How to detect ellipses in image without using fitEllipse() in opencv?

As you already got, you don’t need ellipse fitting, but ellipse detection.

You can find in my other answer two papers with C++ code available. I’ll report here for completeness:

  1. L. Libuda, I. Grothues, K.-F. Kraiss, Ellipse detection in digital image
    data using geometric features, in: J. Braz, A. Ranchordas, H. Arajo,
    J. Jorge (Eds.), Advances in Computer Graphics and Computer Vision,
    volume 4 of Communications in Computer and Information Science,
    Springer Berlin Heidelberg, 2007, pp. 229-239. link, code

  2. M. Fornaciari, A. Prati, R. Cucchiara,
    “A fast and effective ellipse detector for embedded vision applications”, Pattern Recognition, 2014 link, code

It’s also fairly easy to port to OpenCV this matlab script with the implementation of the two papers:

  • “A New Efficient Ellipse Detection Method” (Yonghong Xie Qiang , Qiang Ji / 2002)
  • “Randomized Hough Transform for Ellipse Detection with Result Clustering” (CA Basca, M Talos, R Brad / 2005)

Another very interesting algorithm is:

  • Dilip K. Prasad, Maylor K.H. Leung and Siu-Yeung Cho, “Edge curvature and convexity based ellipse detection method,” Pattern Recognition, 2012.

Matlab code can be found here


Directly applying Hough Transform is not feasible for an ellipse, since you’ll work in a 5 dimensional parameter space. This will be really slow, and not accurate. So a lot of algorithms have been proposed. Among the ones mentioned here:

  • Xie and Ji approach is quite famous and very easy (but still slow)
  • Basca et al. approach is faster, but may be not accurate
  • Prasad et al. approach is fast, and very accurate.
  • Libuda et al. approach is very fast and accurate
  • Fornaciari et al. approach is the fastest, but may be inaccurate in particular cases.

For the up-to-date bibliography for ellipse detection, you can refer to this page.

Leave a Comment