//セットアップ public KinectImage() #region { //キネクト this.kinect = KinectSensor.GetDefault(); //bodyIndexFrameの処理 this.bodyIndexFrameDes = this.kinect.BodyIndexFrameSource.FrameDescription; this.bodyIndexFrameReader = this.kinect.BodyIndexFrameSource.OpenReader(); this.bodyIndexFrameReader.FrameArrived += this.BodyIndexFrame_Arrived; //画像情報 this.kinectImgPackage = new ShadowPackage(); this.imageWidth = this.bodyIndexFrameDes.Width; // imgW; this.imageHeight = this.bodyIndexFrameDes.Height; // imgH; this.imageBytePerPixel = (int)this.bodyIndexFrameDes.BytesPerPixel; this.bitmapRec = new Int32Rect(0, 0, this.imageWidth, this.imageHeight); this.bitmapStride = (int)(this.imageWidth * this.imageBytePerPixel); this.bodyIndexBuffer = new byte[this.imageWidth * this.imageHeight * this.imageBytePerPixel]; this.kinectImage = new Mat(this.imageHeight, this.imageWidth, MatType.CV_8UC1); //キネクト開始 this.kinect.Open(); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (bodyIndexFrameReader != null) { bodyIndexFrameReader.Dispose(); bodyIndexFrameReader = null; } if (bodyFrameReader != null) { bodyFrameReader.Dispose(); bodyFrameReader = null; } if (audioBeamFrameReader != null) { audioBeamFrameReader.Dispose(); audioBeamFrameReader = null; } if (kinect != null) { kinect.Close(); kinect = null; } }
protected override void OnNavigatingFrom( NavigatingCancelEventArgs e) { base.OnNavigatingFrom(e); if (bodyIndexFrameReader != null) { bodyIndexFrameReader.Dispose(); bodyIndexFrameReader = null; } if (bodyFrameReader != null) { bodyFrameReader.Dispose(); bodyFrameReader = null; } if (audioBeamFrameReader != null) { audioBeamFrameReader.Dispose(); audioBeamFrameReader = null; } if (kinect != null) { kinect.Close(); kinect = null; } }
public void Dispose() { if (Server != null) { Server.Dispose(); } if (BodyFrameReader != null) { BodyFrameReader.Dispose(); } if (BodyIndexFrameReader != null) { BodyIndexFrameReader.Dispose(); } if (Sensor != null) { Sensor.Close(); } Server = null; BodyFrameReader = null; BodyIndexFrameReader = null; Sensor = null; }
public MainWindow() { kinect = KinectSensor.GetDefault(); bodyIndexFrameReader = kinect.BodyIndexFrameSource.OpenReader(); bodyIndexFrameReader.FrameArrived += Reader_BodyIndexFrameArrived; FrameDescription bodyIndexFrameDescription = kinect.BodyIndexFrameSource.FrameDescription; bodyIndexBitmap = new WriteableBitmap(bodyIndexFrameDescription.Width, bodyIndexFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); bodyIndexPixels = new byte[bodyIndexFrameDescription.LengthInPixels]; bitmapPixels = new byte[bodyIndexFrameDescription.Width * bodyIndexFrameDescription.Height * 4]; Color[] bodyIndexColors = { Colors.Red, Colors.Blue, Colors.Green, Colors.Yellow, Colors.Purple, Colors.Orange }; kinect.Open(); DataContext = this; }
//セットアップ public KinectImage() #region { //キネクト this.kinect = KinectSensor.GetDefault(); //bodyIndexFrameの処理 this.bodyIndexFrameDes = this.kinect.BodyIndexFrameSource.FrameDescription; this.bodyIndexFrameReader = this.kinect.BodyIndexFrameSource.OpenReader(); this.bodyIndexFrameReader.FrameArrived += this.BodyIndexFrame_Arrived; //画像情報 this.kinectImgPackage = new ShadowPackage(); this.imageWidth = this.bodyIndexFrameDes.Width; // imgW; this.imageHeight = this.bodyIndexFrameDes.Height; // imgH; this.imageBytePerPixel = (int)this.bodyIndexFrameDes.BytesPerPixel; this.bitmapRec = new Int32Rect(0, 0, this.imageWidth, this.imageHeight); this.bitmapStride = (int)(this.imageWidth * this.imageBytePerPixel); this.bodyIndexBuffer = new byte[this.imageWidth * this.imageHeight * this.imageBytePerPixel]; this.kinectImage = new Mat(this.imageHeight, this.imageWidth, MatType.CV_8UC1); //キネクト開始 this.kinect.Open(); }
/// <summary> /// Execute shutdown tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (this.bodyIndexFrameReader != null) { // remove the event handler this.bodyIndexFrameReader.FrameArrived -= this.Reader_FrameArrived; // BodyIndexFrameReder is IDisposable this.bodyIndexFrameReader.Dispose(); this.bodyIndexFrameReader = null; } if (this.colorFrameReader != null) { // ColorFrameReder is IDisposable this.colorFrameReader.Dispose(); this.colorFrameReader = null; } if (this.kinectSensor != null) { this.kinectSensor.Close(); this.kinectSensor = null; } }
public void ShowAndStart() { sensor = KinectSensor.GetDefault(); if (sensor != null) { reader = sensor.BodyIndexFrameSource.OpenReader(); var frameDesc = sensor.BodyIndexFrameSource.FrameDescription; BodyIndexWidth = frameDesc.Width; BodyIndexHeight = frameDesc.Height; texture = new Texture2D(BodyIndexWidth, BodyIndexHeight, TextureFormat.BGRA32, false); data = new byte[frameDesc.LengthInPixels * 4]; rawData = new byte[frameDesc.LengthInPixels]; if (sensor.IsOpen == false) { sensor.Open(); bodyIndexPlane.GetComponent <MeshRenderer>().enabled = true; BodyIndexActive = true; } } }
/// <summary> /// Initializes a new instance of the MainWindow class. /// </summary> public MainWindow() { // get the kinectSensor object this.kinectSensor = KinectSensor.GetDefault(); // open the reader for the depth frames this.bodyIndexFrameReader = this.kinectSensor.BodyIndexFrameSource.OpenReader(); // wire handler for frame arrival this.bodyIndexFrameReader.FrameArrived += this.Reader_FrameArrived; this.bodyIndexFrameDescription = this.kinectSensor.BodyIndexFrameSource.FrameDescription; // allocate space to put the pixels being converted this.bodyIndexPixels = new uint[this.bodyIndexFrameDescription.Width * this.bodyIndexFrameDescription.Height]; // create the bitmap to display this.bodyIndexBitmap = new WriteableBitmap(this.bodyIndexFrameDescription.Width, this.bodyIndexFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); // set IsAvailableChanged event notifier this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged; // open the sensor this.kinectSensor.Open(); // set the status text this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText : Properties.Resources.NoSensorStatusText; // use the window object as the view model in this simple example this.DataContext = this; // initialize the components (controls) of the window this.InitializeComponent(); }
//終了時の処理 public void OnClose() { //カラーリーダーの終了 if (this.colorFrameReader != null) { this.colorFrameReader.Dispose(); this.colorFrameReader = null; } //ボディリーダーの終了 if (this.bodyFrameReader != null) { this.bodyFrameReader.Dispose(); this.bodyFrameReader = null; } //ディプスリーダーの終了 if (this.depthFrameReader != null) { this.depthFrameReader.Dispose(); this.depthFrameReader = null; } //BodyIndexFrame if (this.bodyIndexFrameReader != null) { this.bodyIndexFrameReader.Dispose(); this.bodyIndexFrameReader = null; } //キネクトの終了 if (this.kinect != null) { this.kinect.Close(); } }
public void SetPlayer(bool enable) { if (enable) { playerreader = this.Runtime.BodyIndexFrameSource.OpenReader(); playerreader.FrameArrived += this.Runtime_PlayerFrameReady; } }
public void InitializeBodyIndexStream() { // open the reader for the depth frames this.bodyIndexFrameReader = this.kinectSensor.BodyIndexFrameSource.OpenReader(); bodyIHandler = BodyIndexHandler.Instance; bodyIHandler.BodyIndexHandlerSet(this.kinectSensor.BodyIndexFrameSource.FrameDescription); // create the bitmap to display this.bodyIndexBitmap = new WriteableBitmap(bodyIHandler.Width, bodyIHandler.Height, 96.0, 96.0, PixelFormats.Bgr32, null); }
/// <summary> /// Open readers /// </summary> private static void OpenFrameReaders() { // Open readers m_ColorFrameReader = kinectSensor.ColorFrameSource.OpenReader(); m_DepthFrameReader = kinectSensor.DepthFrameSource.OpenReader(); m_BodyFrameReader = kinectSensor.BodyFrameSource.OpenReader(); m_BodyIndexFrameReader = kinectSensor.BodyIndexFrameSource.OpenReader(); m_InfraredFrameReader = kinectSensor.InfraredFrameSource.OpenReader(); }
/// <summary> /// Disposes the BodyIndexFrameReader /// </summary> public void Dispose() { if (this.bodyIndexFrameReader != null) { this.bodyIndexFrameReader.FrameArrived -= this.Reader_BodyIndexFrameArrived; this.bodyIndexFrameReader.Dispose(); this.bodyIndexFrameReader = null; } }
/// <summary> /// Constructor /// </summary> /// <param name="sensor">Kinect sensor</param> public KinectSensorBodyIndexFrameProvider(KinectSensor sensor) { if (sensor == null) throw new ArgumentNullException("sensor"); this.sensor = sensor; this.reader = this.sensor.BodyIndexFrameSource.OpenReader(); this.reader.FrameArrived += this.FrameArrived; this.frameData = new BodyIndexFrameData(); }
public void Start() { if (Sensor == null) { return; } Log("Start sensor..."); // Mapper coordinateMapper = Sensor.CoordinateMapper; // Open connection Sensor.Open(); // Audio Stream StartAudioStream(); if (ConfigManager.GetInstance().Find("kinect_v2.speech.speech_only", true)) { init = true; return; } // Init single frame StartColorStream(); StartDepthStream(); StartInfraredStream(); StartBodyStream(); StartBodyIndexStream(); // Motion Task StartMotionTask(); // Multi Frame Reader // reader = Sensor.OpenMultiSourceFrameReader(FrameSourceTypes.BodyIndex | FrameSourceTypes.Body); // reader.MultiSourceFrameArrived += OnMultipleFramesArrivedHandler; // Single Frame Reader dfr = Sensor.DepthFrameSource.OpenReader(); dfr.FrameArrived += (object sender, DepthFrameArrivedEventArgs e) => { HandleDepthFrame(e.FrameReference); }; xfr = Sensor.InfraredFrameSource.OpenReader(); xfr.FrameArrived += (object sender, InfraredFrameArrivedEventArgs e) => { HandleInfraredFrame(e.FrameReference); }; cfr = Sensor.ColorFrameSource.OpenReader(); cfr.FrameArrived += (object sender, ColorFrameArrivedEventArgs e) => { HandleColorFrame(e.FrameReference); }; bfr = Sensor.BodyFrameSource.OpenReader(); bfr.FrameArrived += (object sender, BodyFrameArrivedEventArgs e) => { HandleBodyFrame(e.FrameReference); }; ifr = Sensor.BodyIndexFrameSource.OpenReader(); ifr.FrameArrived += (object sender, BodyIndexFrameArrivedEventArgs e) => { HandleBodyIndexFrame(e.FrameReference); }; init = true; }
void Initialize() { if (_Sensor != null) { _Reader = _Sensor.BodyIndexFrameSource.OpenReader(); //讀取深度畫面的Pixels總數,定義為陣列型態。 _Data = new byte[_Sensor.BodyIndexFrameSource.FrameDescription.LengthInPixels]; xres = _Sensor.BodyIndexFrameSource.FrameDescription.Width; yres = _Sensor.BodyIndexFrameSource.FrameDescription.Height; } }
void bodyIndexFrameReader_FrameArrived(BodyIndexFrameReader sender, BodyIndexFrameArrivedEventArgs args) { // ボディインデックスデータを取得する using (var bodyIndexFrame = args.FrameReference.AcquireFrame()) { if (bodyIndexFrame == null) { return; } bodyIndexFrame.CopyFrameDataToArray(bodyIndexBuffer); } // ボディインデックスデータをBGRAデータに変換する for (int i = 0; i < bodyIndexBuffer.Length; i++) { var index = bodyIndexBuffer[i]; var colorIndex = i * 4; if (index != 255) { // BodyIndexとビーム方向のTrackingIdのインデックスが // 一致している人の色を変える(青) if (index == AudioTrackingIndex) { bodyIndexColorBuffer[colorIndex + 0] = 255; bodyIndexColorBuffer[colorIndex + 1] = 0; bodyIndexColorBuffer[colorIndex + 2] = 0; bodyIndexColorBuffer[colorIndex + 3] = 255; } else { bodyIndexColorBuffer[colorIndex + 0] = 0; bodyIndexColorBuffer[colorIndex + 1] = 0; bodyIndexColorBuffer[colorIndex + 2] = 255; bodyIndexColorBuffer[colorIndex + 3] = 255; } } else { bodyIndexColorBuffer[colorIndex + 0] = 0; bodyIndexColorBuffer[colorIndex + 1] = 0; bodyIndexColorBuffer[colorIndex + 2] = 0; bodyIndexColorBuffer[colorIndex + 3] = 255; } } // ビットマップにする var stream = bodyIndexColorBitmap.PixelBuffer.AsStream(); stream.Write(bodyIndexColorBuffer, 0, bodyIndexColorBuffer.Length); bodyIndexColorBitmap.Invalidate(); }
/// <summary> /// Constructor /// </summary> /// <param name="sensor">Kinect sensor</param> public KinectSensorBodyIndexFrameProvider(KinectSensor sensor) { if (sensor == null) { throw new ArgumentNullException("sensor"); } this.sensor = sensor; this.reader = this.sensor.BodyIndexFrameSource.OpenReader(); this.reader.FrameArrived += this.FrameArrived; this.frameData = new BodyIndexFrameData(); }
public void CloseSensor(KinectInterop.SensorData sensorData) { if (coordMapper != null) { coordMapper = null; } if (bodyFrameReader != null) { bodyFrameReader.Dispose(); bodyFrameReader = null; } if (bodyIndexFrameReader != null) { bodyIndexFrameReader.Dispose(); bodyIndexFrameReader = null; } if (colorFrameReader != null) { colorFrameReader.Dispose(); colorFrameReader = null; } if (depthFrameReader != null) { depthFrameReader.Dispose(); depthFrameReader = null; } if (infraredFrameReader != null) { infraredFrameReader.Dispose(); infraredFrameReader = null; } if (multiSourceFrameReader != null) { multiSourceFrameReader.Dispose(); multiSourceFrameReader = null; } if (kinectSensor != null) { if (kinectSensor.IsOpen) { kinectSensor.Close(); } kinectSensor = null; } }
//終了時の処理 public void OnClose() #region { if (this.bodyIndexFrameReader != null) { this.bodyIndexFrameReader.Dispose(); this.bodyIndexFrameReader = null; } if (this.kinect != null) { this.kinect.Close(); } }
void Uninitialize() { // 終了処理 if (bodyIndexFrameReader != null) { bodyIndexFrameReader.FrameArrived -= bodyIndexFrameReader_FrameArrived; bodyIndexFrameReader.Dispose(); bodyIndexFrameReader = null; } ImageBodyIndex.Source = null; TextFps.Text = "0"; }
void Initialize() { try { Uninitialize(); // Kinectを開く kinect = KinectSensor.GetDefault(); if (!kinect.IsOpen) { kinect.Open(); } // 表示のためのデータを作成 bodyIndexFrameDesc = kinect.DepthFrameSource.FrameDescription; // ボディーリーダーを開く bodyIndexFrameReader = kinect.BodyIndexFrameSource.OpenReader(); bodyIndexFrameReader.FrameArrived += bodyIndexFrameReader_FrameArrived; // ボディインデックデータ用のバッファ bodyIndexBuffer = new byte[bodyIndexFrameDesc.LengthInPixels]; // 表示のためのビットマップに必要なものを作成 bodyIndexColorImage = new WriteableBitmap( bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height, 96, 96, PixelFormats.Bgra32, null); bodyIndexColorRect = new Int32Rect(0, 0, bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height); bodyIndexColorStride = bodyIndexFrameDesc.Width * bodyIndexColorBytesPerPixel; // ボディインデックデータをBGRA(カラー)データにするためのバッファ bodyIndexColorBuffer = new byte[bodyIndexFrameDesc.LengthInPixels * bodyIndexColorBytesPerPixel]; ImageBodyIndex.Source = bodyIndexColorImage; // 色付けするために色の配列を作成する bodyIndexColors = new Color[] { Colors.Red, Colors.Blue, Colors.Green, Colors.Yellow, Colors.Pink, Colors.Purple, }; } catch (Exception ex) { Uninitialize(); MessageBox.Show(ex.Message); } }
/// Execute shutdown tasks /// </summary> /// <param name ="sender">object sending the event</param> /// <param name ="e">event arguments</param> private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (this._bodyIndexFrameReader != null) { Exit_Click(); // remove the event handler this._bodyIndexFrameReader.FrameArrived -= this.Reader_FrameArrived; // BodyIndexFrameReder is IDisposable this._bodyIndexFrameReader.Dispose(); this._bodyIndexFrameReader = null; } }
protected virtual void OnApplicationQuit() { if (bodyFrameReader != null) { bodyFrameReader.Dispose(); bodyFrameReader = null; } if (colorFrameReader != null) { colorFrameReader.Dispose(); colorFrameReader = null; } if (depthFrameReader != null) { depthFrameReader.Dispose(); depthFrameReader = null; } if (infraredFrameReader != null) { infraredFrameReader.Dispose(); infraredFrameReader = null; } if (bodyIndexFrameReader != null) { bodyIndexFrameReader.Dispose(); bodyIndexFrameReader = null; } if (faceFrameReader != null) { faceFrameReader.Dispose(); faceFrameReader = null; } if (frameView != null) { frameView.FrameTexture = null; } if (KinectSensor != null && KinectSensor.IsOpen) { KinectSensor.Close(); KinectSensor = null; } }
/// Initializes a new instance of the MainWindow class. public MainWindow() { // get the _kinectSensor object this._kinectSensor = KinectSensor.GetDefault(); // open the reader for bodyIndex frames this._bodyIndexFrameReader = this._kinectSensor.BodyIndexFrameSource.OpenReader(); // wire handler for frame arrival this._bodyIndexFrameReader.FrameArrived += this.Reader_FrameArrived; this._bodyIndexFrameDescription = this._kinectSensor.BodyIndexFrameSource.FrameDescription; // allocate space to put the pixels being converted this._bodyIndexPixels = new uint[this._bodyIndexFrameDescription.Width * this._bodyIndexFrameDescription.Height]; // create the bitmap to display this._bodyIndexBitmap = new WriteableBitmap(this._bodyIndexFrameDescription.Width, this._bodyIndexFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); // set IsAvailableChanged event notifier this._kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged; // open the sensor this._kinectSensor.Open(); // set the status text this.StatusText = this._kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText : Properties.Resources.NoSensorStatusText; // use the window object as a view model this.DataContext = this; // initialize the components (controls) of the window this.InitializeComponent(); _kinectSensor = KinectSensor.GetDefault(); if (_kinectSensor != null) { _kinectSensor.Open(); _bodies = new Body[_kinectSensor.BodyFrameSource.BodyCount]; _reader = _kinectSensor.BodyFrameSource.OpenReader(); _reader.FrameArrived += BodyReader_FrameArrived; _recorder = new KinectFileManager(); } }
private void MainWindow_Closing(object sender, CancelEventArgs e) { if (_bodyIndexFrameReader != null) { _closeStreamDisposable.Dispose(); _bodyIndexFrameReader.Dispose(); _bodyIndexFrameReader = null; } if (_kinectSensor != null) { _kinectSensor.Close(); _kinectSensor = null; } }
private void CloseKinect() { if (reader != null) { reader.Dispose(); reader = null; } if (sensor != null) { if (sensor.IsOpen) { sensor.Close(); } sensor = null; } }
private async Task InitializeKinect() { _kinectSensor = await Sensor.GetDefaultAsync(); if (_kinectSensor != null) { await _kinectSensor.OpenAsync(); //_audioReader = await _kinectSensor.OpenAudioFrameReaderAsync(); _colorReader = await _kinectSensor.OpenColorFrameReaderAsync(ReaderConfig.HalfRate | ReaderConfig.HalfResolution); _depthReader = await _kinectSensor.OpenDepthFrameReaderAsync(); _bodyIndexReader = await _kinectSensor.OpenBodyIndexFrameReaderAsync(); _bodyReader = await _kinectSensor.OpenBodyFrameReaderAsync(); if (_depthReader != null) { DepthOutput.Source = new SoftwareBitmapSource(); _depthReader.FrameArrived += DepthReader_FrameArrived; } if (_colorReader != null) { ColorOutput.Source = new SoftwareBitmapSource(); _colorReader.FrameArrived += ColorReader_FrameArrived; } if (_bodyReader != null) { _bodyReader.FrameArrived += BodyReader_FrameArrived; } if (_bodyIndexReader != null) { BodyIndexOutput.Source = new SoftwareBitmapSource(); _bodyIndexReader.FrameArrived += BodyIndexReader_FrameArrived; } if (_audioReader != null) { _audioReader.FrameArrived += AudioReader_FrameArrived; } } }
protected virtual void Awake() { KinectSensor = KinectSensor.GetDefault(); if (KinectSensor != null) { bodyFrameReader = KinectSensor.BodyFrameSource.OpenReader(); colorFrameReader = KinectSensor.ColorFrameSource.OpenReader(); depthFrameReader = KinectSensor.DepthFrameSource.OpenReader(); infraredFrameReader = KinectSensor.InfraredFrameSource.OpenReader(); bodyIndexFrameReader = KinectSensor.BodyIndexFrameSource.OpenReader(); faceFrameSource = HighDefinitionFaceFrameSource.Create(KinectSensor); faceFrameReader = faceFrameSource.OpenReader(); KinectSensor.Open(); } }
void kinect_IsAvailableChanged(object sender, IsAvailableChangedEventArgs e) { if (!e.IsAvailable) { return; } if (bodyIndexFrameDesc != null) { return; } // 表示のためのデータを作成 bodyIndexFrameDesc = kinect.DepthFrameSource.FrameDescription; // ボディインデックデータ用のバッファ bodyIndexBuffer = new byte[bodyIndexFrameDesc.LengthInPixels]; // 表示のためのビットマップに必要なものを作成 bodyIndexColorImage = new WriteableBitmap(bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height, 96, 96, PixelFormats.Bgra32, null); bodyIndexColorRect = new Int32Rect(0, 0, bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height); bodyIndexColorStride = (int)(bodyIndexFrameDesc.Width * bodyIndexColorBytesPerPixel); // ボディインデックデータをBGRA(カラー)データにするためのバッファ bodyIndexColorBuffer = new byte[bodyIndexFrameDesc.LengthInPixels * bodyIndexColorBytesPerPixel]; ImageBodyIndex.Source = bodyIndexColorImage; // ボディーインデックスリーダーを開く bodyIndexFrameReader = kinect.BodyIndexFrameSource.OpenReader(); bodyIndexFrameReader.FrameArrived += bodyIndexFrameReader_FrameArrived; // Bodyを入れる配列を作る bodies = new Body[kinect.BodyFrameSource.BodyCount]; // ボディーリーダーを開く bodyFrameReader = kinect.BodyFrameSource.OpenReader(); bodyFrameReader.FrameArrived += bodyFrameReader_FrameArrived; // Audioリーダーを開く audioBeamFrameReader = kinect.AudioSource.OpenReader(); audioBeamFrameReader.FrameArrived += audioBeamFrameReader_FrameArrived; }
public void SetPlayer(bool enable) { if (enable && this.playerreader == null && this.Runtime.IsAvailable) { playerreader = this.Runtime.BodyIndexFrameSource.OpenReader(); playerreader.FrameArrived += this.Runtime_PlayerFrameReady; } else { if (this.playerreader != null) { this.playerreader.FrameArrived -= this.Runtime_PlayerFrameReady; this.playerreader.Dispose(); this.playerreader = null; } } }
//結束的時候關閉KINECT。 public void Shutdown() { if (_Reader != null) { _Reader.Dispose(); _Reader = null; } if (_Sensor != null) { if (_Sensor.IsOpen) { _Sensor.Close(); } _Sensor = null; } }
public KinectDevice() { //kinect設定 this.kinect = KinectSensor.GetDefault(); //設定とハンドラ //colorImage #region this.colorImageFormat = ColorImageFormat.Bgra; this.colorFrameDescription = this.kinect.ColorFrameSource.CreateFrameDescription(this.colorImageFormat); this.colorFrameReader = this.kinect.ColorFrameSource.OpenReader(); this.colorFrameReader.FrameArrived += ColorFrame_Arrived; this.colors = new byte[this.colorFrameDescription.Width * this.colorFrameDescription.Height * this.colorFrameDescription.BytesPerPixel]; #endregion //骨格情報 #region this.bodyFrameReader = this.kinect.BodyFrameSource.OpenReader(); this.bodyFrameReader.FrameArrived += BodyFrame_Arrived; #endregion //震度情報 #region this.depthFrameReader = this.kinect.DepthFrameSource.OpenReader(); this.depthFrameReader.FrameArrived += DepthFrame_Arrived; this.depthFrameDescription = this.kinect.DepthFrameSource.FrameDescription; this.depthBuffer = new ushort[this.depthFrameDescription.LengthInPixels]; #endregion //BodyIndex #region this.bodyIndexFrameDes = this.kinect.BodyIndexFrameSource.FrameDescription; this.bodyIndexFrameReader = this.kinect.BodyIndexFrameSource.OpenReader(); this.bodyIndexFrameReader.FrameArrived += this.BodyIndexFrame_Arrived; this.bodyIndexBuffer = new byte[this.bodyIndexFrameDes.Width * this.bodyIndexFrameDes.Height * this.bodyIndexFrameDes.BytesPerPixel]; #endregion //kinect開始 this.package = new ShadowPackage(); this.imageWidth = this.bodyIndexFrameDes.Width; this.imageHeight = this.bodyIndexFrameDes.Height; this.imageBytePerPixel = (int)this.bodyIndexFrameDes.BytesPerPixel; this.kinectImage = new Mat(this.imageHeight, this.imageWidth, MatType.CV_8UC1); this.kinect.Open(); }
protected override void OnNavigatedTo( NavigationEventArgs e ) { base.OnNavigatedTo( e ); try { kinect = KinectSensor.GetDefault(); kinect.Open(); // ボディーインデックスリーダーを開く bodyIndexFrameReader = kinect.BodyIndexFrameSource.OpenReader(); bodyIndexFrameReader.FrameArrived += bodyIndexFrameReader_FrameArrived; // ボディーリーダーを開く bodyFrameReader = kinect.BodyFrameSource.OpenReader(); bodyFrameReader.FrameArrived += bodyFrameReader_FrameArrived; // Audioリーダーを開く audioBeamFrameReader = kinect.AudioSource.OpenReader(); audioBeamFrameReader.FrameArrived += audioBeamFrameReader_FrameArrived; // Bodyを入れる配列を作る bodies = new Body[kinect.BodyFrameSource.BodyCount]; // 表示のためのデータを作成 bodyIndexFrameDesc = kinect.DepthFrameSource.FrameDescription; // ボディインデックデータ用のバッファ bodyIndexBuffer = new byte[bodyIndexFrameDesc.LengthInPixels]; // ビットマップ bodyIndexColorBitmap = new WriteableBitmap( bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height ); ImageBodyIndex.Source = bodyIndexColorBitmap; bodyIndexColorBuffer = new byte[bodyIndexFrameDesc.LengthInPixels * bodyIndexColorBytesPerPixels]; } catch ( Exception ex ) { MessageDialog dlg = new MessageDialog(ex.Message); dlg.ShowAsync(); } }
private void Window_Loaded( object sender, RoutedEventArgs e ) { try { kinect = KinectSensor.GetDefault(); if ( kinect == null ) { throw new Exception("Kinectを開けません"); } kinect.Open(); // 表示のためのデータを作成 bodyIndexFrameDesc = kinect.DepthFrameSource.FrameDescription; // ボディインデックデータ用のバッファ bodyIndexBuffer = new byte[bodyIndexFrameDesc.LengthInPixels]; // 表示のためのビットマップに必要なものを作成 bodyIndexColorImage = new WriteableBitmap( bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height, 96, 96, PixelFormats.Bgra32, null ); bodyIndexColorRect = new Int32Rect( 0, 0, bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height ); bodyIndexColorStride = (int)(bodyIndexFrameDesc.Width * bodyIndexColorBytesPerPixel); // ボディインデックデータをBGRA(カラー)データにするためのバッファ bodyIndexColorBuffer = new byte[bodyIndexFrameDesc.LengthInPixels * bodyIndexColorBytesPerPixel]; ImageBodyIndex.Source = bodyIndexColorImage; // 色付けするために色の配列を作成する bodyIndexColors = new Color[]{ Colors.Red, Colors.Blue, Colors.Green, Colors.Yellow, Colors.Pink, Colors.Purple, }; // ボディーリーダーを開く bodyIndexFrameReader = kinect.BodyIndexFrameSource.OpenReader(); bodyIndexFrameReader.FrameArrived += bodyIndexFrameReader_FrameArrived; } catch ( Exception ex ) { MessageBox.Show( ex.Message ); Close(); } }
/// <summary> /// Initializes a new instance of the KinectBodyIndexView class /// </summary> /// <param name="kinectSensor">Active instance of the Kinect sensor</param> public KinectBodyIndexView(KinectSensor kinectSensor) { if (kinectSensor == null) { throw new ArgumentNullException("kinectSensor"); } // open the reader for the BodyIndex frames this.bodyIndexFrameReader = kinectSensor.BodyIndexFrameSource.OpenReader(); // wire handler for frame arrival this.bodyIndexFrameReader.FrameArrived += this.Reader_BodyIndexFrameArrived; this.bodyIndexFrameDescription = kinectSensor.BodyIndexFrameSource.FrameDescription; // allocate space to put the pixels being converted this.bodyIndexPixels = new uint[this.bodyIndexFrameDescription.Width * this.bodyIndexFrameDescription.Height]; // create the bitmap to display this.bodyIndexBitmap = new WriteableBitmap(this.bodyIndexFrameDescription.Width, this.bodyIndexFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); }
public LiveBackground() : base() { if (!DesignerProperties.GetIsInDesignMode(this)) { _kinectManager = KinectManager.Default; // open the reader for the color frames this._colorFrameReader = _kinectManager.KinectSensor.ColorFrameSource.OpenReader(); this._infraredFrameReader = _kinectManager.KinectSensor.InfraredFrameSource.OpenReader(); this._bodyIndexFrameReader = _kinectManager.KinectSensor.BodyIndexFrameSource.OpenReader(); FrameDescription bodyDescription = this.GetFrameDescriptionForMode(BackgroundMode.BodyIndex); this.bodyIndexPixels = new uint[bodyDescription.Width * bodyDescription.Height]; // wire handler for frame arrival this._colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived; this._infraredFrameReader.FrameArrived += this.Reader_InfraredFrameArrived; this._bodyIndexFrameReader.FrameArrived += this.Reader_BodyIndexFrameArrived; this._needColor = true; } }
protected override void OnNavigatedTo( NavigationEventArgs e ) { base.OnNavigatedTo( e ); try { // Kinectを開く kinect = KinectSensor.GetDefault(); kinect.Open(); // ボディインデックスリーダーを開く bodyIndexFrameReader = kinect.BodyIndexFrameSource.OpenReader(); bodyIndexFrameReader.FrameArrived += bodyIndexFrameReader_FrameArrived; // 表示のためのデータを作成 bodyIndexFrameDesc = kinect.BodyIndexFrameSource.FrameDescription; // ビットマップ bodyIndexColorBitmap = new WriteableBitmap( bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height ); ImageBodyIndex.Source = bodyIndexColorBitmap; // ボディインデックデータ用のバッファ bodyIndexBuffer = new byte[bodyIndexFrameDesc.LengthInPixels]; // ボディインデックデータをBGRA(カラー)データにするためのバッファ bodyIndexColorBuffer = new byte[bodyIndexFrameDesc.LengthInPixels * bodyIndexColorBytesPerPixels]; // 色付けするために色の配列を作成する bodyIndexColors = new Color[]{ Colors.Red, Colors.Blue, Colors.Green, Colors.Yellow, Colors.Pink, Colors.Purple, }; } catch ( Exception ex ) { MessageDialog dlg = new MessageDialog(ex.Message); dlg.ShowAsync(); } }
/// <summary> /// Initializes a new instance of the MainWindow class. /// </summary> public MainWindow() { //PlaySound(player); // get the kinectSensor object this.kinectSensor = KinectSensor.GetDefault(); coordinateMapper = kinectSensor.CoordinateMapper; // get body count this.bodycount = this.kinectSensor.BodyFrameSource.BodyCount; this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader(); this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived; // set length of body array this.bodies = new Body[this.bodycount]; // open the reader for the depth frames this.bodyIndexFrameReader = this.kinectSensor.BodyIndexFrameSource.OpenReader(); // wire handler for frame arrival this.bodyIndexFrameReader.FrameArrived += this.Reader_FrameArrived; // play music PlaySound(player); this.bodyIndexFrameDescription = this.kinectSensor.BodyIndexFrameSource.FrameDescription; // allocate space to put the pixels being converted this.bodyIndexPixels = new uint[this.bodyIndexFrameDescription.Width * this.bodyIndexFrameDescription.Height]; // create the bitmap to display this.bodyIndexBitmap = new WriteableBitmap(this.bodyIndexFrameDescription.Width, this.bodyIndexFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); // set IsAvailableChanged event notifier this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged; // open the sensor this.kinectSensor.Open(); // set the status text this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText : Properties.Resources.NoSensorStatusText; // use the window object as the view model in this simple example this.DataContext = this; // initialize the components (controls) of the window this.InitializeComponent(); restart(); PlaySound(player); }
/// <summary> /// Execute shutdown tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (this.bodyIndexFrameReader != null) { // remove the event handler this.bodyIndexFrameReader.FrameArrived -= this.Reader_FrameArrived; // BodyIndexFrameReder is IDisposable this.bodyIndexFrameReader.Dispose(); this.bodyIndexFrameReader = null; } if (this.kinectSensor != null) { this.kinectSensor.Close(); this.kinectSensor = null; } }
public void Start() { if (Sensor == null) { return; } Log("Start sensor..."); // Mapper coordinateMapper = Sensor.CoordinateMapper; // Open connection Sensor.Open(); // Audio Stream StartAudioStream(); if (ConfigManager.GetInstance().Find("kinect_v2.speech.speech_only", true)) { init = true; return; } // Init single frame StartColorStream(); StartDepthStream(); StartInfraredStream(); StartBodyStream(); StartBodyIndexStream(); // Motion Task StartMotionTask(); // Multi Frame Reader // reader = Sensor.OpenMultiSourceFrameReader(FrameSourceTypes.BodyIndex | FrameSourceTypes.Body); // reader.MultiSourceFrameArrived += OnMultipleFramesArrivedHandler; // Single Frame Reader dfr = Sensor.DepthFrameSource.OpenReader(); dfr.FrameArrived += (object sender, DepthFrameArrivedEventArgs e) => { HandleDepthFrame(e.FrameReference); }; xfr = Sensor.InfraredFrameSource.OpenReader(); xfr.FrameArrived += (object sender, InfraredFrameArrivedEventArgs e) => { HandleInfraredFrame(e.FrameReference); }; cfr = Sensor.ColorFrameSource.OpenReader(); cfr.FrameArrived += (object sender, ColorFrameArrivedEventArgs e) => { HandleColorFrame(e.FrameReference); }; bfr = Sensor.BodyFrameSource.OpenReader(); bfr.FrameArrived += (object sender, BodyFrameArrivedEventArgs e) => { HandleBodyFrame(e.FrameReference); }; ifr = Sensor.BodyIndexFrameSource.OpenReader(); ifr.FrameArrived += (object sender, BodyIndexFrameArrivedEventArgs e) => { HandleBodyIndexFrame(e.FrameReference); }; init = true; }
/// <summary> /// Called when the kinect sensor is available. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="IsAvailableChangedEventArgs"/> instance containing the event data.</param> private void OnSensor_IsAvailableChanged(object sender, IsAvailableChangedEventArgs e) { // This call is automatically dispatched to the main thread, so no // synchronization is needed base.RaisePropertyChanged(() => UniqueKinectId); base.RaisePropertyChanged(() => IsSensorOpen); base.RaisePropertyChanged(() => IsSensorAvailable); if(e.IsAvailable) { m_readerInfraredFrame = m_sensor.InfraredFrameSource.OpenReader(); m_readerInfraredFrame.FrameArrived += OnReaderInfraredFrame_FrameArrived; m_readerLongExposureInfraredFrame = m_sensor.LongExposureInfraredFrameSource.OpenReader(); m_readerLongExposureInfraredFrame.FrameArrived += OnReaderLongExposureInfrared_FrameArrived; m_readerColorFrame = m_sensor.ColorFrameSource.OpenReader(); m_readerColorFrame.FrameArrived += OnReaderColorFrame_FrameArrived; m_readerDepthFrame = m_sensor.DepthFrameSource.OpenReader(); m_readerDepthFrame.FrameArrived += OnReaderDepthFrame_FrameArrived; m_readerBodyFrame = m_sensor.BodyFrameSource.OpenReader(); m_readerBodyFrame.FrameArrived += OnReaderBodyFrame_FrameArrived; m_readerBodyIndexFrame = m_sensor.BodyIndexFrameSource.OpenReader(); m_readerBodyIndexFrame.FrameArrived += OnReaderBodyIndexFrame_FrameArrived; } else { CommonTools.SafeDispose(ref m_readerInfraredFrame); CommonTools.SafeDispose(ref m_readerColorFrame); CommonTools.SafeDispose(ref m_readerDepthFrame); CommonTools.SafeDispose(ref m_readerBodyFrame); CommonTools.SafeDispose(ref m_readerBodyIndexFrame); } }
public KinectPanel() { base.TitleName = "Kinect Condition"; kinect = KinectSensor.GetDefault(); //Mat this.bodyindexMat = new Mat(); this.depthMat = new Mat(); this.colorimageMat = new Mat(); //bodyindex関連 this.bodyIndexFrameDesc = kinect.DepthFrameSource.FrameDescription; this.bodyIndexBuffer = new byte[bodyIndexFrameDesc.LengthInPixels]; this.bodyIndexColorImage = new WriteableBitmap(bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height, 96, 96, PixelFormats.Bgra32, null); this.bodyIndexColorRect = new Int32Rect(0, 0, bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height); this.bodyIndexColorStride = (int)(bodyIndexFrameDesc.Width * bodyIndexColorBytesPerPixel); this.bodyIndexColorBuffer = new byte[bodyIndexFrameDesc.LengthInPixels * bodyIndexColorBytesPerPixel]; bodyIndexColors = new System.Windows.Media.Color[]{ Colors.Red, Colors.Blue, Colors.Green, Colors.Yellow, Colors.Pink, Colors.Purple, }; bodyIndexFrameReader = kinect.BodyIndexFrameSource.OpenReader(); bodyIndexFrameReader.FrameArrived += bodyIndexFrameReader_FrameArrived; //depth関連 this.depthFrameReader = this.kinect.DepthFrameSource.OpenReader(); this.depthFrameReader.FrameArrived += DepthFrame_Arrived; this.depthFrameDescription = this.kinect.DepthFrameSource.FrameDescription; this.depthBuffer = new ushort[this.depthFrameDescription.LengthInPixels]; this.depthImageWidth = this.depthFrameDescription.Width; this.depthImageHeight = this.depthFrameDescription.Height; this.depthImage = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height, 96, 96, PixelFormats.Gray16, null); this.depthRect = new Int32Rect(0, 0, depthFrameDescription.Width, depthFrameDescription.Height); this.depthStride = (int)(depthFrameDescription.Width * depthFrameDescription.BytesPerPixel); //colorimage this.colorImageFormat = ColorImageFormat.Bgra; this.colorFrameDescription = this.kinect.ColorFrameSource.CreateFrameDescription(this.colorImageFormat); this.colorFrameReader = this.kinect.ColorFrameSource.OpenReader(); this.colorFrameReader.FrameArrived += ColorFrame_Arrived; this.colors = new byte[this.colorFrameDescription.Width * this.colorFrameDescription.Height * this.colorFrameDescription.BytesPerPixel]; this.imageWidth = this.colorFrameDescription.Width; this.imageHeight = this.colorFrameDescription.Height; this.colorimage = new WriteableBitmap(this.colorFrameDescription.Width, this.colorFrameDescription.Height, 96, 96, PixelFormats.Bgr32, null); this.calibImg = new WriteableBitmap(this.colorFrameDescription.Width, this.colorFrameDescription.Height, 96, 96, PixelFormats.Bgr32, null); this.bitmapRect = new Int32Rect(0, 0, this.colorFrameDescription.Width, this.colorFrameDescription.Height); this.bitmapStride = this.colorFrameDescription.Width * (int)this.colorFrameDescription.BytesPerPixel; //bone this.bodyFrameReader = this.kinect.BodyFrameSource.OpenReader(); this.bodyFrameReader.FrameArrived += BodyFrame_Arrived; this.bodies = new Body[this.kinect.BodyFrameSource.BodyCount]; //bodycountに骨格情報の数 this.size = new OpenCvSharp.CPlusPlus.Size(512, 424); this.size1 = new OpenCvSharp.CPlusPlus.Size(imageWidth, imageHeight); //this.bodyindexMat = new Mat(size, MatType.CV_8UC1); //this.depthMat = bodyindexMat.Clone(); //this.colorimageMat = new Mat(size1, MatType.CV_8UC3); stump = 0; }
void bodyIndexFrameReader_FrameArrived( BodyIndexFrameReader sender, BodyIndexFrameArrivedEventArgs args ) { // ボディインデックスデータを取得する using ( var bodyIndexFrame = args.FrameReference.AcquireFrame() ) { if ( bodyIndexFrame == null ) { return; } bodyIndexFrame.CopyFrameDataToArray( bodyIndexBuffer ); } // ボディインデックスデータをBGRAデータに変換する for ( int i = 0; i < bodyIndexBuffer.Length; i++ ) { var index = bodyIndexBuffer[i]; var colorIndex = i * 4; if ( index != 255 ) { // BodyIndexとビーム方向のTrackingIdのインデックスが // 一致している人の色を変える(青) if ( index == AudioTrackingIndex ) { bodyIndexColorBuffer[colorIndex + 0] = 255; bodyIndexColorBuffer[colorIndex + 1] = 0; bodyIndexColorBuffer[colorIndex + 2] = 0; bodyIndexColorBuffer[colorIndex + 3] = 255; } else { bodyIndexColorBuffer[colorIndex + 0] = 0; bodyIndexColorBuffer[colorIndex + 1] = 0; bodyIndexColorBuffer[colorIndex + 2] = 255; bodyIndexColorBuffer[colorIndex + 3] = 255; } } else { bodyIndexColorBuffer[colorIndex + 0] = 0; bodyIndexColorBuffer[colorIndex + 1] = 0; bodyIndexColorBuffer[colorIndex + 2] = 0; bodyIndexColorBuffer[colorIndex + 3] = 255; } } // ビットマップにする var stream = bodyIndexColorBitmap.PixelBuffer.AsStream(); stream.Write( bodyIndexColorBuffer, 0, bodyIndexColorBuffer.Length ); bodyIndexColorBitmap.Invalidate(); }
public async Task<object> OpenBodyIndexReader(dynamic input) { this.logCallback("OpenBodyIndexReader"); if (this.bodyIndexFrameReader != null) { return false; } this.bodyIndexFrameCallback = (Func<object, Task<object>>)input.bodyIndexFrameCallback;//bodyIndexFrameCallback this.bodyIndexFrameDescription = this.kinectSensor.BodyIndexFrameSource.FrameDescription; this.logCallback("depth: " + this.bodyIndexFrameDescription.Width + "x" + this.bodyIndexFrameDescription.Height); this.bodyIndexFrameReader = this.kinectSensor.BodyIndexFrameSource.OpenReader(); // // this.bodyIndexFrameReader = this.kinectSensor.BodyIndexFrameSource.OpenReader(); this.bodyIndexFrameReader.FrameArrived += this.BodyIndexReader_FrameArrived; // // allocate space to put the pixels being converted // this.bodyIndexPixels = new byte[this.bodyIndexFrameDescription.Width * this.bodyIndexFrameDescription.Height]; this.bodyIndexPixels = new byte[this.bodyIndexFrameDescription.Width * this.bodyIndexFrameDescription.Height]; return true; }
protected override void OnNavigatingFrom( NavigatingCancelEventArgs e ) { base.OnNavigatingFrom( e ); if ( bodyIndexFrameReader != null ) { bodyIndexFrameReader.Dispose(); bodyIndexFrameReader = null; } if ( bodyFrameReader != null ) { bodyFrameReader.Dispose(); bodyFrameReader = null; } if ( audioBeamFrameReader != null ) { audioBeamFrameReader.Dispose(); audioBeamFrameReader = null; } if ( kinect != null ) { kinect.Close(); kinect = null; } }
public void SetPlayer(bool enable) { if (enable && this.playerreader == null && this.Runtime.IsAvailable) { playerreader = this.Runtime.BodyIndexFrameSource.OpenReader(); playerreader.FrameArrived += this.Runtime_PlayerFrameReady; } else { if(this.playerreader != null) { this.playerreader.FrameArrived -= this.Runtime_PlayerFrameReady; this.playerreader.Dispose(); this.playerreader = null; } } }
//終了時の処理 public void OnClose() { //カラーリーダーの終了 if (this.colorFrameReader != null) { this.colorFrameReader.Dispose(); this.colorFrameReader = null; } //ボディリーダーの終了 if (this.bodyFrameReader != null) { this.bodyFrameReader.Dispose(); this.bodyFrameReader = null; } //ディプスリーダーの終了 if (this.depthFrameReader != null) { this.depthFrameReader.Dispose(); this.depthFrameReader = null; } //BodyIndexFrame if (this.bodyIndexFrameReader != null) { this.bodyIndexFrameReader.Dispose(); this.bodyIndexFrameReader = null; } //キネクトの終了 if (this.kinect != null) { this.kinect.Close(); } }
private void Window_Loaded( object sender, RoutedEventArgs e ) { try { // Kinectを開く kinect = KinectSensor.GetDefault(); kinect.Open(); // 表示のためのデータを作成 bodyIndexFrameDesc = kinect.DepthFrameSource.FrameDescription; // ボディインデックデータ用のバッファ bodyIndexBuffer = new byte[bodyIndexFrameDesc.LengthInPixels]; // 表示のためのビットマップに必要なものを作成 bodyIndexColorImage = new WriteableBitmap( bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height, 96, 96, PixelFormats.Bgra32, null ); bodyIndexColorRect = new Int32Rect( 0, 0, bodyIndexFrameDesc.Width, bodyIndexFrameDesc.Height ); bodyIndexColorStride = (int)(bodyIndexFrameDesc.Width * bodyIndexColorBytesPerPixel); // ボディインデックデータをBGRA(カラー)データにするためのバッファ bodyIndexColorBuffer = new byte[bodyIndexFrameDesc.LengthInPixels * bodyIndexColorBytesPerPixel]; ImageBodyIndex.Source = bodyIndexColorImage; // ボディーインデックスリーダーを開く bodyIndexFrameReader = kinect.BodyIndexFrameSource.OpenReader(); bodyIndexFrameReader.FrameArrived += bodyIndexFrameReader_FrameArrived; // Bodyを入れる配列を作る bodies = new Body[kinect.BodyFrameSource.BodyCount]; // ボディーリーダーを開く bodyFrameReader = kinect.BodyFrameSource.OpenReader(); bodyFrameReader.FrameArrived += bodyFrameReader_FrameArrived; // Audioリーダーを開く audioBeamFrameReader = kinect.AudioSource.OpenReader(); audioBeamFrameReader.FrameArrived += audioBeamFrameReader_FrameArrived; } catch ( Exception ex ) { MessageBox.Show( ex.Message ); Close(); } }
/// <summary> /// Disposes the BodyIndexFrameReader /// </summary> public void Dispose() { if(this.bodyIndexFrameReader != null) { this.bodyIndexFrameReader.FrameArrived -= this.Reader_BodyIndexFrameArrived; this.bodyIndexFrameReader.Dispose(); this.bodyIndexFrameReader = null; } }
void bodyIndexFrameReader_FrameArrived( BodyIndexFrameReader sender, BodyIndexFrameArrivedEventArgs args ) { UpdateBodyIndexFrame( args ); DrawBodyIndexFrame(); }
//終了時の処理 public void OnClose() #region { if (this.bodyIndexFrameReader != null) { this.bodyIndexFrameReader.Dispose(); this.bodyIndexFrameReader = null; } if (this.kinect != null) { this.kinect.Close(); } }
private void Window_Closing( object sender, System.ComponentModel.CancelEventArgs e ) { if ( bodyIndexFrameReader != null ) { bodyIndexFrameReader.Dispose(); bodyIndexFrameReader = null; } if ( kinect != null ) { kinect.Close(); kinect = null; } }
public async Task<object> Close(object input) { if (this.depthFrameReader != null) { this.depthFrameReader.Dispose(); this.depthFrameReader = null; } if (this.bodyIndexFrameReader != null) { this.bodyIndexFrameReader.Dispose(); this.bodyIndexFrameReader = null; } if (this.colorFrameReader != null) { this.colorFrameReader.Dispose(); this.colorFrameReader = null; } if (this.infraredFrameReader != null) { this.infraredFrameReader.Dispose(); this.infraredFrameReader = null; } if (this.longExposureInfraredFrameReader != null) { this.longExposureInfraredFrameReader.Dispose(); this.longExposureInfraredFrameReader = null; } if (this.bodyFrameReader != null) { this.bodyFrameReader.Dispose(); this.bodyFrameReader = null; } if (this.kinectSensor != null) { this.kinectSensor.Close(); this.kinectSensor = null; } return true; }
public void SetPlayer(bool enable) { if (enable) { playerreader = this.Runtime.BodyIndexFrameSource.OpenReader(); playerreader.FrameArrived += this.Runtime_PlayerFrameReady; } }