1

我试图在我的二进制图像中找到最大的对象。我曾经在第 52 行在这里编码,但我得到了FindContours如下所示的错误。

我的代码有什么问题?还有其他方法可以找到二值图像中面积最大的物体吗?

在此处输入图像描述

4

1 回答 1

1

你升级到3.0了吗?这会导致问题,这是一个相当普遍的情况(请参阅我的答案:Emgu CV 3 findContours and hierarchy parameter of type Vec4i equivalent?)。基本上,据我所见,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;
}
于 2016-02-01T16:45:15.510 回答