peterbraden / node-opencv

OpenCV Bindings for node.js
MIT License
4.37k stars 858 forks source link

CV_RETR_CCOMP in findContours not returning hierarchy #634

Closed justin-segler closed 6 years ago

justin-segler commented 6 years ago

I noticed that the mode and chain args inside of findContours are hardcoded to be CV_RETR_LIST and CV_CHAIN_APPROX_SIMPLE. However, when the mode is changed to CV_RETR_CCOMP (which should return the hierarchy with sibling and parent-child relationships), it is not returning the full hierarchy.

1) Why is the mode and chain hardcoded? These should be arguments to the findContours function. 2) Why is CV_RETR_CCOMP returning the same hierarchy output as CV_RETR_LIST?

crawft commented 5 years ago

Were you able to solve this? Also looking to get the hierarchy from findContours...

crawft commented 5 years ago

OK, so you CAN pass integer vals for mode and chain, modes:

CV_RETR_EXTERNAL =0, CV_RETR_LIST =1, CV_RETR_CCOMP =2, CV_RETR_TREE =3, CV_RETR_FLOODFILL =4