How to get the distance between the major and minor axes an ellipse?

I am trying to use opencv in python to detect the distance between the major and bottom axes of an ellipse in an image, so far I detect the centroid. Any ideas to get the axes of the ellipse?

Thanks a lot

``````import time
import sys
sys.path.append('/usr/local/lib/python3.9/site-packages')

import cv2
import numpy as np

# Convert to grayscale.
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Blur using 3 * 3 kernel.
gray_blurred = cv2.blur(gray, (3, 3))

# Apply Hough transform on the blurred image.
detected_circles = cv2.HoughCircles(gray_blurred,
cv2.HOUGH_GRADIENT, 1, 20, param1 = 50,

# Draw circles that are detected.
if detected_circles is not None:

# Convert the circle parameters a, b and r to integers.
detected_circles = np.uint16(np.around(detected_circles))

for pt in detected_circles[0, :]:
a, b, r = pt[0], pt[1], pt[2]

# Draw the circumference of the circle.
cv2.circle(img, (a, b), r, (0, 255, 0), 2)

# Draw a small circle (of radius 1) to show the center.
cv2.circle(img, (a, b), 1, (0, 0, 255), 3)

print ("axis x:",(pt[0]))
print ("axis y:",(pt[1]))
print ("Diameter:",(pt[2]))
cv2.imshow("Detected Circle", img)
cv2.waitKey(0)
``````

if you had contours, you could try to fit an ellipse