Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate minimum area rectangle for a polygon

Tags:

java

c++

c

geometry

I have a need to calculate the minimum area rectangle (smallest possible rectangle) around the polygon.

The only input i have is the number of points in polygon.

I have the co-ordinates of the points also.

like image 837
Samra Avatar asked Dec 08 '22 06:12

Samra


1 Answers

This is called Minimum Bounding Box, it's most basic algorithm used in OCR packages. You can find an implementation using Rotating Calipers from the OpenCV package. Once you get the source code, check out this file,

cv/src/cvrotcalipers.cpp

The method you need is cvMinAreaRect2().

like image 110
ZZ Coder Avatar answered Dec 09 '22 18:12

ZZ Coder