0
我想在我的二進制圖像中找到最大的對象。我曾經在第52行代碼here,但我得到了如下所示的FindContours
錯誤。在C#中EmguCV不能使用'FindContours'
我的代碼有什麼問題?有沒有其他的方式來找到對象在二進制圖像中最大的區域?
我想在我的二進制圖像中找到最大的對象。我曾經在第52行代碼here,但我得到了如下所示的FindContours
錯誤。在C#中EmguCV不能使用'FindContours'
我的代碼有什麼問題?有沒有其他的方式來找到對象在二進制圖像中最大的區域?
你升級到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;
}