1 | initial version |
After reading the docs and some examples I figured out the way it is supposed to be done.
These are the steps :
C++ std::vector
.Rotated Rect
variable.cv::fitEllipse
method.center
and size
of the Rotated Rect
.cv::RotatedRect _Ellipse['value you want'];
_Ellipse[i] = cv::fitEllipse(points_vector);
cv::Point2f center = cv::Point2f(_Ellipse[i].center.x ,_Ellipse[i].center.y );
cv::Size2f size = cv::Size2f(_Ellipse[i].size.width,_Ellipse[i].size.width);
cv::RotatedRect ellipse_rect = cv::RotatedRect(center, size, _Ellipse[i].angle);
cv::ellipse(ref_image, ellipse_rect, cv::Scalar(0,0,255), -1, 8);
I am still not completely sure about this because it is drawing a circle instead of ellipse, but this is like the gist of what is to be done. Thanks.
2 | No.2 Revision |
After reading the docs and some examples I figured out the way it is supposed to be done.
These are the steps :
C++ std::vector
.Rotated Rect
variable.cv::fitEllipse
method.center
and size
of the Rotated Rect
.cv::RotatedRect _Ellipse['value you want'];
_Ellipse[i] = cv::fitEllipse(points_vector);
cv::Point2f center = cv::Point2f(_Ellipse[i].center.x ,_Ellipse[i].center.y );
cv::Size2f size = cv::Size2f(_Ellipse[i].size.width,_Ellipse[i].size.width);
cv::Size2f(_Ellipse[i].size.width,_Ellipse[i].size.width);
cv::Size2f size = cv::Size2f(_Ellipse[i].size.width,_Ellipse[i].size.height);
cv::RotatedRect ellipse_rect = cv::RotatedRect(center, size, _Ellipse[i].angle);
cv::ellipse(ref_image, ellipse_rect, cv::Scalar(0,0,255), -1, 8);
I am still not completely sure about this because it is drawing a circle instead of ellipse, but this is like the gist of what is to be done. Thanks.
EDIT
I made a silly mistake while defining Size2f
(width
instead of height
) . Now I am getting proper ellipse.