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


C# CvMat.Erode方法代码示例

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


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

示例1: GetForegroundAlphaFrame

        private static bool GetForegroundAlphaFrame(SensorData sensorData, bool bLimitedUsers, ICollection<int> alTrackedIndexes, ref byte[] fgAlphaFrame)
        {
            if (sensorData == null || sensorData.bodyIndexImage == null)
                return false;

            CvMat cvAlphaMap = new CvMat(sensorData.depthImageHeight, sensorData.depthImageWidth, MatrixType.U8C1);

            System.IntPtr rawPtrAlpha;
            cvAlphaMap.GetRawData(out rawPtrAlpha);

            if (sensorData.selectedBodyIndex != 255 || bLimitedUsers)
            {
                // copy body-index selectively
                byte btSelBI = sensorData.selectedBodyIndex;
                int iBodyIndexLength = sensorData.bodyIndexImage.Length;

                for (int i = 0; i < iBodyIndexLength; i++)
                {
                    byte btBufBI = sensorData.bodyIndexImage[i];

                    bool bUserTracked = btSelBI != 255 ? btSelBI == btBufBI :
                        (btBufBI != 255 ? alTrackedIndexes.Contains((int)btBufBI) : false);

                    if (bUserTracked)
                    {
                        cvAlphaMap.Set1D(i, btBufBI);
                    }
                    else
                    {
                        cvAlphaMap.Set1D(i, 255);
                    }
                }
            }
            else
            {
                // copy the entire body-index buffer
                Marshal.Copy(sensorData.bodyIndexImage, 0, rawPtrAlpha, sensorData.bodyIndexImage.Length);
            }

            // make the image b&w
            cvAlphaMap.Threshold(cvAlphaMap, 254, 255, ThresholdType.BinaryInv);

            // apply erode, dilate and blur
            cvAlphaMap.Erode(cvAlphaMap);
            cvAlphaMap.Dilate(cvAlphaMap);
            cvAlphaMap.Smooth(cvAlphaMap, SmoothType.Blur, 5, 5);
            //cvAlphaMap.Smooth(cvAlphaMap, SmoothType.Median, 7);

            // get the foreground image
            Marshal.Copy(rawPtrAlpha, fgAlphaFrame, 0, fgAlphaFrame.Length);

            return true;
        }
开发者ID:BrainProject,项目名称:UnityTemp,代码行数:53,代码来源:KinectInterop.cs

示例2: GetForegroundAlphaFrame

    private static bool GetForegroundAlphaFrame(SensorData sensorData, ref byte[] fgAlphaFrame)
    {
        if(sensorData == null || sensorData.bodyIndexImage == null)
            return false;

        CvMat cvAlphaMap = new CvMat(sensorData.depthImageHeight, sensorData.depthImageWidth, MatrixType.U8C1);

        System.IntPtr rawPtrAlpha;
        cvAlphaMap.GetRawData(out rawPtrAlpha);

        Marshal.Copy(sensorData.bodyIndexImage, 0, rawPtrAlpha, sensorData.bodyIndexImage.Length);
        cvAlphaMap.Threshold(cvAlphaMap, 254, 255, ThresholdType.BinaryInv);

        cvAlphaMap.Erode(cvAlphaMap);
        cvAlphaMap.Dilate(cvAlphaMap);
        cvAlphaMap.Smooth(cvAlphaMap, SmoothType.Blur, 5, 5);
        //cvAlphaMap.Smooth(cvAlphaMap, SmoothType.Median, 7);

        Marshal.Copy(rawPtrAlpha, fgAlphaFrame, 0, fgAlphaFrame.Length);

        return true;
    }
开发者ID:lukasIO,项目名称:UnityMyo,代码行数:22,代码来源:KinectInterop.cs


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