缺少Image.FindContours方法,使用最新的3.0版Emgu CV。 (我想这不是唯一的)
我在哪里可以找到它们?
更新:
我想在 C# 下完成同样的事情
Mat edges; //from canny
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours(edges, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE);
最佳答案
是的,您是对的 - EmguCV 3.0 中缺少 Image.FindContours() 方法。还有很多其他的甚至还没有被新的包装 CvInvoke
包装器。
但是对于特定的 FindContours,您可以使用下面的代码片段使用 CvInvoke 静态方法包装器: (假设 imgBinary 是 Image 对象,)
VectorOfVectorOfPoint contoursDetected = new VectorOfVectorOfPoint();
CvInvoke.FindContours(imgBinary, contoursDetected, null, Emgu.CV.CvEnum.RetrType.List, Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);
然后你可以像这样使用获得的轮廓“数组”:
contoursArray = new List<VectorOfPoint>();
int count = contoursDetected.Size;
for (int i = 0; i < count; i++)
{
using (VectorOfPoint currContour = contoursDetected[i])
{
contoursArray.Add(currContour);
}
}
请注意 CvInvoke.FindContours()
现在不返回 Seq<Point>
或 Contour<Point>
检测到轮廓中的结构,但 VectorOfVectorOfPoint
这实际上是 Point[][]
.
关于c# - EmguCV 3.0 中缺少 Image<TColor, TDepth>.FindContours,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31583946/