Exemplo n.º 1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="jointsOption">Joint 単位の設定</param>
        public OriginPositionAutoSetter(JointsOption jointsOption)
        {
            _jointsOption = jointsOption;

            _addedEventListener = false;
            _timer = null;

            _remainingTime = 0;
            _alreadySet = false;

            _status = OriginPositionAutoSetterStatus.NOT_STARTING;
        }
Exemplo n.º 2
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="jointsOption">Joint 単位の設定</param>
        public OriginPositionAutoSetter(JointsOption jointsOption)
        {
            _jointsOption = jointsOption;

            _addedEventListener = false;
            _timer = null;

            _remainingTime = 0;
            _alreadySet    = false;

            _status = OriginPositionAutoSetterStatus.NOT_STARTING;
        }
Exemplo n.º 3
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public MainWindowViewModel()
        {
            _kinectManager = new KinectManager();
            _cameraOptions = new CameraOptions();
            _jointsOption = new JointsOption();
            _blenderOptions = new BlenderOptions();
            _originPositionAutoSetter = new OriginPositionAutoSetter(_jointsOption);
            _kinectDataManager = new KinectDataManager(_cameraOptions, _blenderOptions, _jointsOption);
            _parameterFileManager = new ParameterFileManager(this);

            _statusBarMessage = "";
        }
Exemplo n.º 4
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="cameraOptions">カメラ設定</param>
        /// <param name="blenderOptions">Blender 側へ反映する際のオプション</param>
        /// <param name="jointsOption">Joint 単位の設定</param>
        public KinectDataManager(CameraOptions cameraOptions, BlenderOptions blenderOptions, JointsOption jointsOption)
        {
            _addedEventListener = false;

            _colorSource        = null;
            _depthSource        = null;
            _jointDrawPositions = null;

            _cameraOptions      = cameraOptions;
            _blenderOptions     = blenderOptions;
            _jointsOption       = jointsOption;
            _skeletonDataSender = new SkeletonDataSender(IPAddress.Loopback, 38040);
        }
