1 | initial version |
You're only looking at contour[0]. Ever.
Your outer for loop checks every contour at the top level of the hirearchy, and either disqualifies them based on area or looks further.
Your inner loop is supposed to check every point in the contour, but it only looks at contour[0].