/// <summary> /// RGB カメラのデータ更新イベントハンドラ /// </summary> /// <param name="sender">イベント送信元</param> /// <param name="e">イベント引数</param> void kinectManager_ColorUpdate(object sender, ColorUpdateEventArgs e) { _colorSource = null; if (!_cameraOptions.ColorDrawEnable) { return; } ColorImageFrame colorFrame = e.ColorFrame; byte[] colorPixel = new byte[colorFrame.PixelDataLength]; colorFrame.CopyPixelDataTo(colorPixel); _colorSource = BitmapSource.Create( colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, colorPixel, colorFrame.Width * colorFrame.BytesPerPixel ); }
/// <summary> /// RGB カメラフレーム更新イベントハンドラ /// </summary> /// <param name="sender">Kinect センサー</param> /// <param name="e">イベント</param> private void _kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e) { if (!_drawEnable) { return; } KinectSensor kinect = sender as KinectSensor; if (kinect == null) { return; } // RGB カメラのフレームデータを取得する using (ColorImageFrame colorFrame = e.OpenColorImageFrame()) { if (colorFrame == null) { return; } EventHandler<ColorUpdateEventArgs> eventHandler = ColorUpdate; if (eventHandler != null) { ColorUpdateEventArgs args = new ColorUpdateEventArgs(); args.Kinect = kinect; args.ColorFrame = colorFrame; eventHandler(this, args); } } }
/// <summary> /// RGB カメラのデータ更新イベントハンドラ /// </summary> /// <param name="sender">イベント送信元</param> /// <param name="e">イベント引数</param> private void _kinectManager_ColorUpdate(object sender, ColorUpdateEventArgs e) { RaisePropertyChanged("ColorSource"); }