Exemplo n.º 5
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="cameraOptions">カメラ設定</param>
        /// <param name="blenderOptions">Blender 側へ反映する際のオプション</param>
        /// <param name="jointsOption">Joint 単位の設定</param>
        public KinectDataManager(CameraOptions cameraOptions, BlenderOptions blenderOptions, JointsOption jointsOption)
        {
            _addedEventListener = false;

            _colorSource = null;
            _depthSource = null;
            _jointDrawPositions = null;

            _cameraOptions = cameraOptions;
            _blenderOptions = blenderOptions;
            _jointsOption = jointsOption;
            _skeletonDataSender = new SkeletonDataSender(IPAddress.Loopback, 38040);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 送信
        /// </summary>
        /// <param name="skeleton">スケルトンデータ</param>
        /// <param name="userNo">ユーザー No(Kinect で認識された人物を識別する番号)</param>
        /// <param name="blenderOptions">Blender 側へ反映する際のオプション</param>
        /// <param name="jointsOption">Joint 単位の設定</param>
        public void Send(Skeleton skeleton, uint userNo, BlenderOptions blenderOptions, JointsOption jointsOption)
        {
            double sizeProportionX = blenderOptions.SizeProportionX;
            double sizeProportionY = blenderOptions.SizeProportionY;
            double sizeProportionZ = blenderOptions.SizeProportionZ;
            double centerX         = blenderOptions.CenterX;
            double centerY         = blenderOptions.CenterY;
            double centerZ         = blenderOptions.CenterZ;
            bool   mirror          = blenderOptions.Mirror;

            OscMessage message = new OscMessage(_sourceEndPoint, "/skeleton");

            message.Append(userNo.ToString());

            foreach (Joint joint in skeleton.Joints)
            {
                if (joint.TrackingState == JointTrackingState.NotTracked)
                {
                    continue;
                }

                JointType jointType = joint.JointType;

                double originX = jointsOption.GetOriginX(jointType);
                double originY = jointsOption.GetOriginY(jointType);
                double originZ = jointsOption.GetOriginZ(jointType);

                if (mirror)
                {
                    if (jointType == JointType.ShoulderRight)
                    {
                        jointType = JointType.ShoulderLeft;
                    }
                    else if (jointType == JointType.ShoulderLeft)
                    {
                        jointType = JointType.ShoulderRight;
                    }
                    else if (jointType == JointType.ElbowRight)
                    {
                        jointType = JointType.ElbowLeft;
                    }
                    else if (jointType == JointType.ElbowLeft)
                    {
                        jointType = JointType.ElbowRight;
                    }
                    else if (jointType == JointType.WristRight)
                    {
                        jointType = JointType.WristLeft;
                    }
                    else if (jointType == JointType.WristLeft)
                    {
                        jointType = JointType.WristRight;
                    }
                    else if (jointType == JointType.HandRight)
                    {
                        jointType = JointType.HandLeft;
                    }
                    else if (jointType == JointType.HandLeft)
                    {
                        jointType = JointType.HandRight;
                    }
                    else if (jointType == JointType.HipRight)
                    {
                        jointType = JointType.HipLeft;
                    }
                    else if (jointType == JointType.HipLeft)
                    {
                        jointType = JointType.HipRight;
                    }
                    else if (jointType == JointType.KneeRight)
                    {
                        jointType = JointType.KneeLeft;
                    }
                    else if (jointType == JointType.KneeLeft)
                    {
                        jointType = JointType.KneeRight;
                    }
                    else if (jointType == JointType.AnkleRight)
                    {
                        jointType = JointType.AnkleLeft;
                    }
                    else if (jointType == JointType.AnkleLeft)
                    {
                        jointType = JointType.AnkleRight;
                    }
                    else if (jointType == JointType.FootRight)
                    {
                        jointType = JointType.FootLeft;
                    }
                    else if (jointType == JointType.FootLeft)
                    {
                        jointType = JointType.FootRight;
                    }
                }

                if (jointsOption.GetEnable(jointType))
                {
                    message.Append(jointsOption.GetName(jointType));

                    // Kinect
                    // x 軸: 横(右が正)
                    // y 軸: 高さ(上が正)
                    // z 軸: 奥行き(人間から見てカメラがある方向が正)
                    //
                    //  ↓
                    //
                    // Blender
                    // x 軸: 横
                    // y 軸: 奥行き
                    // z 軸: 高さ

                    double locationX = 0;
                    double locationY = 0;
                    double locationZ = 0;
                    if (!mirror)
                    {
                        locationX = (joint.Position.X - centerX - originX) * sizeProportionX;
                        locationY = (joint.Position.Z - centerZ - originZ) * sizeProportionZ;
                        locationZ = (joint.Position.Y - centerY - originY) * sizeProportionY;
                    }
                    else
                    {
                        locationX = (joint.Position.X - centerX - originX) * sizeProportionX * -1;
                        locationY = (joint.Position.Z - centerZ - originZ) * sizeProportionZ * -1;
                        locationZ = (joint.Position.Y - centerY - originY) * sizeProportionY;
                    }

                    message.Append(locationX.ToString());
                    message.Append(locationY.ToString());
                    message.Append(locationZ.ToString());
                }
            }
            message.Send(_destinationEndPoint);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 送信
        /// </summary>
        /// <param name="skeleton">スケルトンデータ</param>
        /// <param name="userNo">ユーザー No(Kinect で認識された人物を識別する番号)</param>
        /// <param name="blenderOptions">Blender 側へ反映する際のオプション</param>
        /// <param name="jointsOption">Joint 単位の設定</param>
        public void Send(Skeleton skeleton, uint userNo, BlenderOptions blenderOptions, JointsOption jointsOption)
        {
            double sizeProportionX = blenderOptions.SizeProportionX;
            double sizeProportionY = blenderOptions.SizeProportionY;
            double sizeProportionZ = blenderOptions.SizeProportionZ;
            double centerX = blenderOptions.CenterX;
            double centerY = blenderOptions.CenterY;
            double centerZ = blenderOptions.CenterZ;
            bool mirror = blenderOptions.Mirror;

            OscMessage message = new OscMessage(_sourceEndPoint, "/skeleton");
            message.Append(userNo.ToString());

            foreach (Joint joint in skeleton.Joints)
            {
                if (joint.TrackingState == JointTrackingState.NotTracked)
                {
                    continue;
                }

                JointType jointType = joint.JointType;

                double originX = jointsOption.GetOriginX(jointType);
                double originY = jointsOption.GetOriginY(jointType);
                double originZ = jointsOption.GetOriginZ(jointType);

                if (mirror)
                {
                    if (jointType == JointType.ShoulderRight) { jointType = JointType.ShoulderLeft; }
                    else if (jointType == JointType.ShoulderLeft) { jointType = JointType.ShoulderRight; }
                    else if (jointType == JointType.ElbowRight) { jointType = JointType.ElbowLeft; }
                    else if (jointType == JointType.ElbowLeft) { jointType = JointType.ElbowRight; }
                    else if (jointType == JointType.WristRight) { jointType = JointType.WristLeft; }
                    else if (jointType == JointType.WristLeft) { jointType = JointType.WristRight; }
                    else if (jointType == JointType.HandRight) { jointType = JointType.HandLeft; }
                    else if (jointType == JointType.HandLeft) { jointType = JointType.HandRight; }
                    else if (jointType == JointType.HipRight) { jointType = JointType.HipLeft; }
                    else if (jointType == JointType.HipLeft) { jointType = JointType.HipRight; }
                    else if (jointType == JointType.KneeRight) { jointType = JointType.KneeLeft; }
                    else if (jointType == JointType.KneeLeft) { jointType = JointType.KneeRight; }
                    else if (jointType == JointType.AnkleRight) { jointType = JointType.AnkleLeft; }
                    else if (jointType == JointType.AnkleLeft) { jointType = JointType.AnkleRight; }
                    else if (jointType == JointType.FootRight) { jointType = JointType.FootLeft; }
                    else if (jointType == JointType.FootLeft) { jointType = JointType.FootRight; }
                }

                if (jointsOption.GetEnable(jointType))
                {
                    message.Append(jointsOption.GetName(jointType));

                    // Kinect
                    // x 軸: 横(右が正)
                    // y 軸: 高さ(上が正)
                    // z 軸: 奥行き(人間から見てカメラがある方向が正)
                    //
                    //  ↓
                    //
                    // Blender
                    // x 軸: 横
                    // y 軸: 奥行き
                    // z 軸: 高さ

                    double locationX = 0;
                    double locationY = 0;
                    double locationZ = 0;
                    if (!mirror)
                    {
                        locationX = (joint.Position.X - centerX - originX) * sizeProportionX;
                        locationY = (joint.Position.Z - centerZ - originZ) * sizeProportionZ;
                        locationZ = (joint.Position.Y - centerY - originY) * sizeProportionY;
                    }
                    else
                    {
                        locationX = (joint.Position.X - centerX - originX) * sizeProportionX * -1;
                        locationY = (joint.Position.Z - centerZ - originZ) * sizeProportionZ * -1;
                        locationZ = (joint.Position.Y - centerY - originY) * sizeProportionY;
                    }

                    message.Append(locationX.ToString());
                    message.Append(locationY.ToString());
                    message.Append(locationZ.ToString());
                }
            }
            message.Send(_destinationEndPoint);
        }