diff --git a/modules/core/doc/pics/rotatedrect.png b/modules/core/doc/pics/rotatedrect.png index 344bf49ad0..8c43e32b86 100644 Binary files a/modules/core/doc/pics/rotatedrect.png and b/modules/core/doc/pics/rotatedrect.png differ diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index 9da1450d46..73cb29f73a 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -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 diff --git a/samples/cpp/tutorial_code/snippets/core_various.cpp b/samples/cpp/tutorial_code/snippets/core_various.cpp index 4639940856..2be97f989d 100644 --- a/samples/cpp/tutorial_code/snippets/core_various.cpp +++ b/samples/cpp/tutorial_code/snippets/core_various.cpp @@ -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);