Exemplo n.º 1
0
        /// <summary>
        /// スケルトンデータ更新イベントハンドラ
        /// </summary>
        /// <param name="sender">イベント送信元</param>
        /// <param name="e">イベント引数</param>
        void kinectManager_SkeletonUpdate(object sender, SkeletonUpdateEventArgs e)
        {
            KinectSensor  kinect        = e.Kinect;
            SkeletonFrame skeletonFrame = e.SkeletonFrame;

            Skeleton[] skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
            skeletonFrame.CopySkeletonDataTo(skeletons);

            IList <JointDrawPosition> jointDrawPositionList = new List <JointDrawPosition>();

            uint userNo = 1;

            foreach (Skeleton skeleton in skeletons)
            {
                if (skeleton.TrackingState != SkeletonTrackingState.Tracked)
                {
                    continue;
                }

                if (_cameraOptions.SkeletonDrawEnable)
                {
                    // 描画
                    foreach (Joint joint in skeleton.Joints)
                    {
                        if (joint.TrackingState == JointTrackingState.NotTracked)
                        {
                            continue;
                        }

                        // スケルトンの座標を RGB カメラの座標に変換する
                        ColorImagePoint point = kinect.MapSkeletonPointToColor(joint.Position, kinect.ColorStream.Format);
                        // 座標を画面のサイズに変換する
                        // TODO: ダメなハードコーディング
                        point.X = (int)((point.X * 320) / kinect.ColorStream.FrameWidth);
                        point.Y = (int)((point.Y * 240) / kinect.ColorStream.FrameHeight);

                        JointDrawPosition jointDrawPosition = new JointDrawPosition();
                        jointDrawPosition.X = point.X;
                        jointDrawPosition.Y = point.Y;
                        jointDrawPositionList.Add(jointDrawPosition);
                    }
                }

                // 送信
                _skeletonDataSender.Send(skeleton, userNo, _blenderOptions, _jointsOption);

                userNo++;
            }

            _jointDrawPositions = new ObservableCollection <JointDrawPosition>(jointDrawPositionList);
        }
Exemplo n.º 2
0
        /// <summary>
        /// スケルトンデータ更新イベントハンドラ
        /// </summary>
        /// <param name="sender">イベント送信元</param>
        /// <param name="e">イベント引数</param>
        void kinectManager_SkeletonUpdate(object sender, SkeletonUpdateEventArgs e)
        {
            KinectSensor kinect = e.Kinect;
            SkeletonFrame skeletonFrame = e.SkeletonFrame;

            Skeleton[] skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
            skeletonFrame.CopySkeletonDataTo(skeletons);

            IList<JointDrawPosition> jointDrawPositionList = new List<JointDrawPosition>();

            uint userNo = 1;
            foreach (Skeleton skeleton in skeletons)
            {
                if (skeleton.TrackingState != SkeletonTrackingState.Tracked)
                {
                    continue;
                }

                if (_cameraOptions.SkeletonDrawEnable)
                {
                    // 描画
                    foreach (Joint joint in skeleton.Joints)
                    {
                        if (joint.TrackingState == JointTrackingState.NotTracked)
                        {
                            continue;
                        }

                        // スケルトンの座標を RGB カメラの座標に変換する
                        ColorImagePoint point = kinect.MapSkeletonPointToColor(joint.Position, kinect.ColorStream.Format);
                        // 座標を画面のサイズに変換する
                        // TODO: ダメなハードコーディング
                        point.X = (int)((point.X * 320) / kinect.ColorStream.FrameWidth);
                        point.Y = (int)((point.Y * 240) / kinect.ColorStream.FrameHeight);

                        JointDrawPosition jointDrawPosition = new JointDrawPosition();
                        jointDrawPosition.X = point.X;
                        jointDrawPosition.Y = point.Y;
                        jointDrawPositionList.Add(jointDrawPosition);
                    }
                }

                // 送信
                _skeletonDataSender.Send(skeleton, userNo, _blenderOptions, _jointsOption);

                userNo++;
            }

            _jointDrawPositions = new ObservableCollection<JointDrawPosition>(jointDrawPositionList);
        }