How opencv Extracts the Region of Interest of Rotating Rectangle

It's simple,

1 use Rotatedrect Minarearect (input array point) to get this rotated rectangle.

2 save its four corners to a vector < Point >;; Inside, it becomes an outline. What about the four corners? Have you seen structures.html http://docs.opencv.org/modules/core/doc/basic? highlight = rotated rect # rotated rect

You can take it out.

Then traverse all the points of the inner contour, and then determine the distance between this point and the quadrilateral with the opencv function of pointPolygonTest.

It should be noted that the obtained distance is negative because the point is within the contour.