Draw Ellipse on NumPy array and Image Using OpenCV Python

In Python OpenCV Tutorial, Explained How to put text and Ellipse over the image using python OpenCV cv2.ellipse() function?

Syntax: cv2. ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]])
Return : Image with ellipse

Parameters:

.   @param img Image.
.   @param center Center of the ellipse.
.   @param axes Half of the size of the ellipse main axes.
.   @param angle Ellipse rotation angle in degrees.
.   @param startAngle Starting angle of the elliptic arc in degrees.
.   @param endAngle Ending angle of the elliptic arc in degrees.
.   @param color Ellipse color.
.   @param thickness Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that
.   a filled ellipse sector is to be drawn.
.   @param lineType Type of the ellipse boundary. See #LineTypes
.   @param shift Number of fractional bits in the coordinates of the center and values of axes.

Draw Ellipse on NumPy array and Image

Draw Ellipse on Image

import cv2

img_path = r"C:\Users\kashz\AI Life\AI Projects - IAIP, PTs (Web + Channel)\02 OpenCV\000 opencv tutorial\data\images\adult-beautiful-beauty-1130624.jpg"

img = cv2.imread(img_path)

img_resize = cv2.resize(img, (1280, 720))

center = (500, 230)
axes = (100, 200)
angle = 30
startAngle = 0
endAngle = 360
color = (12,200,43)
thickness = 4

#ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]) -> img
cv2.ellipse(img_resize, center, axes, angle, startAngle, endAngle, color, thickness)

cv2.imshow("Model Image", img_resize)
cv2.waitKey(0)
cv2.destroyAllWindows()

Fill Ellipse

import cv2

img_path = r"C:\Users\kashz\AI Life\AI Projects - IAIP, PTs (Web + Channel)\02 OpenCV\000 opencv tutorial\data\images\adult-beautiful-beauty-1130624.jpg"

img = cv2.imread(img_path)

img_resize = cv2.resize(img, (1280, 720))

center = (500, 230)
axes = (100, 200)
angle = 30
startAngle = 0
endAngle = 360
color = (12,200,43)
thickness = -1

#ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]) -> img
cv2.ellipse(img_resize, center, axes, angle, startAngle, endAngle, color, thickness)

cv2.imshow("Model Image", img_resize)
cv2.waitKey(0)
cv2.destroyAllWindows()

Incomplete Ellipse Arc

import cv2

img_path = r"C:\Users\kashz\AI Life\AI Projects - IAIP, PTs (Web + Channel)\02 OpenCV\000 opencv tutorial\data\images\adult-beautiful-beauty-1130624.jpg"

img = cv2.imread(img_path)

img_resize = cv2.resize(img, (1280, 720))

center = (500, 230)
axes = (100, 200)
angle = 30
startAngle = 100
endAngle = 360
color = (12,200,43)
thickness = -1

#ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]) -> img
cv2.ellipse(img_resize, center, axes, angle, startAngle, endAngle, color, thickness)

cv2.imshow("Model Image", img_resize)
cv2.waitKey(0)
cv2.destroyAllWindows()

Incomplete Empty Ellipse Arc

import cv2

img_path = r"C:\Users\kashz\AI Life\AI Projects - IAIP, PTs (Web + Channel)\02 OpenCV\000 opencv tutorial\data\images\adult-beautiful-beauty-1130624.jpg"

img = cv2.imread(img_path)

img_resize = cv2.resize(img, (1280, 720))

center = (500, 230)
axes = (100, 200)
angle = 30
startAngle = 100
endAngle = 360
color = (12,200,43)
thickness = 33

#ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]) -> img
cv2.ellipse(img_resize, center, axes, angle, startAngle, endAngle, color, thickness)

cv2.imshow("Model Image", img_resize)
cv2.waitKey(0)
cv2.destroyAllWindows()

Ellipse And Text

### ELLIPS AND TEXT

import cv2

img_path = r"C:\Users\kashz\AI Life\AI Projects - IAIP, PTs (Web + Channel)\02 OpenCV\000 opencv tutorial\data\images\adult-beautiful-beauty-1130624.jpg"

img = cv2.imread(img_path)

img_resize = cv2.resize(img, (1280, 720))

center = (500, 230)
axes = (100,200)
angle = 30
startAngle = 0
endAngle = 340
color = (56,208,23)
thickness = 5

#ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]) -> img
cv2.ellipse(img_resize, center, axes, angle, startAngle, endAngle, color, thickness)

#putText(img, text, org, fontFace, fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]]) -> img
cv2.putText(img_resize, "Model Smile", (600, 280), cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, 2, (34,200,200), 3)

cv2.imshow("Model Image", img_resize)
cv2.waitKey(0)
cv2.destroyAllWindows()

Leave a Reply

Top