This forum is disabled, please visit https://forum.opencv.org

1 | initial version |

A rotated rectangle consists of four points, the corners. Therefore it should be possible to convert it to a contour. Then I would suggest you follow the answer on StackOverflow, linked below, to see if your point is within that contour.

Determine if a point is inside or outside of a shape with opencv

That would make you end up with something like this:

```
bool DoesRectangleContainsPoint(RotatedRect rectangle, Point2f point) {
//Get the corner points.
Point2f corners[4];
rectangle.points(corners);
//Convert the point array to a vector.
//https://stackoverflow.com/a/8777619/1997617
Point2f* lastItemPointer = (corners + sizeof corners / sizeof corners[0]);
vector<Point2f> contour(corners, lastItemPointer);
//Check if the point is within the rectangle.
double indicator = pointPolygonTest(contour, point, false);
bool rectangleContainsPoint = (indicator >= 0);
return rectangleContainsPoint;
}
```

2 | No.2 Revision |

A rotated rectangle consists of four points, the corners. Therefore it should be possible to convert it to a contour. Then I would suggest you follow the answer on StackOverflow, linked below, to see if your point is within that contour.

Determine if a point is inside or outside of a shape with opencv

That would make you end up with something like this:

`bool `~~DoesRectangleContainsPoint(RotatedRect ~~DoesRectangleContainPoint(RotatedRect rectangle, Point2f point) {
//Get the corner points.
Point2f corners[4];
rectangle.points(corners);
//Convert the point array to a vector.
//https://stackoverflow.com/a/8777619/1997617
Point2f* lastItemPointer = (corners + sizeof corners / sizeof corners[0]);
vector<Point2f> contour(corners, lastItemPointer);
//Check if the point is within the rectangle.
double indicator = pointPolygonTest(contour, point, false);
bool rectangleContainsPoint = (indicator >= 0);
return rectangleContainsPoint;
}

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.