Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV - Find skewed rectangle

I want to draw a "bounding box" around a skewed rectangle. I thought I could use the cvMinAreaRect2() function but it only handles the rotation, see this image:

enter image description here

Is there any function to solve this? If not, any ideas how to implement it?

like image 420
Linus Avatar asked Apr 29 '11 23:04

Linus


1 Answers

Compute both MinAreaRect and ConvexHull. Then, for each of the four points found by MinAreaRect, find the corresponding nearest point in the convex hull.

like image 127
rwong Avatar answered Oct 21 '22 02:10

rwong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!