Repository: opencv
Issue: fitEllipse fails with a certain set of points 
Labels: bug

### System Information

OpenCV python version: 4.10.0
Operating System / Platform: Ubuntu 24.04.1 LTS
Python version: 3.12.3

### Detailed description

cv2.fitEllipse function fails to fit an ellipse with a certain set of points. It seems that the returned angle of the ellipse should be around 90 degrees but 0 degree angle is returned instead. 

I have added four examples: three sets of points for which ellipse fitting fails and one set of points for which ellipse is fitted successfully. 

I am attaching the output of all four examples. No input is needed to reproduce the code. The points that need to be fitted are marked in red.

![elipse_fit_failed1](https://github.com/user-attachments/assets/efc41fd7-bc5f-474d-b374-d9b745b56cd0)
![elipse_fit_failed2](https://github.com/user-attachments/assets/4281e918-967f-43ed-b88f-08fa790c1705)
![elipse_fit_failed3](https://github.com/user-attachments/assets/ee27e1ae-1f2b-41d2-8a2a-a1da5a5ce628)
![elipse_fit_success](https://github.com/user-attachments/assets/86b83c32-7535-466e-9424-aa8942bacdad)

This might be related to issue https://github.com/opencv/opencv/issues/26078


### Steps to reproduce

```python
import numpy as np
import cv2

# This is an example where ellipse fitting fails
points_to_fit = np.array([[37,111],[37,112],[36,113],[37,114],[37,115],[37,116],[37,117],[37,118],[36,119],[35,120],[34,120],[33,121],[32,121],[31,121],[30,122],[29,123],[28,123],[27,124],[26,124],[25,125],[25,126],[25,127],[25,128],[25,129],[254,121],[255,120],[255,119],[256,118],[256,117],[256,116],[256,115],[256,114],[256,113],[256,112],[256,111],[256,110],[256,109],[256,108],[256,107],[257,106],[257,105],[256,104],[257,103],[257,102],[257,101]])

# This is another example where ellipse fitting fails (subset of points in the first example). Uncomment the line below to check
#points_to_fit = np.array([[ 37, 105], [ 38, 106], [ 38, 107], [25,129], [254,121], [257, 103], [257, 102], [257, 101]])

# This is another example where ellipse fitting fails (subset of points in the second example). Uncomment the line below to check
# points_to_fit = np.array([[ 37, 105], [ 38, 106], [ 38, 107], [257, 103], [257, 102], [257, 101]])

# This is a different set of point where ellipse is fitted successfully. Uncomment the line below to check
# points_to_fit = np.array([[ 30, 105], [ 25, 110], [ 30, 115], [250, 105], [255, 110], [250, 115]]) 

e = cv2.fitEllipse(np.array(points_to_fit))

print(e)

img_tmp = np.ones((300, 300, 3), np.uint8) * 255

img_tmp = cv2.ellipse(img_tmp, e, (0,0,0), 1, cv2.LINE_AA)

for point in points_to_fit:
    img_tmp = cv2.circle(img_tmp, (int(round(point[0])), int(round(point[1]))), 1, (0,0,255), -1)


cv2.imshow("ellipse", img_tmp)
cv2.waitKey(0)  
cv2.destroyAllWindows()  
```

### Issue submission checklist

- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)