How do you approximate a shape with fixed angle polygon in OpenCV?

Viewed 106

I have some contours for example the three colored shapes in this image.

enter image description here

I would like to approximate the boundary of each with a polygon WITH the constraint that the interior angles of the polygon are some fixed values. So the angle should snap to say {45 or 90} degrees and also ensure no edge is less that a certain number of pixels .e.g 50 - so there aren't many tiny edges. So the result for the green contour would be:

enter image description here

Is this possible in OpenCV?

0 Answers
Related