There is a module of scikit that deals with the problem of finding in ellipse through a set of data points: https://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.EllipseModel. Please use this module instead of my code.
This old python program fits an ellipse through a given set of points. This ellipse is optimal in the least squares sense. I just keep my code and documentation in case people are interested in obtaining a basic understanding how to attack the problem.
If you still like to use it, as it is available under the MIT license: You can use it in any way you like, but don’t blame me if you don’t like the result.
I will no longer maintain this code, unless the scikit module will disappear.
fitEllipse.orgcontains the source codefitEllipse.pdfis the pdf made fromfitEllipse.orgto make the maths readable.fitEllipse.pycontains the algorithm, obtained by tanglingfitEllipse.orgfit_ellipse_example.pyshows an example on how to use the coderun_fit_ellipse.pymakes many test cases.
Before moving this code to github, it was available at http://nicky.vanforeest.com/misc/fitEllipse/fitEllipse.html.