【问题标题】:OpenCV/EmguCV Version 2 to OpenCV/EmguCV Version 3 conversionOpenCV/EmguCV 版本 2 到 OpenCV/EmguCV 版本 3 的转换
【发布时间】:2017-01-14 19:12:24
【问题描述】:

当然,我正在学习 OpenCV/EmguCV,实际上更喜欢 EmguCV,因为包装器非常好。

但是,在网上找到的许多示例/教程都是针对 2.X 版的,并且不能在 3.0 版下编译。第 3 版不支持 Contour 之类的东西。是否有任何人都可以指点我的文档/网站,这样我可以花更少的时间移植,而花更多的时间实际学习和做?

【问题讨论】:

  • 您在寻找transition guide吗?
  • 如果您使用的是 emgu,请不要使用 opencv 标签。 api的差异很大,opencv也不支持这个。
  • @berak,我非常清楚 API 的不同之处。但是,我的理由是,如果有什么东西可以指导 2.X 到 3.0 OpenCV 的过渡,也许我可以从 EmguCV 的变化中推断出来。
  • @Miki,谢谢!是的,这会很有帮助。

标签: emgucv


【解决方案1】:

其实我只是在这里回答了这个问题:Emgu CV 3 findContours and hierarchy parameter of type Vec4i equivalent?

正如你提到的,轮廓在 Emgu 3 中没有正确实现,但你可以手动调用 FindContours 方法,它会起作用:

/// <summary>
/// Find contours using the specific memory storage
/// </summary>
/// <param name="method">The type of approximation method</param>
/// <param name="type">The retrieval type</param>
/// <param name="stor">The storage used by the sequences</param>
/// <returns>
/// Contour if there is any;
/// null if no contour is found
/// </returns>
public static VectorOfVectorOfPoint FindContours(this Image<Gray, byte> image, ChainApproxMethod method = ChainApproxMethod.ChainApproxSimple,
    Emgu.CV.CvEnum.RetrType type = RetrType.List) {
    //Check that all parameters are valid.
    VectorOfVectorOfPoint result = new VectorOfVectorOfPoint();

    if (method == Emgu.CV.CvEnum.ChainApproxMethod.ChainCode) {
        throw new ColsaNotImplementedException("Chain Code not implemented, sorry try again later");
    }

    CvInvoke.FindContours(image, result, null, type, method);
    return result;
}

并使用这些轮廓:

    VectorOfVectorOfPoint contours = canvass2.FindContours(ChainApproxMethod.ChainApproxSimple, RetrType.Tree);
    int contCount = contours.Size;
    for (int i = 0; i < contCount; i++) {
        using (VectorOfPoint contour = contours[i]) {
            segmentRectangles.Add(CvInvoke.BoundingRectangle(contour));
            if (debug) {
                finalCopy.Draw(CvInvoke.BoundingRectangle(contour), new Rgb(255, 0, 0), 5);
            }
        }
    }

我刚刚经历了相同的转换过程,所以如果您能具体说明您遇到的其他问题,我可以回答很多问题。

【讨论】:

  • 克里斯,谢谢!我很感激答案和提供一些帮助。道格
猜你喜欢
  • 2016-12-17
  • 2018-06-21
  • 1970-01-01
  • 2011-02-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多