/// <summary> /// Constructor. /// </summary> public MainWindowViewModel() { this.Preferences = new Preferences(); this.Proxies = new Proxies(this.Preferences); this.LoadData(); // Create Nao teacher. this.NaoTeacher = new NaoTeacher(this.Preferences, this.Proxies, this.Scenario); // Color stream. this.ColorStreamManager = new ColorStreamManager(); this.ColorStreamManager.PropertyChanged += this.ColorStreamManagerPropertyChanged; this.Proxies.KinectSensor.ColorFrameReady += this.KinectSensorColorFrameReady; // Skeleton stream. this.Proxies.KinectSensor.SkeletonFrameReady += this.KinectSensorSkeletonFrameReady; this.Proxies.KinectSensor.SkeletonFrameReady += this.NaoTeacher.KinectSensorSkeletonFrameReady; //this.Scenario.Add(new LeftHandPunchScene("C:\\Users\\bootsman\\Desktop\\data.v1.kinect", new Score(20, 5))); //this.Scenario.Add(new GedanBaraiScene("C:\\Users\\bootsman\\Desktop\\data.v2.kinect", new Score(30, 10))); //this.Scenario.Add(new RightHandPunchScene("C:\\Users\\bootsman\\Desktop\\data.v3.kinect", new Score(20, 5))); }
private void UninitializeRuntime() { if (_runtime == null) { return; } _runtime.VideoFrameReady -= RuntimeVideoFrameReady; _runtime.Uninitialize(); _colorStreamManager = null; _runtime = null; }
private void InitializeRuntime() { UninitializeRuntime(); _runtime = new Runtime(); //在建立Runtime 的Instance的同時,也順便建立ColorStreamManager的Instance _colorStreamManager = new ColorStreamManager(); //因為我們只要取得基本的鏡頭拍到的畫面而已,所以只需要將RuntimeOptions設定為UseColor即可 _runtime.Initialize(RuntimeOptions.UseColor); //透過VideoStream.Open方法開始取得視訊串流 _runtime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); //替VideoFrameReady加入EventHandler,把畫面畫在Image中。 _runtime.VideoFrameReady += new EventHandler <ImageFrameReadyEventArgs>(RuntimeVideoFrameReady); }
public void Dispose() { if (skeletonDisplayManager != null) { skeletonDisplayManager = null; } if (colorManager != null) { colorManager = null; } if (depthManager != null) { depthManager = null; } if (speechRecognizer != null) { speechRecognizer.SpeechRecognized -= Speech_Recognized; speechRecognizer.Dispose(); speechRecognizer = null; } if (gestureRecognizer != null) { gestureRecognizer.GestureRecognzied -= Gesture_Recognzied; gestureRecognizer.Dispose(); gestureRecognizer = null; } if (kinectSensor != null) { kinectSensor.ColorFrameReady -= kinectRuntime_ColorFrameReady; kinectSensor.SkeletonFrameReady -= kinectRuntime_SkeletonFrameReady; kinectSensor.ColorFrameReady -= kinectRuntime_ColorFrameReady; kinectSensor.Stop(); kinectSensor = null; } }
public void LoadColorManager(Image colorDisplay) { colorManager = new ColorStreamManager(); colorDisplay.DataContext = colorManager; }