Image<TColor, TDepth>.FindContours missing from EmguCV 3.0

The Image.FindContours method is missing, using the latest 3.0 version of Emgu CV. (i guess that is not the only one)

Where can I find them?

Update:

I want to accomplish the same under C#

Mat edges; //from canny
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours(edges, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE);

Upvotes: 1

Views: 4928

Answers (1)

Michael
Michael

Reputation: 51

Yes, you are right - the Image.FindContours() method is missing from the EmguCV 3.0. And there is a lot of others even has not been wrapped by the new CvInvoke wrapper.

But as for the FindContours particular one you can use the snippet below using CvInvoke static methods wrapper: (suppose imgBinary is the Image object, )

VectorOfVectorOfPoint contoursDetected = new VectorOfVectorOfPoint();
CvInvoke.FindContours(imgBinary, contoursDetected, null, Emgu.CV.CvEnum.RetrType.List, Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);

And then you can use the obtained contours "array" for example like this:

contoursArray = new List<VectorOfPoint>();
int count = contoursDetected.Size;
for (int i = 0; i < count; i++)
{
    using (VectorOfPoint currContour = contoursDetected[i])
    {
        contoursArray.Add(currContour);
    }
}

Note that the CvInvoke.FindContours() now doesn't return Seq<Point> or Contour<Point> structures into the contoursDetected but the VectorOfVectorOfPoint which is actually Point[][].

Upvotes: 5

Related Questions