How to fit an ellipse contour with 4 points?
<p>I have 4 coordinate points. Using these 4 points I want to fit an ellipse, but seems like the requirement for cv2.fitellipse() is a minimum of 5 points. Is there any way to get around this and draw a countour with just 4 points?</p>

<p>How does fitellipse draw a contour when cv2.CHAIN_APPROX_SIMPLE is used, which gives only 4 coordinates point. </p>

<p>If you take a look at the equation for ellipses:</p>

<p><a href="http://i.stack.imgur.com/EkEHr.gif" rel="nofollow"><img src="http://i.stack.imgur.com/EkEHr.gif" alt="enter image description here"></a></p>

<p>and the homogenous representation:</p>

<p><a href="http://i.stack.imgur.com/ehVZY.gif" rel="nofollow"><img src="http://i.stack.imgur.com/ehVZY.gif" alt="enter image description here"></a>.</p>

<p>The conic-matrix looks like this:</p>

<p><a href="http://i.stack.imgur.com/sA0u5.gif" rel="nofollow"><img src="http://i.stack.imgur.com/sA0u5.gif" alt="enter image description here"></a></p>

<p>you see that it has 6 parameters - one projective degree of freedom, so 5 degree of freedom (if f not equal 0).
Every point on C gives a condition to the parameters a-f. So five points are needed to describe a conic:</p>

<p><a href="http://i.stack.imgur.com/U5U4i.gif" rel="nofollow"><img src="http://i.stack.imgur.com/U5U4i.gif" alt="enter image description here"></a></p>

<p>To solve this you need to compute the kernel of the matrix (for five points):</p>

<p><a href="http://i.stack.imgur.com/She4g.gif" rel="nofollow"><img src="http://i.stack.imgur.com/She4g.gif" alt="enter image description here"></a> </p>

<p>if you have more then five you need the least square solution:
<a href="http://i.stack.imgur.com/icWFJ.gif" rel="nofollow"><img src="http://i.stack.imgur.com/icWFJ.gif" alt="enter image description here"></a></p>

<p>and x is the eigenvector from the smallest eigenvalue of <a href="http://i.stack.imgur.com/Nsl12.gif" rel="nofollow"><img src="http://i.stack.imgur.com/Nsl12.gif" alt="enter image description here"></a></p>

python opencv image-processing