1

I am trying to use CvInvoke.FindContours in EmguCV 3.1 to extract contours with their respective hierarchy level. However, I have tried some solutions from the internet to read the hierarchy mat variable. I have tried:

Mat hierarchy = new Mat();

CvInvoke.FindContours(gray_image, extractedContours, hierarchy, contouringMethod, Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxNone);

//method#1
Matrix<float> mat1 = new Matrix<float>(hierarchy.Size);
hierarchy.CopyTo(mat1);

//method#2
MatND<float> mat2 = new MatND<float>(hierarchy.Size.Width,hierarchy.Size.Height,1);
hierarchy.CopyTo(mat2);
float[, ,] arr2 = (float[, ,])mat2.ManagedArray;

But I just get zeros as result for a sourc image of a small rectangle inside a big rectange for example. Someone knows how to extract the hierarchy information from the mat variable or any other way to extract the hierarchy information for a Tree. I am also open to any other way t

Nahydrin
  • 13,197
  • 12
  • 59
  • 101
Pablo Gonzalez
  • 673
  • 2
  • 10
  • 24
  • what is the value of your `contouringMethod` variable? also, see [this question](http://stackoverflow.com/questions/11782147/python-opencv-contour-tree-hierarchy). It's about python, but that's basically the same – slawekwin Mar 01 '17 at 07:10
  • contouringMethod = RetrType.Tree. In python, the functions are a little bit different. Also, I am not getting any result about the hierarchy. All my resulting array variables are zero arrays – Pablo Gonzalez Mar 01 '17 at 08:12

0 Answers0