/// <summary>
        /// Kinectにつないでる時だけ使えるコンストラクタ
        /// </summary>
        /// <param name="originalCoordinateMapper"></param>
        /// <param name="depthWidth"></param>
        /// <param name="depthHeight"></param>
        public LocalCoordinateMapper(CoordinateMapper originalCoordinateMapper, int depthWidth, int depthHeight)
        {
            this.depthWidth  = depthWidth;
            this.depthHeight = depthHeight;
            this.depthFrameToCameraSpaceTable = originalCoordinateMapper.GetDepthFrameToCameraSpaceTable();

            int length = depthWidth * depthHeight;

            ushort[]          depthBuffer      = new ushort[length];
            ColorSpacePoint[] colorSpacePoints = new ColorSpacePoint[length];
            this.depthFrameToColorSpacfeTable = new PointF[length];

            int depth = 1500; // なんでもいい

            for (int i = 0; i < length; i++)
            {
                depthBuffer[i] = (ushort)depth;
            }
            originalCoordinateMapper.MapDepthFrameToColorSpace(depthBuffer, colorSpacePoints);
            for (int i = 0; i < length; i++)
            {
                PointF tempP = new PointF();
                tempP.X = (float)(colorSpacePoints[i].X - D / depth);
                tempP.Y = colorSpacePoints[i].Y;
                this.depthFrameToColorSpacfeTable[i] = tempP;
            }
            Debug.WriteLine(1);
        }
예제 #2
0
        protected void CalcDistanceMap()
        {
            if (distanceMap != null)
            {
                return;
            }

            Microsoft.Kinect.PointF[] mapPoints = coordinateMapper.GetDepthFrameToCameraSpaceTable();
            distanceMap = new float[depthHeight, depthWidth];
            for (int y = 0; y < depthHeight; y++)
            {
                for (int x = 0; x < depthWidth; x++)
                {
                    int    idx = y * depthWidth + x;
                    double a   = mapPoints[idx].X;
                    double b   = mapPoints[idx].Y;
                    a *= a;
                    b *= b;
                    distanceMap[y, x] = (float)Math.Sqrt(1 + a + b);
                }
            }
        }
        /// <summary>
        /// Kinectにつないでる時だけ使えるコンストラクタ
        /// </summary>
        /// <param name="originalCoordinateMapper"></param>
        /// <param name="depthWidth"></param>
        /// <param name="depthHeight"></param>
        public LocalCoordinateMapper(CoordinateMapper originalCoordinateMapper, int depthWidth, int depthHeight)
        {
            this.depthWidth = depthWidth;
            this.depthHeight = depthHeight;
            this.depthFrameToCameraSpaceTable = originalCoordinateMapper.GetDepthFrameToCameraSpaceTable();

            int length = depthWidth * depthHeight;
            ushort[] depthBuffer = new ushort[length];
            ColorSpacePoint[] colorSpacePoints = new ColorSpacePoint[length];            
            this.depthFrameToColorSpacfeTable = new PointF[length];

            int depth = 1500; // なんでもいい
            for (int i = 0; i < length; i++)
            {
                depthBuffer[i] = (ushort)depth;
            }
            originalCoordinateMapper.MapDepthFrameToColorSpace(depthBuffer, colorSpacePoints);
            for (int i = 0; i < length; i++)
            {
                PointF tempP = new PointF();
                tempP.X = (float)(colorSpacePoints[i].X - D / depth);
                tempP.Y = colorSpacePoints[i].Y;
                this.depthFrameToColorSpacfeTable[i] = tempP;
            }
            Debug.WriteLine(1);
        }
예제 #4
0
 /// <summary>
 /// Convenience factory to create table from Kinect coordinate mapper
 /// </summary>
 /// <param name="device">Direct3D Device</param>
 /// <param name="coordinateMapper">Kinect Coordinate mapper</param>
 /// <returns>Ray table texture</returns>
 public static unsafe RayTableTexture FromCoordinateMapper(Device device, CoordinateMapper coordinateMapper)
 {
     var points = coordinateMapper.GetDepthFrameToCameraSpaceTable();
     return FromPoints(device, points);
 }
예제 #5
0
        /// <summary>
        /// Convenience factory to create table from Kinect coordinate mapper
        /// </summary>
        /// <param name="device">Direct3D Device</param>
        /// <param name="coordinateMapper">Kinect Coordinate mapper</param>
        /// <returns>Ray table texture</returns>
        public unsafe static RayTableTexture FromCoordinateMapper(Device device, CoordinateMapper coordinateMapper)
        {
            var points = coordinateMapper.GetDepthFrameToCameraSpaceTable();

            return(FromPoints(device, points));
        }