Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Float or int accuracy for displaying line.

Hi

From the example of RotateRect in the documentation the vertices are stored in an array of Point2f which contains floating point values, the line function then draws with these values.

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);

My question is why is the array created using Point2f? wouldn't it be better to use Point2i? as pixel coordinates cannot be faction numbers anyway.

Also would there be a performance penalty in using floating point instead of int?

Thanks

Steve