本文整理汇总了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;
}
示例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;
}