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


C# CvMat.GetSize方法代码示例

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


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

示例1: DepthColorMatToRealPoints

 /// <summary>
 /// 深度データからリアルワールドの色を見つける
 /// </summary>
 /// <param name="depthData"></param>
 /// <param name="colorFrameData"></param>
 /// <param name="colorSize"></param>
 /// <returns></returns>
 public List<Tuple<CvPoint3D64f, CvColor>> DepthColorMatToRealPoints(CvMat depthMat, CvMat colorMat)
 {
     List<Tuple<CvPoint3D64f, CvColor>> res = new List<Tuple<CvPoint3D64f, CvColor>>();
     int bytesPerPixel = colorMat.ElemChannels;
     CvSize colorSize = colorMat.GetSize();
     unsafe
     {
         short* depthArr = depthMat.DataInt16;
         byte* colorArr = colorMat.DataByte;                
         
         for (int y = 0; y < depthHeight; ++y)
         {
             for (int x = 0; x < depthWidth; ++x)
             {
                 int depthIndex = (y * depthWidth) + x;
                 ushort depthVal = (ushort)depthArr[depthIndex];
                 ColorSpacePoint colorPoint = this.MapDepthPointToColorSpace(x, y, depthVal, colorSize.Width, colorSize.Height);
                 CameraSpacePoint cameraPoint = this.MapDepthPointToCameraSpace(x, y, depthVal);
                 // make sure the depth pixel maps to a valid point in color space
                 int colorX = (int)Math.Floor(colorPoint.X + 0.5);
                 int colorY = (int)Math.Floor(colorPoint.Y + 0.5);
                 if ((colorX >= 0) && (colorX < colorSize.Width) && (colorY >= 0) && (colorY < colorSize.Height))
                 {
                     // calculate index into color array
                     int colorIndex = ((colorY * colorSize.Width) + colorX) * bytesPerPixel;
                     CvColor color = new CvColor(colorArr[colorIndex + 2], colorArr[colorIndex + 1], colorArr[colorIndex + 0]);
                     res.Add(Tuple.Create((CvPoint3D64f)cameraPoint.ToCvPoint3D(), color));
                 }
             }
         }
     }
     return res;
 }
开发者ID:guozanhua,项目名称:KinectMotionCapture,代码行数:40,代码来源:LocalCoordinateMapper.cs

示例2: GetEachUserColorPoints

        /// <summary>
        /// ユーザのボクセルを返す
        /// </summary>
        /// <param name="depthData"></param>
        /// <param name="colorFrameData"></param>
        /// <param name="bodyIndexFrameData"></param>
        /// <param name="colorSize"></param>
        /// <returns></returns>
        public Dictionary<int, List<Tuple<CvPoint3D64f, CvColor>>> GetEachUserColorPoints(CvMat depthMat, CvMat colorMat, CvMat userMat)
        {
            Dictionary<int, List<Tuple<CvPoint3D64f, CvColor>>> res = new Dictionary<int, List<Tuple<CvPoint3D64f, CvColor>>>();
            List<Tuple<CvPoint3D64f, CvColor>> lis;
            int bytesPerPixel = colorMat.ElemChannels;
            CvSize colorSize = colorMat.GetSize();
            unsafe
            {
                short* depthArr = depthMat.DataInt16;
                byte* colorArr = colorMat.DataByte;
                byte* userArr = userMat.DataByte;

                for (int y = 0; y < depthHeight; ++y)
                {
                    for (int x = 0; x < depthWidth; ++x)
                    {                        
                        int depthIndex = (y * depthWidth) + x;
                        byte player = userArr[depthIndex];
                        if (player != 0xff)
                        {
                            ushort depthVal = (ushort)depthArr[depthIndex];
                            ColorSpacePoint colorPoint = this.MapDepthPointToColorSpace(x, y, depthVal, colorSize.Width, colorSize.Height);
                            CameraSpacePoint cameraPoint = this.MapDepthPointToCameraSpace(x, y, depthVal);
                            // make sure the depth pixel maps to a valid point in color space
                            int colorX = (int)Math.Floor(colorPoint.X + 0.5);
                            int colorY = (int)Math.Floor(colorPoint.Y + 0.5);
                            if ((colorX >= 0) && (colorX < colorSize.Width) && (colorY >= 0) && (colorY < colorSize.Height))
                            {
                                // calculate index into color array
                                int colorIndex = ((colorY * colorSize.Width) + colorX) * bytesPerPixel;
                                CvColor color = new CvColor(colorArr[colorIndex + 2], colorArr[colorIndex + 1], colorArr[colorIndex + 0]);
                                if (res.TryGetValue((int)player, out lis))
                                {
                                    res[(int)player].Add(Tuple.Create((CvPoint3D64f)cameraPoint.ToCvPoint3D(), color));
                                }
                                else
                                {
                                    res[(int)player] = new List<Tuple<CvPoint3D64f, CvColor>>();
                                    res[(int)player].Add(Tuple.Create((CvPoint3D64f)cameraPoint.ToCvPoint3D(), color));
                                }
                            }
                        }
                    }
                }
            }
            return res;
        }
开发者ID:guozanhua,项目名称:KinectMotionCapture,代码行数:55,代码来源:LocalCoordinateMapper.cs


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