Revision history [back]

After reading the docs and some examples I figured out the way it is supposed to be done.

These are the steps :

1. Collecting the points around which you plan to draw ellipse.
I have done this using a C++ std::vector.
2. Declare a Rotated Rect variable.
3. Initialize this variable using the value returned by cv::fitEllipse method.
4. Next in line is to find the center and size of the Rotated Rect.
5. Then we draw the ellipse .

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.

After reading the docs and some examples I figured out the way it is supposed to be done.

These are the steps :

1. Collecting the points around which you plan to draw ellipse.
I have done this using a C++ std::vector.
2. Declare a Rotated Rect variable.
3. Initialize this variable using the value returned by cv::fitEllipse method.
4. Next in line is to find the center and size of the Rotated Rect.
5. Then we draw the ellipse .

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.