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); }
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); } }