Ejemplo n.º 1
0
        public static void SetFingerRotations(particle f, int depth, Point3D h_rotation, int radius)
        {
            Point3D meters = ObjectPoint.PixelsToMeters(new Point3D()
            {
                X = f.x - radius, Y = f.y - radius, Z = depth
            });

            f.angle_from_hand_degrees.X  = -Math.Atan2(meters.Y, meters.X) * 180 / 3.14159;
            f.angle_from_hand_degrees.X += (720 - h_rotation.X);
            f.angle_from_hand_degrees.X  = f.angle_from_hand_degrees.X % 360;

            //f.angle_from_hand_degrees.Y = -Math.Atan2(meters.Y, -meters.Z) * 180 / 3.14159;
            //f.angle_from_hand_degrees.Y += 720;
            //f.angle_from_hand_degrees.Y = f.angle_from_hand_degrees.Y % 360;

            //f.angle_from_hand_degrees.Z = -Math.Atan2(meters.X, meters.Z) * 180 / 3.14159;
            //f.angle_from_hand_degrees.Z += (720 - h_rotation.Z);
            //f.angle_from_hand_degrees.Z = f.angle_from_hand_degrees.Z % 360;
        }
Ejemplo n.º 2
0
        public static HandFrame zoomOnHand(short[] depthFrame, DepthFrameParams DFSettings, ObjectPoint handPos)
        {
            HandFrame HF = new HandFrame(DFSettings.Width, DFSettings.Height, handPos.X, handPos.Y, getRadiusFromHand(handPos.Depth));

            // converts the 2d X and Y from output matrix to the 1d array Depth Image: DeptImgWidth*Y + X
            // should have xShift and yShift incorporated??????
            int startPoint = DFSettings.Width * Math.Max(1, (handPos.Y - HF.radius)) + Math.Max(1, handPos.X - HF.radius);
            int endPoint   = Math.Min(depthFrame.Length - 1, DFSettings.Width * (handPos.Y + HF.radius) + handPos.X + HF.radius);

            int x = 0;
            int y = 0;

            for (int i = startPoint; i <= endPoint; i++)
            {
                // wraps the linear array to create the 2D Matrix
                if (x >= HF.width)
                {
                    i += DFSettings.Width - HF.width - 1;
                    x  = 0;
                    y++;
                    continue;
                }

                depthFrame[i] = (short)(depthFrame[i] >> DFSettings.Bitmask);

                // Kinect reports unknown values as -1 or 0
                if (depthFrame[i] <= 0 || depthFrame[i] >= handPos.Depth + HF.radius)
                {
                    depthFrame[i] = (short)(handPos.Depth + HF.radius);
                }

                HF.abs[y, x] = (short)(depthFrame[i]);
                HF.dx[y, x]  = threshold(depthFrame[i] - depthFrame[i - 1], FingerDetection.DetectionParameters.dxThreshold);
                HF.dy[y, x]  = threshold(depthFrame[i] - depthFrame[i - DFSettings.Width], FingerDetection.DetectionParameters.dyThreshold);

                x++;
            }

            return(HF);
        }