Beispiel #1
0
        public static Vector2 JointPostoDepthPos(Vector3 JointPos, DepthInfo depthInfo)
        {
            if (depthInfo.EnableCoordinate == false)
            {
                return(new Vector2(0, 0));
            }

            double depthX = (JointPos.x / JointPos.z - depthInfo.JointDepthXFix) * depthInfo.JointDepthXMult;
            double depthY = (JointPos.y / JointPos.z - depthInfo.JointDepthYFix) * depthInfo.JointDepthYMult;

            if (depthX > 1)
            {
                depthX = 1;
            }
            else if (depthX < -1)
            {
                depthX = -1;
            }

            if (depthY > 1)
            {
                depthY = 1;
            }
            else if (depthY < -1)
            {
                depthY = -1;
            }

            depthX += 1;
            depthY += 1;
            return(new Vector2((int)(depthX * depthInfo.Width / 2), (int)(depthInfo.Height - (depthY * depthInfo.Width / 2))));
        }
        internal DepthData(short[] data, DepthInfo info)
        {
            this.FrameData = new ushort[data.Length];
            int index = 0;

            foreach (short value in data)
            {
                this.FrameData[index] = (ushort)value;
                index++;
            }
            this.Description = info;
        }
        internal NuiSensor(NuiApplication nuiApp, string name, string company, int id, SensorState state,
                           int colorFrameWidth, int colorFrameHeight, int colorbpp, int depthFrameWidth, int depthFrameHeight, int depthbpp, int maxTrackingbody)
        {
            this.ColorFrameAuthority = false;
            this.DepthFrameAuthority = false;
            this.BodyFrameAuthority  = false;

            this._app = nuiApp;

            this.Name   = name;
            this.Vendor = company;
            this.Id     = id;
            this.State  = state;


            bool EnableCoordinate = false;

            double JointDepthXMult   = 0;
            double JointDepthXFix    = 0;
            double JointDepthYMult   = 0;
            double JointDepthYFix    = 0;
            double DepthToJointZMult = 0;

            //나중엔 uID 로 처리하던가 해야함.
            switch (name)
            {
            case "Kinect":
                EnableCoordinate = true;

                JointDepthXMult   = 1.85;
                JointDepthXFix    = 0;
                JointDepthYMult   = 1.9;
                JointDepthYFix    = 0.13;
                DepthToJointZMult = 0.00123;
                break;

            case "Kinect2":
                EnableCoordinate = true;

                JointDepthXMult   = 1.5;
                JointDepthXFix    = 0;
                JointDepthYMult   = 1.45;
                JointDepthYFix    = 0.085;
                DepthToJointZMult = 0.00107;
                break;
            }

            ColorInfo = new ColorInfo(colorFrameWidth, colorFrameHeight, colorbpp);

            if (EnableCoordinate)
            {
                DepthInfo = new DepthInfo(depthFrameWidth, depthFrameHeight, short.MinValue, short.MaxValue, depthbpp,
                                          EnableCoordinate,
                                          JointDepthXMult, JointDepthXFix, JointDepthYMult, JointDepthYFix,
                                          DepthToJointZMult);
            }
            else
            {
                DepthInfo = new DepthInfo(depthFrameWidth, depthFrameHeight, short.MinValue, short.MaxValue, depthbpp);
            }

            BodyInfo = new BodyInfo(maxTrackingbody);
        }