I am trying to draw an arc using Open CV, using cv2.ellipse function
I tried reading the documentation for the same, but I m finding it very confusing. It is an arc in my case so axes_x and axes_y are same, i.e the radius. What should be my axis, In which direction should I calculate the Start and the End angle? And what is this angle of rotation?
Given is the function -
cv2.ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]])
import cv2
import numpy as np
def create_blank(height, width, color):
blank_image = np.zeros((int(height), int(width), 3), np.uint8)
blank_image[:, :] = color
return blank_image
def draw_arc(image):
height, width = image.shape[0:2]
# Ellipse parameters
radius = 100
center = (width / 2, height/2)
axes = (radius, radius)
angle = 0
startAngle = 135
endAngle = 180
cv2.line(image, (0, 150), (300, 150), (0, 0, 0), 2, cv2.CV_AA)
cv2.line(image, (150, 0), (150, 300), (0, 0, 0), 2, cv2.CV_AA)
cv2.ellipse(image, center, axes, angle, startAngle, endAngle, (0, 0, 0), 2, cv2.CV_AA)
cv2.imshow("ellipse", image)
# Create new blank 300x150 white image
width, height = 300, 300
image = create_blank(width, height, color=WHITE)
draw_arc(image)
cv2.waitKey(0)
cv2.destroyAllWindows()
When my startAngle is 135 and endAngle is 180, the result looks like
whereas when the startAngle is 0 and endAngle is 90, the result looks like
So this makes it confusing, in which direction is the arc rotating.