【问题标题】:Image<TColor, TDepth>.FindContours missing from EmguCV 3.0EmguCV 3.0 中缺少 Image<TColor, TDepth>.FindContours
【发布时间】:2015-08-06 20:00:46
【问题描述】:

缺少 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);

【问题讨论】:

    标签: c# emgucv


    【解决方案1】:

    是的,你是对的 - EmguCV 3.0 中缺少 Image.FindContours() 方法。还有很多其他的甚至还没有被新的CvInvoke 包装器包装。

    但是对于 FindContours 特定的一个,您可以使用下面的 sn-p 使用 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&lt;Point&gt;Contour&lt;Point&gt; 结构返回到contoursDetected 中,而是VectorOfVectorOfPoint 实际上是Point[][]

    【讨论】:

    • 请解释你的答案,添加链接\引用和引用
    • 欢迎来到 SO。 @迈克尔。即使您已经确定了作者所指的方法,它也不能解决问题。这个问题本身质量很低,因为没有代码示例或任何参考。请考虑进一步解释并向作者索取更多信息。
    • 答案还是挺有用的,除了层次的类型。
    猜你喜欢
    • 2018-10-17
    • 2020-09-01
    • 1970-01-01
    • 2017-04-14
    • 2016-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-28
    相关资源
    最近更新 更多