繁体   English   中英

无法在C#中的EmguCV中使用'FindContours'

[英]Can not use 'FindContours' with EmguCV in C#

我正在尝试在二进制图像中找到最大的对象。 我以前在这里在第52行进行编码,但是在如下所示的FindContours上遇到了错误。

我的代码有什么问题? 还有其他方法可以找到二进制图像中具有最大面积的对象吗?

在此处输入图片说明

您是否升级到3.0? 这将导致问题,并且这是相当普遍的情况(请在此处查看我的答案: Emgu CV 3 findContours和等同于Vec4i类型的层次结构参数? )。 基本上,从我所看到的来看,Emgu团队尚未将所有功能迁移到最新版本,因此需要重做在2.X中可用的某些功能。

如果要使用该功能,可以直接调用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;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM