8/26/2013

OpenCV - RotatedRect Draw Example source code

This source code is copied from this site -> http://docs.opencv.org/modules/core/doc/basic_structures.html for our convenience.


Mat image(200, 200, CV_8UC3, Scalar(0));
RotatedRect rRect = RotatedRect(Point2f(100,100), Size2f(100,50), 30);

Point2f vertices[4];
rRect.points(vertices);
for (int i = 0; i < 4; i++)
    line(image, vertices[i], vertices[(i+1)%4], Scalar(0,255,0));

Rect brect = rRect.boundingRect();
rectangle(image, brect, Scalar(255,0,0));

imshow("rectangles", image);
waitKey(0);



We can get rect information and rotatedRect information from RotatedRect variance.
From the above source code, green line is drawn by line function for describing rotated rect. 
And Blue line means outlier rect of target. It is drawn by rectangle function.
Thank you.

1 comment:

  1. Anonymous23/5/23 02:50

    Thanks for sharing this.,
    Leanpitch provides online training in agile coach certification, everyone can use it wisely.

    ReplyDelete