Ejemplo n.º 1
0
        private static CalibrationRecord Calibrate(KinectSensor sensor)
        {
            int width  = sensor.DepthFrameSource.FrameDescription.Width;
            int height = sensor.DepthFrameSource.FrameDescription.Height;

            ushort minDepth = sensor.DepthFrameSource.DepthMinReliableDistance;
            ushort maxDepth = sensor.DepthFrameSource.DepthMaxReliableDistance;

            var result         = new CalibrationRecord();
            int nextDepth      = minDepth;
            int depthIncrement = 777;

            if (depthIncrement >= maxDepth - minDepth || (maxDepth - minDepth) % depthIncrement == 0)
            {
                throw new ArgumentException("Pick an increment which is less than, and not divisible by, maxDepth - minDepth");
            }

            // 0 to 512
            for (int depthX = 0; depthX < width; depthX += 3)
            {
                // 0 to 424
                for (int depthY = 0; depthY < height; depthY += 3)
                {
                    // 500 to 4500
                    DepthSpacePoint depthPoint = new DepthSpacePoint
                    {
                        X = depthX,
                        Y = depthY
                    };

                    ColorSpacePoint  colorPoint = sensor.CoordinateMapper.MapDepthPointToColorSpace(depthPoint, (ushort)nextDepth);
                    CameraSpacePoint bodyPoint  = sensor.CoordinateMapper.MapDepthPointToCameraSpace(depthPoint, (ushort)nextDepth);

                    CalibrationPoint cpoint = new CalibrationPoint()
                    {
                        DepthPoint  = depthPoint,
                        Depth       = (ushort)nextDepth,
                        CameraPoint = bodyPoint,
                        ColorPoint  = colorPoint
                    };

                    result.AddCalibrationPoint(cpoint);

                    nextDepth += depthIncrement;
                    if (nextDepth >= maxDepth)
                    {
                        nextDepth -= maxDepth - minDepth;
                    }
                }
            }

            return(result);
        }
 public void AddCalibrationPoint(CalibrationPoint cpoint)
 {
     _depthToColorAndCamera.Add(cpoint);
 }
Ejemplo n.º 3
0
 public void AddCalibrationPoint(CalibrationPoint cpoint)
 {
     _depthToColorAndCamera.Add(cpoint);
 }
Ejemplo n.º 4
0
        private static CalibrationRecord Calibrate(KinectSensor sensor)
        {
            int width = sensor.DepthFrameSource.FrameDescription.Width;
            int height = sensor.DepthFrameSource.FrameDescription.Height;

            ushort minDepth = sensor.DepthFrameSource.DepthMinReliableDistance;
            ushort maxDepth = sensor.DepthFrameSource.DepthMaxReliableDistance;

            var result = new CalibrationRecord();
            int nextDepth = minDepth;
            int depthIncrement = 777;
            if (depthIncrement >= maxDepth - minDepth || (maxDepth - minDepth) % depthIncrement == 0)
                throw new ArgumentException("Pick an increment which is less than, and not divisible by, maxDepth - minDepth");

            // 0 to 512
            for (int depthX = 0; depthX < width; depthX += 3)
            {
                // 0 to 424
                for (int depthY = 0; depthY < height; depthY += 3)
                {
                    // 500 to 4500
                    DepthSpacePoint depthPoint = new DepthSpacePoint
                    {
                        X = depthX,
                        Y = depthY
                    };

                    ColorSpacePoint colorPoint = sensor.CoordinateMapper.MapDepthPointToColorSpace(depthPoint, (ushort)nextDepth);
                    CameraSpacePoint bodyPoint = sensor.CoordinateMapper.MapDepthPointToCameraSpace(depthPoint, (ushort)nextDepth);

                    CalibrationPoint cpoint = new CalibrationPoint()
                    {
                        DepthPoint = depthPoint,
                        Depth = (ushort)nextDepth,
                        CameraPoint = bodyPoint,
                        ColorPoint = colorPoint
                    };

                    result.AddCalibrationPoint(cpoint);

                    nextDepth += depthIncrement;
                    if (nextDepth >= maxDepth) nextDepth -= maxDepth - minDepth;
                }
            }

            return result;
        }