I succesfully implemented a Delaunay triangulation of a contour in OpenCV 2.3.1.
With cvPointPolygonTest I can get all the triangles in the convex hull, then I tried to perform another cvPointPolygonTest on triangles centroid to know if they are in the main contour or not, so I can have the constrained triangulation of the contour.
But, it doesn't work well, as some triangles are (eg. with a walking man who has his two legs distant) 'over' a hole.
Does anyone know a way to perform a constrained triangulation. I thought about convexityDefects, but can't manage to understand how to begin with this.
Thanks in advance !
Ben
In fact, it is not a Convex Hull defects problem, but a triangulation one. This image will show you the trouble :
Particularly in the bottom of the triangulated hull, you can see that the triangulation is in AND out of the contour, because OpenCV is triangulating the convex hull. I would like to find a way to triangulate the contour itself.
I found some ideas about adding Steiner Points in the contour itself, but can't find where to begin with OpenCV.
My idea was to :
- test if the triangle is in AND out of the contour ;
- if true : get the intersection point ;
- and add it to the cvSubdiv2D.
Am I right with this ?
Thanks for your patience and your answers !