/// <summary> /// コンストラクタ /// </summary> public MainWindowViewModel() { _kinectManager = new KinectManager(); _cameraOptions = new CameraOptions(); _jointsOption = new JointsOption(); _blenderOptions = new BlenderOptions(); _originPositionAutoSetter = new OriginPositionAutoSetter(_jointsOption); _kinectDataManager = new KinectDataManager(_cameraOptions, _blenderOptions, _jointsOption); _parameterFileManager = new ParameterFileManager(this); _statusBarMessage = ""; }
/// <summary> /// Called when the KinectSensorChooser gets a new sensor /// </summary> /// <param name="sender">sender of the event</param> /// <param name="args">event arguments</param> private void SensorChooserOnKinectChanged(object sender, KinectChangedEventArgs args) { if (args.OldSensor != null) { try { args.OldSensor.DepthStream.Range = DepthRange.Default; args.OldSensor.SkeletonStream.EnableTrackingInNearRange = false; args.OldSensor.DepthStream.Disable(); args.OldSensor.SkeletonStream.Disable(); } catch (InvalidOperationException) { // KinectSensor might enter an invalid state while enabling/disabling streams or stream features. // E.g.: sensor might be abruptly unplugged. } } if (args.NewSensor != null) { try { kinect_sensor = args.NewSensor; kinect_data_manager = new KinectDataManager(ref kinect_sensor); kinect_sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); kinect_sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); kinect_sensor.SkeletonStream.Enable(); // set source (must after source has been initialized otherwise it's null forever) kinect_data_manager.ColorStreamBitmap = new WriteableBitmap( kinect_sensor.ColorStream.FrameWidth, kinect_sensor.ColorStream.FrameHeight, 96, 96, PixelFormats.Bgr32, null); color_disp_img.Source = kinect_data_manager.ColorStreamBitmap; ske_disp_img.Source = kinect_data_manager.skeletonImageSource; // bind event handlers kinect_sensor.ColorFrameReady += kinect_colorframe_ready; kinect_sensor.SkeletonFrameReady += kinect_skeletonframe_ready; } catch (InvalidOperationException) { // KinectSensor might enter an invalid state while enabling/disabling streams or stream features. // E.g.: sensor might be abruptly unplugged. } isStreaming = true; kinect_data_manager.ifShowJointStatus = true; frame_rec_buffer.Clear(); kinect_sensor.Start(); } }
/// <summary> /// initialize kinect sensor and init data members /// </summary> private bool InitKinect() { // enumerate and fetch an available sensor foreach (var potentialsensor in KinectSensor.KinectSensors) { if (potentialsensor.Status == KinectStatus.Connected) { kinect_sensor = potentialsensor; break; } } if (kinect_sensor != null) kinect_data_manager = new KinectDataManager(ref kinect_sensor); // enable data stream if (kinect_sensor != null) { // initialize all streams kinect_sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); kinect_sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); //kinect_sensor.SkeletonStream.Enable(); // can't use IR simultaneously with color! //kinect_sensor.ColorStream.Enable(ColorImageFormat.InfraredResolution640x480Fps30); // initialize image sources kinect_data_manager.ColorStreamBitmap = new WriteableBitmap( kinect_sensor.ColorStream.FrameWidth, kinect_sensor.ColorStream.FrameHeight, 96, 96, PixelFormats.Bgr32, null); kinect_data_manager.DepthStreamBitmap = new WriteableBitmap( kinect_sensor.DepthStream.FrameWidth, kinect_sensor.DepthStream.FrameHeight, 96, 96, PixelFormats.Bgr32, null); // set source (must after source has been initialized otherwise it's null forever) color_disp_img.Source = kinect_data_manager.ColorStreamBitmap; depth_disp_img.Source = kinect_data_manager.DepthStreamBitmap; skeleton_disp_img.Source = kinect_data_manager.skeletonImageSource; // bind event handlers kinect_sensor.ColorFrameReady += kinect_colorframe_ready; kinect_sensor.DepthFrameReady += kinect_depthframe_ready; kinect_sensor.SkeletonFrameReady += kinect_skeletonframe_ready; // enable data stream based on initial check if (!colorCheckBox.IsChecked.Value) kinect_sensor.ColorStream.Disable(); if (!depthCheckBox.IsChecked.Value) kinect_sensor.DepthStream.Disable(); if (!skeletonCheckBox.IsChecked.Value) kinect_sensor.SkeletonStream.Disable(); } else return false; return true; }
/// <summary> /// initialize kinect sensor and init data members /// </summary> private bool InitKinect() { // enumerate and fetch an available sensor foreach (var potentialsensor in KinectSensor.KinectSensors) { if (potentialsensor.Status == KinectStatus.Connected) { kinect_sensor = potentialsensor; break; } } // enable data stream if (kinect_sensor != null) { // initialize data manager kinect_data_manager = new KinectDataManager(ref kinect_sensor); //replay_data_manager = new KinectDataManager(ref kinect_sensor); // initialize stream kinect_sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); if (ifDoSmoothing) { TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); { // Some smoothing with little latency (defaults). // Only filters out small jitters. // Good for gesture recognition in games. smoothingParam.Smoothing = 0.5f; smoothingParam.Correction = 0.5f; smoothingParam.Prediction = 0.5f; smoothingParam.JitterRadius = 0.05f; smoothingParam.MaxDeviationRadius = 0.04f; // Smoothed with some latency. // Filters out medium jitters. // Good for a menu system that needs to be smooth but // doesn't need the reduced latency as much as gesture recognition does. //smoothingParam.Smoothing = 0.5f; //smoothingParam.Correction = 0.1f; //smoothingParam.Prediction = 0.5f; //smoothingParam.JitterRadius = 0.1f; //smoothingParam.MaxDeviationRadius = 0.1f; //// Very smooth, but with a lot of latency. //// Filters out large jitters. //// Good for situations where smooth data is absolutely required //// and latency is not an issue. //smoothingParam.Smoothing = 0.7f; //smoothingParam.Correction = 0.3f; //smoothingParam.Prediction = 1.0f; //smoothingParam.JitterRadius = 1.0f; //smoothingParam.MaxDeviationRadius = 1.0f; }; kinect_sensor.SkeletonStream.Enable(smoothingParam); } else { kinect_sensor.SkeletonStream.Enable(); } // set source (must after source has been initialized otherwise it's null forever) kinect_data_manager.ColorStreamBitmap = new WriteableBitmap( kinect_sensor.ColorStream.FrameWidth, kinect_sensor.ColorStream.FrameHeight, 96, 96, PixelFormats.Bgr32, null); color_disp_img.Source = kinect_data_manager.ColorStreamBitmap; ske_disp_img.Source = kinect_data_manager.skeletonImageSource; // bind event handlers kinect_sensor.ColorFrameReady += kinect_colorframe_ready; kinect_sensor.SkeletonFrameReady += kinect_skeletonframe_ready; } else { // invalidate all buttons gestureReplayBtn.IsEnabled = false; return(false); } return(true); }
/// <summary> /// initialize kinect sensor and init data members /// </summary> private bool InitKinect() { // enumerate and fetch an available sensor foreach (var potentialsensor in KinectSensor.KinectSensors) { if (potentialsensor.Status == KinectStatus.Connected) { kinect_sensor = potentialsensor; break; } } // enable data stream if (kinect_sensor != null) { // initialize data manager kinect_data_manager = new KinectDataManager(ref kinect_sensor); //replay_data_manager = new KinectDataManager(ref kinect_sensor); // initialize stream kinect_sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); if (ifDoSmoothing) { TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); { // Some smoothing with little latency (defaults). // Only filters out small jitters. // Good for gesture recognition in games. smoothingParam.Smoothing = 0.5f; smoothingParam.Correction = 0.5f; smoothingParam.Prediction = 0.5f; smoothingParam.JitterRadius = 0.05f; smoothingParam.MaxDeviationRadius = 0.04f; // Smoothed with some latency. // Filters out medium jitters. // Good for a menu system that needs to be smooth but // doesn't need the reduced latency as much as gesture recognition does. //smoothingParam.Smoothing = 0.5f; //smoothingParam.Correction = 0.1f; //smoothingParam.Prediction = 0.5f; //smoothingParam.JitterRadius = 0.1f; //smoothingParam.MaxDeviationRadius = 0.1f; //// Very smooth, but with a lot of latency. //// Filters out large jitters. //// Good for situations where smooth data is absolutely required //// and latency is not an issue. //smoothingParam.Smoothing = 0.7f; //smoothingParam.Correction = 0.3f; //smoothingParam.Prediction = 1.0f; //smoothingParam.JitterRadius = 1.0f; //smoothingParam.MaxDeviationRadius = 1.0f; }; kinect_sensor.SkeletonStream.Enable(smoothingParam); } else kinect_sensor.SkeletonStream.Enable(); // set source (must after source has been initialized otherwise it's null forever) kinect_data_manager.ColorStreamBitmap = new WriteableBitmap( kinect_sensor.ColorStream.FrameWidth, kinect_sensor.ColorStream.FrameHeight, 96, 96, PixelFormats.Bgr32, null); color_disp_img.Source = kinect_data_manager.ColorStreamBitmap; ske_disp_img.Source = kinect_data_manager.skeletonImageSource; // bind event handlers kinect_sensor.ColorFrameReady += kinect_colorframe_ready; kinect_sensor.SkeletonFrameReady += kinect_skeletonframe_ready; } else { // invalidate all buttons gestureReplayBtn.IsEnabled = false; return false; } return true; }
/// <summary> /// initialize kinect sensor and init data members /// </summary> private bool InitKinect() { // enumerate and fetch an available sensor foreach (var potentialsensor in KinectSensor.KinectSensors) { if (potentialsensor.Status == KinectStatus.Connected) { kinect_sensor = potentialsensor; break; } } if (kinect_sensor != null) { kinect_data_manager = new KinectDataManager(ref kinect_sensor); } // enable data stream if (kinect_sensor != null) { // initialize all streams kinect_sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); kinect_sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); //kinect_sensor.SkeletonStream.Enable(); // can't use IR simultaneously with color! //kinect_sensor.ColorStream.Enable(ColorImageFormat.InfraredResolution640x480Fps30); // initialize image sources kinect_data_manager.ColorStreamBitmap = new WriteableBitmap( kinect_sensor.ColorStream.FrameWidth, kinect_sensor.ColorStream.FrameHeight, 96, 96, PixelFormats.Bgr32, null); kinect_data_manager.DepthStreamBitmap = new WriteableBitmap( kinect_sensor.DepthStream.FrameWidth, kinect_sensor.DepthStream.FrameHeight, 96, 96, PixelFormats.Bgr32, null); // set source (must after source has been initialized otherwise it's null forever) color_disp_img.Source = kinect_data_manager.ColorStreamBitmap; depth_disp_img.Source = kinect_data_manager.DepthStreamBitmap; skeleton_disp_img.Source = kinect_data_manager.skeletonImageSource; // bind event handlers kinect_sensor.ColorFrameReady += kinect_colorframe_ready; kinect_sensor.DepthFrameReady += kinect_depthframe_ready; kinect_sensor.SkeletonFrameReady += kinect_skeletonframe_ready; // enable data stream based on initial check if (!colorCheckBox.IsChecked.Value) { kinect_sensor.ColorStream.Disable(); } if (!depthCheckBox.IsChecked.Value) { kinect_sensor.DepthStream.Disable(); } if (!skeletonCheckBox.IsChecked.Value) { kinect_sensor.SkeletonStream.Disable(); } } else { return(false); } return(true); }