Reputation: 864
I am trying to find biggest object in my binary image. I used to code here in line 52 but I got the error on FindContours
shown below.
What is wrong in my code? and Is there an other way to find the object has biggest area in binary image?
Upvotes: 1
Views: 2573
Reputation: 761
Did you upgrade to 3.0? That would cause the issue, and it's a fairly common occurrence (see my answer here: Emgu CV 3 findContours and hierarchy parameter of type Vec4i equivalent?). Basically, from what I have seen, the Emgu team has not yet migrated all the functionality to the newest versions, so some things that worked in 2.X will need to be redone.
If you want to use that functionality, you can directly invoke the FindContours method:
/// <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;
}
Upvotes: 2