public static Results EvaluateContinuousRecognizer(DeviceType device) { // Get the list of participants 15 through 24 List <int> participants = new List <int> { 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; Results all_results = new Results(); all_results.Reset(); long one = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; // at beginning Results user_results = new Results(); for (int pid = 0; pid < participants.Count; pid++) { Debug.Log("Running Yeah evaluation on Participant " + participants[pid]); user_results.Reset(); for (int ii = 0; ii < 10; ii++) { Results tempResults = EvaluateSession(device, participants[pid]); tempResults.PrintF(); user_results.AppendResults(tempResults); } all_results.AppendResults(user_results); Debug.Log("Results for Participant " + participants[pid]); user_results.PrintF(); } long two = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; // at beginning Debug.Log(string.Format("Time elapsed {0} seconds", (two - one) / 1000)); Debug.Log("Overall results"); all_results.PrintF(); return(all_results); }
public static Results EvaluateSessionWindowed(DeviceType device, int subject_id) { configuartion_parameters_t parameneters = new configuartion_parameters_t(device); // Load subject dataset Dataset ds = Global.load_subject_dataset(device, subject_id); List <Sample> train_set = Global.GetTrainSet(ds, 1); // Covert the dataset to format accepted by Jackknife List <Jackknife.Sample> jk_train_set = JackknifeConnector.GetJKTrainSet(train_set); // Load subject session List <Frame> frames = new List <Frame>(); Global.load_session(device, subject_id, frames, ds); // Load ground truth List <GestureCommand> cmds = new List <GestureCommand>(); GestureCommand.GetAllCommands(cmds, ds, device, subject_id); // Train the recognizer JackknifeBlades blades = new JackknifeBlades(); blades.SetIPDefaults(); blades.ResampleCnt = 20; Jackknife.Jackknife jk = new Jackknife.Jackknife(blades); foreach (Jackknife.Sample s in jk_train_set) { jk.AddTemplate(s); } // Set between 2.0 and 10.0 in steps of .25 // to find the best result jk.SetRejectionThresholds(5.25f); // Set up filter for session points ExponentialMovingAverage ema_filter = new ExponentialMovingAverage(frames[0].pt); Vector pt; WindowSegmentor windowSegmentor = new WindowSegmentor(jk); //List<RecognitionResult> rresults = new List<RecognitionResult>(); List <ContinuousResult> continuous_results = new List <ContinuousResult>(); // Go through session for (int session_pt = 0; session_pt < frames.Count; session_pt++) { long ts1 = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; // at beginning pt = ema_filter.Filter(frames[session_pt].pt, 1 / (double)parameneters.fps); long ts2 = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; // after filter Jackknife.Vector jkpt = JackknifeConnector.ToJKVector(pt); windowSegmentor.Update(jkpt); windowSegmentor.Segment(continuous_results); if (session_pt % 2000 == 0) { Debug.Log(string.Format("{0}% Done", (double)session_pt / (double)frames.Count * 100.0)); } } foreach (ContinuousResult cr in continuous_results) { Debug.Log(string.Format("st {0}, en {1}, gid {2}", cr.startFrameNo, cr.endFrameNo, cr.gid)); } // Per gesture confusion matrix List <ConfisionMatrix> cm = new List <ConfisionMatrix>(); for (int ii = 0; ii < ds.Gestures.Count; ii++) { cm.Add(new ConfisionMatrix()); } for (int ii = 0; ii < continuous_results.Count; ii++) { ContinuousResult result = continuous_results[ii]; bool found = false; int cidx = 0; for (cidx = 0; cidx < cmds.Count; cidx++) { found = cmds[cidx].Hit(result); if (found == true) { break; } } if (found == true) { // true positive if (cmds[cidx].detected == false) { cmds[cidx].detected = true; cm[result.gid].tp += 1.0f; } } else { bool bad = GestureCommand.IsBadCommand( frames, result); if (bad == true) { continue; } // false positive cm[result.gid].fp += 1.0f; } } // false negatives for (int cidx = 0; cidx < cmds.Count; cidx++) { if (cmds[cidx].detected == true) { continue; } cm[cmds[cidx].gid].fn += 1.0; } Results ret = new Results(); for (int ii = 0; ii < cm.Count; ii++) { ret.AppendResults(cm[ii]); } ret.PrintF(); return(ret); }
void Update() { if (eStatus == EvaluationStatus.TRAINING) { if (segmentorType == SegmentorType.MACHETE) { Prepare(); } else if (segmentorType == SegmentorType.WINDOW) { PrepareWindow(); } eStatus = EvaluationStatus.EVALUATING; } if (eStatus == EvaluationStatus.EVALUATING) { if (frame_idx > 1) { // Time since last frame timer += Time.deltaTime; // Total time timeStats_UserDependent.add(Time.deltaTime); timeStats_Overall.add(Time.deltaTime); } if (segmentorType == SegmentorType.MACHETE) { Step(); } else if (segmentorType == SegmentorType.WINDOW) { StepWindow(); } frame_idx += 1; if (frame_idx == frames.Count) { eStatus = EvaluationStatus.SUMMARIZING; } } if (eStatus == EvaluationStatus.SUMMARIZING) { Summarize(); eStatus = EvaluationStatus.TRANSITION; } if (eStatus == EvaluationStatus.TRANSITION) { iteration += 1; Debug.Log(string.Format("Iteration {2} User# {0}, (Participant {1}) Completed.\n", currentParticipantIndex, currentParticipantID, iteration)); iteration_results.PrintF(); user_results.AppendResults(iteration_results); // PrintTimes(); iteration_results.Reset(); // If all iterations are done, continue to next participant if (iteration == iterationCount) { // Save results into a file and to all results logResultsToFile("stats.csv", user_results, timeStats_UserDependent, "PID " + currentParticipantID); all_results.AppendResults(user_results); iteration = 0; currentParticipantIndex += 1; timeStats_UserDependent.reset(); user_results.Reset(); } // If all participants done, we're finished if (currentParticipantIndex == participants.Count) { Debug.Log("FINISHED"); eStatus = EvaluationStatus.FINISHED; all_results.PrintF(); logResultsToFile("stats.csv", all_results, timeStats_Overall, "global"); timeStats_Overall.reset(); return; } eStatus = EvaluationStatus.TRAINING; } if (eStatus == EvaluationStatus.FINISHED) { } }