In Python OpenCV Tutorial, Explained How to put text and Circle over the image using python OpenCV?
Syntax: cv2.circle(img, center, radius, color[, thickness[, lineType[, shift]]])
. The function cv::circle draws a simple or filled circle with a given center and radius. . @param img Image where the circle is drawn. . @param center Center of the circle. . @param radius Radius of the circle. . @param color Circle color. . @param thickness Thickness of the circle outline, if positive. Negative values, like #FILLED, . mean that a filled circle is to be drawn. . @param lineType Type of the circle boundary. See #LineTypes . @param shift Number of fractional bits in the coordinates of the center and in the radius value.
Draw Circle using OpenCV on NumPy array or Image
Draw Circle on Image
#Draw Circle 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-826349.jpg"
image = cv2.imread(img_path)
img_resize = cv2.resize(image, (1280,720))
center = (600, 250)
radius = 130
color = (23,220, 75)
thickness = 3
lineType = cv2.LINE_8
shift = 0
#circle(img, center, radius, color[, thickness[, lineType[, shift]]]) -> img
cv2.circle(img_resize, center, radius, color, thickness, lineType, shift)
cv2.imshow("Model Image", img_resize)
cv2.waitKey(0)
cv2.destroyAllWindows()
Fill Circle on Image
#fill circle 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-826349.jpg"
image = cv2.imread(img_path)
img_resize = cv2.resize(image, (1280,720))
center = (600, 250)
radius = 130
color = (23,220, 75)
thickness = -1 #fill circle on Image
lineType = cv2.LINE_8
shift = 0
#circle(img, center, radius, color[, thickness[, lineType[, shift]]]) -> img
cv2.circle(img_resize, center, radius, color, thickness, lineType, shift)
cv2.imshow("Model Image", img_resize)
cv2.waitKey(0)
cv2.destroyAllWindows()
Draw 2 Circles
#Draw 2 Circles 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-826349.jpg"
image = cv2.imread(img_path)
img_resize = cv2.resize(image, (1280,720))
##### Draw 2 Circles on Image
center = (600, 250)
radius = 130
color = (23,220, 75)
thickness = 5
lineType = cv2.LINE_8
shift = 0
#circle(img, center, radius, color[, thickness[, lineType[, shift]]]) -> img
cv2.circle(img_resize, center, radius, color, thickness, lineType, shift)
center2 = (640, 450)
radius2 = 80
color2 = (36,90,10)
cv2.circle(img_resize, center2, radius2, color2, thickness, lineType, shift)
cv2.imshow("Model Image", img_resize)
cv2.waitKey(0)
cv2.destroyAllWindows()
Draw Multiple Circles & Text
#Draw Multiple Circles & Text on Image
img_path = r"C:\Users\kashz\AI Life\AI Projects - IAIP, PTs (Web + Channel)\02 OpenCV\000 opencv tutorial\data\images\adult-beautiful-beauty-826349.jpg"
image = cv2.imread(img_path)
img_resize = cv2.resize(image, (1280,720))
#circle(img, center, radius, color[, thickness[, lineType[, shift]]])
center = (600, 250)
radius = 130
color = (28,68,235)
thickness = 6
linetype = cv2.LINE_4
shift = 0
color2 = (2555,0,0)
radius2 = 120
color3 = (0,255,0)
radius3 = 110
color4 = (0,0,255)
radius4 = 100
color5 = (85,87,93)
radius5 = 90
color6 = (65,207,203)
radius6 = 80
color7 = (65,207,203)
radius7 = 80
cv2.circle(img_resize, center, radius, color, thickness, linetype, shift)
cv2.circle(img_resize, center, radius2, color2, thickness, linetype, shift)
cv2.circle(img_resize, center, radius3, color3, thickness, linetype, shift)
cv2.circle(img_resize, center, radius4, color4, thickness, linetype, shift)
cv2.circle(img_resize, center, radius5, color5, thickness, linetype, shift)
cv2.circle(img_resize, center, radius6, color6, thickness, linetype, shift)
cv2.circle(img_resize, center, radius7, color7, thickness, linetype, shift)
#putText(img, text, org, fontFace, fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]]) -> img
cv2.putText(img_resize, "Model Face", (410, 110), cv2.FONT_HERSHEY_COMPLEX_SMALL, 3, (0,255,0), 3)
cv2.imshow("Model Image", img_resize)
cv2.waitKey(0)
cv2.destroyAllWindows()