Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cv::fitEllipse sometimes completely fails #6544

Closed
zvrba opened this issue May 16, 2016 · 2 comments · Fixed by #9923
Closed

cv::fitEllipse sometimes completely fails #6544

zvrba opened this issue May 16, 2016 · 2 comments · Fixed by #9923

Comments

@zvrba
Copy link

zvrba commented May 16, 2016

Please state the information for your system

  • OpenCV version: 3.x (3.1)
  • Host OS: Linux (Arch Linux)

In which part of the OpenCV library you got the issue?

The function cv::fitEllipse sometimes completely fails, returning bogus fit.

Additional description

A fit is returned which is concave against the dataset. To reproduce, please clone the following repository: https://github.com/zvrba/ellipse_fitting; it is a netbeans project and you may need to adjust makefiles to link it on platforms other than Arch. You will also need to install Eigen matrix library v3.2 to compile it.

The program contains a hard-coded dataset which demonstrates the failure nicely; run it with ellipsefitting FAIL 1. The fit produced by my implementation of paper [1] is displayed with thick line; the fit produced by OpenCV is displayed with thin line. The dataset are small circles. As you can see from the image, the OpenCV fitting has completely failed.

[1] http://autotrace.sourceforge.net/WSCG98.pdf

Note: the program compares the two fitting procedures. If you replace FAIL with some number, it will generate that many random points with added gaussian noise with sigma=1 (the 2nd parameter) and plot the results.

screenshot from 2016-05-16 11-25-45

@arrybn
Copy link
Contributor

arrybn commented Jul 15, 2016

I created test for this issue in this PR: #6915

@arrybn arrybn assigned vpisarev and unassigned arrybn Jul 15, 2016
@arrybn
Copy link
Contributor

arrybn commented Jul 18, 2016

Current status is next:
There are 2 bugs for fitEllipse(): this and #4515. Both bugs contain set of points which leads to fitEllipse() fail.
Author of #4515 suggests relatively small changes but his fixes don't correct this bug. Moreover, I have not found articles or any explanations for current implementation of fitEllipse(). Documentation points to article in which some different algorithm is described.
In this bug author suggests total change of fitEllipse() algorithm.
I've added 2 tests for both issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants