Im usign python and opencv to get a image from the webcam, and I want to know how to draw a circle over my image, just a simple green circle with transparent fill
cv2.circle(img, center, radius, color, thickness=1, lineType=8, shift=0) → None
Draws a circle.
Parameters:
img (CvArr) – Image where the circle is drawn
center (CvPoint) – Center of the circle
radius (int) – Radius of the circle
color (CvScalar) – Circle color
thickness (int) – Thickness of the circle outline if positive, otherwise this indicates that a filled circle is to be drawn
lineType (int) – Type of the circle boundary, see Line description
shift (int) – Number of fractional bits in the center coordinates and radius value
Use "thickness" parameter for only the border.
Just an additional information:
The parameter "center" of OpenCV's drawing function cv2.circle() takes a tuple of two integers. The first is the width location and the second is the height location. This ordering is different from the usual array indexing. The following example demonstrates the issue.
import numpy as np
import cv2
height, width = 150, 200
img = np.zeros((height, width, 3), np.uint8)
img[:, :] = [255, 255, 255]
# Pixel position to draw at
row, col = 20, 100
# Draw a square with position 20, 100 as the top left corner
for i in range(row, 30):
for j in range(col, 110):
img[i, j] = [0, 0, 255]
# Will the following draw a circle at (20, 100)?
# Ans: No. It will draw at row index 100 and column index 20.
cv2.circle(img,(col, row), 5, (0,255,0), -1)
cv2.imwrite("square_circle_opencv.jpg", img)
try
cv2.circle(img, center, radius, color[, thickness[, lineType[, shift]]])
See the documentation for more details