Ask Your Question
1

How to draw ellipse with first python function ?

asked Mar 28 '14

Guido gravatar image

updated Aug 12 '14

Dear all,

I am trying to draw an ellipse with Opencv/Python, version 2.4.6.1. According to the doc, there are two functions :

Python: cv2.ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]])  None
Python: cv2.ellipse(img, box, color[, thickness[, lineType]])  None

I use the first as follow :

cv2.ellipse(img, (113, 155.6), (23.4, 15.2), 0.0, 0.0, 360.0, (255, 255, 255), -1);

but get the following error message

TypeError: ellipse() takes at most 5 arguments (8 given)

Any idea on how to solve this ?

Preview: (hide)

2 answers

Sort by » oldest newest most voted
1

answered Aug 11 '14

lapis gravatar image

I found that axes (as well as center) has to be an integers tuple, not floats. Pretty hard to figure out by the error message OpenCV gives...

Preview: (hide)
0

answered Aug 18 '18

How to use float in this case my script is using float

    image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
    features = []

    # grab the dimensions and compute the center of the image
    (h, w) = image.shape[:2]
    (cX, cY) = (int(w * 0.5), int(h * 0.5))

    # divide the image into four rectangles/segments (top-left,
    # top-right, bottom-right, bottom-left)
    segments = [(0, cX, 0, cY), (cX, w, 0, cY), (cX, w, cY, h),
        (0, cX, cY, h)]

    # construct an elliptical mask representing the center of the
    # image
    (axesX, axesY) = (int(w * 0.75) / 2, int(h * 0.75) / 2)
    ellipMask = np.zeros(image.shape[:2], dtype = "uint8")
    cv2.ellipse(ellipMask, (cX, cY), (axesX, axesY), 0, 0, 360, 255, -1)
Preview: (hide)

Question Tools

Stats

Asked: Mar 28 '14

Seen: 8,848 times

Last updated: Aug 12 '14