How would I sort contours from cvFindContours using RETR_TREE into a tree/pyrimid based on hierarchy?
For example if I were to input the hierarchy from 4.RETR_TREE here
hierarchy =
array([[[ 7, -1, 1, -1],
[-1, -1, 2, 0],
[-1, -1, 3, 1],
[-1, -1, 4, 2],
[-1, -1, 5, 3],
[ 6, -1, -1, 4],
[-1, 5, -1, 4],
[ 8, 0, -1, -1],
[-1, 7, -1, -1]]])
I would like to get this output:
{0:{1:{2:{3:{4:{5:{},6:{}}}}}},
7:{},
8:{}}
I am looking to do this to build a tree model in Qt so I can easily see which contours contain which others. If you have a better idea of how to turn the hierarchy data into a Qt tree model that would also be appreciated.
Thanks in advance!
It's really(!) against netiquette to post your question twice without even saying to do so. In many cases, the question will be answered once and the poster won't even publish the answer at the other places (you are a nice exception from the rule...). But please at least make it visible that you copy/pasted the question.
Thanks for the tip. I didn't realize that. I just thought this forum would be more knowledgeable about opencv specifically while stack would be a good source of broader knowledge and has a larger user base. I'm not quite sure why it would be bad to post on two different forums?? It seems its just a better way to have more people see the question and potential answer.