예제 #1
0
        /// <summary>
        /// スケルトンデータ更新イベントハンドラ
        /// </summary>
        /// <param name="sender">イベント送信元</param>
        /// <param name="e">イベント引数</param>
        private void kinectManager_SkeletonUpdate(object sender, SkeletonUpdateEventArgs e)
        {
            // 実設定可能でないなら終了
            if (_status != OriginPositionAutoSetterStatus.SETTABLE)
            {
                return;
            }

            KinectSensor kinect = e.Kinect;
            SkeletonFrame skeletonFrame = e.SkeletonFrame;

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

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

            bool success = false;

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

                // 実設定
                _SetOriginPosition(skeleton);
                success = true;
            }

            if (success)
            {
                _alreadySet = true;
                _lastSetTime = DateTime.Now;
            }
            _status = OriginPositionAutoSetterStatus.NOT_STARTING;

            EventHandler<EventArgs> eventHandler = Update;
            if (eventHandler != null)
            {
                eventHandler(this, new EventArgs());
            }
        }
예제 #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);
        }
예제 #3
0
        /// <summary>
        /// スケルトンフレーム更新イベント
        /// </summary>
        /// <param name="sender">Kinect センサー</param>
        /// <param name="e">イベント</param>
        private void _kinect_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            KinectSensor kinect = sender as KinectSensor;
            if (kinect == null)
            {
                return;
            }

            // スケルトンのフレームを取得する
            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame == null)
                {
                    return;
                }

                EventHandler<SkeletonUpdateEventArgs> eventHandler = SkeletonUpdate;
                if (eventHandler != null)
                {
                    SkeletonUpdateEventArgs args = new SkeletonUpdateEventArgs();
                    args.Kinect        = kinect;
                    args.SkeletonFrame = skeletonFrame;
                    eventHandler(this, args);
                }
            }
        }
예제 #4
0
 /// <summary>
 /// スケルトンデータ更新イベントハンドラ
 /// </summary>
 /// <param name="sender">イベント送信元</param>
 /// <param name="e">イベント引数</param>
 private void _kinectManager_SkeletonUpdate(object sender, SkeletonUpdateEventArgs e)
 {
     RaisePropertyChanged("JointDrawPositions");
 }