void frameListener(Frame frame) // the frame handler { currentFrame = frame; double[] distances = new double[5]; i++; if (i == Constants.framesInterval) { if (UpdateEnable == true) { distances = LeapEventListener.getDistances(frame); OutputData1.Text = distances[0].ToString(); OutputData2.Text = distances[1].ToString(); OutputData3.Text = distances[2].ToString(); OutputData4.Text = distances[3].ToString(); OutputData5.Text = distances[4].ToString(); } i = 0; } }
void TranslateInstance(Frame frame) { // Create a new Linear kernel IKernel kernel = new Linear(); // Create a new Multi-class Support Vector Machine with one input, // using the linear kernel and for four disjoint classes. var machine = new MulticlassSupportVectorMachine(5, kernel, numOfClasses); // Create the Multi-class learning algorithm for the machine var teacher = new MulticlassSupportVectorLearning(machine, inputs, outputs); // Configure the learning algorithm to use SMO to train the // underlying SVMs in each of the binary class subproblems. teacher.Algorithm = (svm, classInputs, classOutputs, i, j) => new SequentialMinimalOptimization(svm, classInputs, classOutputs); // Run the learning algorithm double error = teacher.Run(); // output should be 0 double[] distances = new double[5]; distances = LeapEventListener.getDistances(frame); int decision = machine.Compute(distances); //svm AI output.Text = output.Text + Char2SvmClass.class2svm(decision); }
public MainMenu() { InitializeComponent(); //initializing listener and controller this.controller = new Controller(); this.listener = new LeapEventListener(this); controller.AddListener(listener); }
public CountinuousTranslate() { InitializeComponent(); InitializeSVM(); InitilizeTimer(); this.controller = new Controller(); this.listener = new LeapEventListener(this); controller.AddListener(listener); }
private int i = 0; // listener interval public SingleInstanceTranslate() { InitializeComponent(); InitializeSVM(); this.controller = new Controller(); this.listener = new LeapEventListener(this); controller.AddListener(listener); }
private int i = 0; // listener interval public SignsDatabase() { InitializeComponent(); this.Focus(); InitializeList(); // initialize samples from database to a list //initializing listener and controller controller = new Controller(); listener = new LeapEventListener(this); controller.AddListener(listener); }
private void Timer_Tick(Object sender, EventArgs e) //timer for continuous check { if (currentFrame != null) { double[] velocityArr = LeapEventListener.getVelocity(currentFrame); ts++; if (velocityArr[0] < Constants.velocityThreshold && velocityArr[1] < Constants.velocityThreshold && velocityArr[2] < Constants.velocityThreshold && velocityArr[3] < Constants.velocityThreshold && velocityArr[4] < Constants.velocityThreshold) { if (LeapEventListener.isZeros(velocityArr) == false) { /* * if (ts - timeStamp > Constants.positionStallThreshold / 10) * { * tempFrame = currentFrame; * timeStamp = ts; * TranslateInstance(tempFrame); * * } */ if (toExtract == false) // if the letter is not ready for extraction { tempFrame = currentFrame; timeStamp = ts; toExtract = true; printPermission = true; // gives permission for the letter to be printed, prevent duplicates } if (ts - timeStamp > (Constants.positionStallThreshold / 10) / 2) //check if the user stayed in the same position 1 sec { tempFrame = currentFrame; } if (ts - timeStamp > Constants.positionStallThreshold / 10 && toExtract == true && printPermission == true) //check if the user stayed in the same position 1 sec { printPermission = false; TranslateInstance(tempFrame); timeStamp = 0; ts = 0; } } } else//user switch to the next letter { toExtract = false; printPermission = false; // timeStamp = ts; // sahar } } }
private void saveSapmle(Frame fr) { double[] distances = new double[5]; distances = LeapEventListener.getDistances(fr); if (fr == null || LeapEventListener.isZeros(distances) == true) { MessageBox.Show("The frame is null.\n Try reconnecting the Leap device", "Application Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } else { if (MessageBox.Show("Do you want to save the sample as " + LettersCombo.Text + "?", "Signs DataSet", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { saveSampleToDB(LettersCombo.Text, distances[0], distances[1], distances[2], distances[3], distances[4]); } } }
private void TranslateBtn_Click(object sender, EventArgs e) { double[] distances = new double[5]; distances = LeapEventListener.getDistances(currentFrame); if (LeapEventListener.isZeros(distances) == true) { MessageBox.Show("The frame is null.\n Try reconnecting the Leap device", "Application Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } else { // Create a new Linear kernel IKernel kernel = new Linear(); // Create a new Multi-class Support Vector Machine with one input, // using the linear kernel and for four disjoint classes. var machine = new MulticlassSupportVectorMachine(5, kernel, numOfClasses); // Create the Multi-class learning algorithm for the machine var teacher = new MulticlassSupportVectorLearning(machine, inputs, outputs); // Configure the learning algorithm to use SMO to train the // underlying SVMs in each of the binary class subproblems. teacher.Algorithm = (svm, classInputs, classOutputs, i, j) => new SequentialMinimalOptimization(svm, classInputs, classOutputs); // Run the learning algorithm double error = teacher.Run(); // output should be 0 int decision = machine.Compute(distances); //svm AI output.Text = output.Text + Char2SvmClass.class2svm(decision); } }