private void Classify() { if (this.classifier == null || this.classifier.HasUpdates /* update flag */) { this.classifier = new GestureClassifier(); this.classifier.ProblemFile = this.featureFilePath; this.classifier.ModelFile = this.modelFilePath; this.classifier.CategoryDetected += classifier_CategoryDetected; GestureStudio.DisplayLoadingWindow("Loading Image Classifier..."); this.classifier.BeginInitialize(() => { GestureStudio.HideLoadingWindow(); }); } if (this.classifier.Initialized) { this.UpdateStatus("Classifying"); this.classifier.ClassifyImage(this.croppedFrame); } else { this.UpdateStatus("Loading Classifier..."); } }
private void Train() { if (this.trainer == null) { this.trainer = new GestureLearner(); this.trainer.ProblemFile = this.featureFilePath; this.trainer.ImageCollectionFinished += trainer_ImageCollectionFinished; this.trainer.NewModelReady += trainer_NewModelReady; GestureStudio.DisplayLoadingWindow("Loading Gesture Trainer..."); this.trainer.BeginInitialize(() => { GestureStudio.HideLoadingWindow(); }); } else if (this.trainer.CurrentSampleCount == 0) { } if (this.trainer.Initialized) { if (!this.trainer.GestureDataReady) { this.UpdateStatus("Collecting Gesture " + this.trainer.CurrentSampleCount + " of 30"); this.trainer.LearnGesture(this.croppedFrame); } else if (!this.trainer.ModelBuildStarted) { this.UpdateStatus("Building Prediction Model..."); GestureStudio.DisplayLoadingWindow("Building Prediction Model..."); this.trainer.BuildModel(() => { GestureStudio.HideLoadingWindow(); }); } else { // training finished this.Stop(); } } else { // waiting for init, do nothing } }
public void BeginInitialize() { this.floodFill = new FloodFill(); this.mode = ProgramMode.Idle; this.classifier = null; this.trainer = null; this.featureFilePath = null; this.modelFilePath = null; GestureStudio.DisplayLoadingWindow("Loading Kinect Sensor..."); ThreadPool.QueueUserWorkItem((state) => { // init kinect this.StartKinectSensor(); GestureStudio.HideLoadingWindow(); this.UpdateStatus("Ready"); }); }
void InternalInitialize(Action initializeCallback) { modelBuilder = new SvmModelBuilder(); this.featureVector = new List <double[]>(); // init omp this.imgFeature = new ImageFeature(GestureStudio.GestureLib_DictionartyPath); // update GestureInfo.data if (this.problemFile == null || this.problemFile.Equals(GestureStudio.FeatureFileEmpty)) { Gestures.loadData(GestureStudio.GesturesDataPathEmpty); } else if (this.problemFile.Equals(GestureStudio.FeatureFileNew)) { Gestures.loadData(GestureStudio.GesturesDataPathNew); } else // demo version, this will take a long time. So avoid this in the demo. { Gestures.loadData(GestureStudio.GesturesDataPathDemo); } // done initialization if (initializeCallback != null) { initializeCallback(); } // display trainer form SynchronizationContext ctx = SynchronizationContext.Current; GestureStudio.DisplayTrainerForm(() => { // count down finished, begin this.initialized = true; }); }