Reputation: 782
I am working in OpenCV/Python and I came up with this problem. I have used cv2.minAreaRect() to get the Bounding Box surrounding a set of points. Is there any other function/generic algorithm that can give me the largest rectangle inscribed within a polygon (set of points)? I have a set of points of the polygon and the function should be able to return 4 points of the largest rectangle inscribing the input points.
Here is an example of a similar kind of problem
Thanks. Any help is highly appreciated.
Upvotes: 1
Views: 2638
Reputation: 11
I can provide you with those set of conditions which can lead you to your desired result but can't provide you with the code at present because it's very time taking for me. so you have to code for yourself in the mean time. here are the conditions to follow.
Filter all the coordinates of the polygon for all 4 set of coordinates which satisfy these below mentioned condition for coordinates: [(a,b),(c,d),(e,f),(g,h)]
1.(a-c)=(e-g) as opposite sides should be equal
2.(b-f)=(d-h) as opposite sides should be equal
3.(d-f)^2+(c-e)^ = (b-h)^2+(a-g)^2 as diagonals should be equal
if these conditions are satisfied you will get all the set of four
coordinates which are rectangles.After that
4.Filter out all the coordinates received by checking if any polygonal coordinate is falling inside the rectangle, that's easy.
now you are left with all the possible inbound rectangles, now all you have
to do is
list all the areas possible
max out the list for maximum area.
Upvotes: 0