使用Emgu CV的最新3.0版本缺少Image.FindContours方法.(我猜这不是唯一一个)
我在哪里可以找到它们?
更新:
我想在C#下完成同样的事情
Mat edges; //from canny
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours(edges, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE);
Run Code Online (Sandbox Code Playgroud)
是的,你是对的 - 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);
Run Code Online (Sandbox Code Playgroud)
然后你可以使用获得的轮廓"数组",例如:
contoursArray = new List<VectorOfPoint>();
int count = contoursDetected.Size;
for (int i = 0; i < count; i++)
{
using (VectorOfPoint currContour = contoursDetected[i])
{
contoursArray.Add(currContour);
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,CvInvoke.FindContours()现在不会返回Seq<Point>或Contour<Point>结构到contoursDetected但VectorOfVectorOfPoint实际上是Point[][].
| 归档时间: |
|
| 查看次数: |
4676 次 |
| 最近记录: |