Ask Your Question

fitEllipse bug? (for angle=180)

asked 2014-10-31 05:02:32 -0500

Hanna gravatar image

hello there,

if I want to fit the ellipse for an input image which is already an exact ellipse (rotated 180° to x-axis - that means height=vertical > width=horizontal), then the opencv function fitEllipse returns the correct angle (=180) but the size is totally wrong.

e.g. for an ellipse with width=43, height=86 - it returns width=51, height=57

what is wrong here?

Cheers, Hanna

edit retag flag offensive close merge delete


Can you post your image and your code? It's hard to verify a bug if you don't provide a way to reproduce it.

FooBar gravatar imageFooBar ( 2014-10-31 05:11:47 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2014-11-03 02:08:30 -0500

Hanna gravatar image

updated 2014-11-03 02:59:52 -0500


see image attached.

the code:

std::string filename = "ellipse_ver.png"; 

cv::Mat image = cv::imread(filename, CV_LOAD_IMAGE_GRAYSCALE);

if (image.empty()){

    return -1;


std::vector<std::vector<cv::Point>> contours;

cv::findContours(image.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);

cv::RotatedRect r = cv::fitEllipse(;
edit flag offensive delete link more


That's really strange. Have you already posted it on the bug-page?

FooBar gravatar imageFooBar ( 2014-11-03 04:08:35 -0500 )edit
Hanna gravatar imageHanna ( 2014-11-03 08:00:21 -0500 )edit

Question Tools


Asked: 2014-10-31 05:02:32 -0500

Seen: 432 times

Last updated: Nov 03 '14