Approximate contour with n-sided polygon

asked 2015-09-21 09:25:21 -0600

updated 2015-09-21 10:29:02 -0600

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.

edit retag flag offensive close merge delete

Comments

1

Have you try to decrease distance in approxPolyDP like this?

LBerger gravatar imageLBerger ( 2015-09-21 10:21:22 -0600 )edit

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.

FooBar gravatar imageFooBar ( 2015-09-21 10:30:48 -0600 )edit

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?

LBerger gravatar imageLBerger ( 2015-09-21 12:30:09 -0600 )edit