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