예제 #1
0
        /// <summary>
        /// 顔を認識し回転のパラメータを取得
        /// </summary>
        /// <param name="colorFrame"></param>
        /// <param name="depthFrame"></param>
        /// <param name="skeletonFrame"></param>
        private void FaceDataAcquisition(ColorImageFrame colorFrame, DepthImageFrame depthFrame, Skeleton skeleton)
        {
            FaceTrackFrame faceFrame = faceTracker.Track(colorFrame.Format, colorFrame.ToPixelData(),
                                                         depthFrame.Format, depthFrame.ToPixelData(), skeleton);

            if (faceFrame.TrackSuccessful)
            {
                rotHeadXYZ.x = faceFrame.Rotation.X;
                rotHeadXYZ.y = faceFrame.Rotation.Y;
                rotHeadXYZ.z = faceFrame.Rotation.Z;

                // トラッキング状態を表示
                statusTextBlock.Text       = "Status: Tracked";
                statusTextBlock.Background = new SolidColorBrush(Color.FromRgb(0xBB, 0xDE, 0xFB));

                // 送信
                if (sendTextBlock.Text != "push 'Update IP and Port'")
                {
                    SendOSCMessage(rotHeadXYZ, posHeadXYZ, posHandRightXYZ, posHandLeftXYZ);
                }
            }
            else
            {
                // トラッキング状態を表示
                statusTextBlock.Text       = "Status: NOT Tracked";
                statusTextBlock.Background = (SolidColorBrush)this.FindResource("MyBrush");
            }
        }
예제 #2
0
 /// <summary>
 /// 画像をBitmapSourceに変換する
 /// </summary>
 /// <param name="colorFrame"></param>
 /// <returns></returns>
 public static BitmapSource ToBitmapSource(this ColorImageFrame colorFrame)
 {
     return(BitmapSource.Create(colorFrame.Width, colorFrame.Height,
                                96, 96, PixelFormats.Bgr32, null, colorFrame.ToPixelData(),
                                colorFrame.Width * colorFrame.BytesPerPixel));
 }