Approximate contour with n-sided polygon
I have segmented a contour which can be approximated by a 5-sided polygon (a square with a corner broken off). Is there a function that makes use of this information? I currently uses approxPolyDP, but that function only uses a maximal distance between the approximation and the contour and not the expected number of corners.
Have you try to decrease distance in approxPolyDP like this?
The detection is so far reliable, but giving a distance threshold feels wrong if I have a much better information (n=5) in my case that would be scale-invariant.
I don't understand problem with scale invariant because algorithm stop when side number is equal to 5 (4 in my example) . Of course if you want a square and add one corner it does not work.
In that case I think you have to write your own algorithm. If contour is a circle there is 4 answers is it?