mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
Merge pull request #23342 from n0099:#23335
Improve document of cv::RotatedRect for #23335 #23342 fix #23335 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
parent
3c76b33532
commit
868787c364
Binary file not shown.
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 1.8 KiB |
@ -545,8 +545,11 @@ public:
|
||||
*/
|
||||
RotatedRect(const Point2f& point1, const Point2f& point2, const Point2f& point3);
|
||||
|
||||
/** returns 4 vertices of the rectangle
|
||||
@param pts The points array for storing rectangle vertices. The order is bottomLeft, topLeft, topRight, bottomRight.
|
||||
/** returns 4 vertices of the rotated rectangle
|
||||
@param pts The points array for storing rectangle vertices. The order is _bottomLeft_, _topLeft_, topRight, bottomRight.
|
||||
@note _Bottom_, _Top_, _Left_ and _Right_ sides refer to the original rectangle (angle is 0),
|
||||
so after 180 degree rotation _bottomLeft_ point will be located at the top right corner of the
|
||||
rectangle.
|
||||
*/
|
||||
void points(Point2f pts[]) const;
|
||||
//! returns the minimal up-right integer rectangle containing the rotated rectangle
|
||||
|
@ -38,6 +38,8 @@ int main()
|
||||
waitKey(0);
|
||||
//! [Algorithm]
|
||||
|
||||
const char * vertex_names[4] {"0", "1", "2", "3"};
|
||||
|
||||
//! [RotatedRect_demo]
|
||||
Mat test_image(200, 200, CV_8UC3, Scalar(0));
|
||||
RotatedRect rRect = RotatedRect(Point2f(100,100), Size2f(100,50), 30);
|
||||
@ -45,7 +47,10 @@ int main()
|
||||
Point2f vertices[4];
|
||||
rRect.points(vertices);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
line(test_image, vertices[i], vertices[(i+1)%4], Scalar(0,255,0), 2);
|
||||
putText(test_image, vertex_names[i], vertices[i], FONT_HERSHEY_SIMPLEX, 1, Scalar(255,255,255));
|
||||
}
|
||||
|
||||
Rect brect = rRect.boundingRect();
|
||||
rectangle(test_image, brect, Scalar(255,0,0), 2);
|
||||
|
Loading…
Reference in New Issue
Block a user