当前位置: 首页>>代码示例>>C#>>正文


C# CoordinateMapper.MapDepthPointToColorSpace方法代码示例

本文整理汇总了C#中CoordinateMapper.MapDepthPointToColorSpace方法的典型用法代码示例。如果您正苦于以下问题:C# CoordinateMapper.MapDepthPointToColorSpace方法的具体用法?C# CoordinateMapper.MapDepthPointToColorSpace怎么用?C# CoordinateMapper.MapDepthPointToColorSpace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CoordinateMapper的用法示例。


在下文中一共展示了CoordinateMapper.MapDepthPointToColorSpace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Finger

        internal Finger(DepthPointEx point, CoordinateMapper coordinateMapper)
        {
            ushort depth = (ushort)point.Z;

            DepthPoint = new DepthSpacePoint
            {
                X = point.X,
                Y = point.Y
            };

            ColorPoint = coordinateMapper.MapDepthPointToColorSpace(DepthPoint, (ushort)point.Z);

            CameraPoint = coordinateMapper.MapDepthPointToCameraSpace(DepthPoint, (ushort)point.Z);
        }
开发者ID:guozanhua,项目名称:Kinect-Finger-Tracking,代码行数:14,代码来源:Finger.cs

示例2: calculateProject


//.........这里部分代码省略.........

                for (int i = 0; i < noOfPoints; i++)
                {
                    Console.WriteLine(projectDepthPixelToCameraSpacePoint(new Point3(depthBasics[i].X, depthBasics[i].Y, distance)).ToSString());
                }
            }

            // Let's X_ir(P) being P.X in depth image, X_rgb(P) being P.X in RGB

            // The calculation here is just an estimation, doesn't take into account camera calibration
            // Solve the problem on the z-plane of 1 meter
            // Center of depth field has the same X, Y as the zero point of coordinate space
            System.Drawing.PointF centerDepthField_ir = new System.Drawing.PointF(spaceBasicToDepth[4].X, spaceBasicToDepth[4].Y);

            System.Drawing.PointF centerDepthField_rgb = new System.Drawing.PointF(spaceBasicToColor[4].X, spaceBasicToColor[4].Y);

            // It is difficult to get the center point of rgb field directly, so let's assume it is the center of rgb field

            System.Drawing.PointF centerRgbField_rgb = new System.Drawing.PointF(964.5f, 544.5f);

            // Vector from centerRgbFieldInRgb to centerDepthFieldInRgb
            System.Drawing.PointF translation = new System.Drawing.PointF(centerDepthField_rgb.X - centerRgbField_rgb.X,
                 centerDepthField_rgb.Y - centerRgbField_rgb.Y);

            // Ratio of depth unit / rgb unit
            float ratioX = (spaceBasicToDepth[2].X - centerDepthField_ir.X) / (spaceBasicToColor[2].X - centerDepthField_rgb.X);
            float ratioY = (spaceBasicToDepth[3].Y - centerDepthField_ir.Y) / (spaceBasicToColor[3].Y - centerDepthField_rgb.Y);

            ColorSpacePoint[,] shortRange = new ColorSpacePoint[512, 424];
            ColorSpacePoint[,] longRange = new ColorSpacePoint[512, 424];

            for ( int X = 0; X < 511; X ++ )
                for ( int Y = 0; Y < 423; Y ++ )
                {
                    Point3 p1 = new Point3 { X = X, Y = Y, Z = 500 };
                    Point3 p2 = new Point3 { X = X, Y = Y, Z = 8000 };

                    var p1Projected = coordinateMapper.MapDepthPointToColorSpace(new DepthSpacePoint { X = p1.X, Y = p1.Y }, (ushort)p1.Z);
                    var p2Projected = coordinateMapper.MapDepthPointToColorSpace(new DepthSpacePoint { X = p2.X, Y = p2.Y }, (ushort)p2.Z);

                    shortRange[X, Y] = p1Projected;
                    longRange[X, Y] = p2Projected;
                }
            
            // Write these projected points into a file
            if ( !File.Exists(COORDINATE_MAPPING) )
            {
                var coordinateWriter = new DepthCoordinateMappingWriter(COORDINATE_MAPPING);

                coordinateWriter.write(512, 424, 500, 8000, shortRange, longRange);
            }

            // Let's get a random space point with a depth
            Point3[] PointAs = new Point3[] { new Point3 { X = 300f, Y = 300f, Z = 500 },
                                                new Point3 { X = 400f, Y = 400f, Z = 500 },
                                                new Point3 { X = 300f, Y = 300f, Z = 1000 },
                                                new Point3 { X = 400f, Y = 400f, Z = 1000 },
                                                new Point3 { X = 300f, Y = 300f, Z = 2000 },
                                                new Point3 { X = 400f, Y = 400f, Z = 2000 },
                                                new Point3 { X = 100f, Y = 100f, Z = 1000 },
                                                new Point3 { X = 100f, Y = 100f, Z = 2000 },
                                                new Point3 { X = 0f, Y = 100f, Z = 1000 },
                                                new Point3 { X = 0f, Y = 100f, Z = 2000 },
                                                new Point3 { X = 50f, Y = 100f, Z = 1000 },
                                                new Point3 { X = 50f, Y = 100f, Z = 2000 },
                                                new Point3 { X = 50f, Y = 50f, Z = 1000 },
                                                new Point3 { X = 50f, Y = 50f, Z = 2000 },
                                                new Point3 { X = 500f, Y = 50f, Z = 1000 },
                                                new Point3 { X = 500f, Y = 50f, Z = 2000 },
                                                new Point3 { X = 10f, Y = 10f, Z = 1000 },
                                                new Point3 { X = 10f, Y = 10f, Z = 2000 },
                                                new Point3 { X = 500f, Y = 200f, Z = 1000 },
                                                new Point3 { X = 500f, Y = 200f, Z = 2000 },
                                                new Point3 { X = depthBasics[4].X, Y = depthBasics[4].Y, Z = 2000 },
                                                new Point3 { X = depthBasics[4].X, Y = depthBasics[4].Y, Z = 1000 },
                                                new Point3 { X = depthBasics[4].X, Y = depthBasics[4].Y, Z = 4000 },
                                                new Point3 { X = depthBasics[4].X, Y = depthBasics[4].Y, Z = 500 },
                                                new Point3 { X = spaceBasicToDepth[2].X, Y = spaceBasicToDepth[2].Y, Z = 1000 },
                                                new Point3 { X = spaceBasicToDepth[2].X, Y = spaceBasicToDepth[2].Y, Z = 2000 },
            };

            foreach (Point3 PointA in PointAs)
            {
                // Project randomDepthPoint using ray from IR camera on the 1-z plane
                // It still has X_ir = 300, y_ir = 300 

                System.Drawing.PointF projectedA_ir = new System.Drawing.PointF(PointA.X, PointA.Y);

                // Let's find projectedA_rgb
                System.Drawing.PointF projectedA_rgb = new System.Drawing.PointF(translation.X * 1000 / PointA.Z + (projectedA_ir.X - centerDepthField_ir.X) / ratioX + centerRgbField_rgb.X,
                                                                                   translation.Y * 1000 / PointA.Z + (projectedA_ir.Y - centerDepthField_ir.Y) / ratioY + centerRgbField_rgb.Y);

                // Test
                Console.WriteLine("======Test=====");
                Console.WriteLine(PointA.X + ", " + PointA.Y + ", " + PointA.Z);
                Console.WriteLine(projectedPoint(shortRange, longRange, 500, 8000, PointA));
                Console.WriteLine(projectedA_rgb);
                Console.WriteLine(coordinateMapper.MapDepthPointToColorSpace(new DepthSpacePoint { X = PointA.X, Y = PointA.Y }, (ushort)PointA.Z).ToSString());
            }
        }
开发者ID:tuandnvn,项目名称:ecat,代码行数:101,代码来源:KinectUtils.cs


注:本文中的CoordinateMapper.MapDepthPointToColorSpace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。