添加注释

This commit is contained in:
2024-09-23 21:48:52 +08:00
parent 75018880b4
commit 667dc803aa
+5 -4
View File
@@ -2,17 +2,18 @@ from pickletools import uint8
import cv2 as cv import cv2 as cv
import numpy as np import numpy as np
# setup a write 3 channel image
img = np.ones((512, 512, 3), dtype=np.uint8) * 255 img = np.ones((512, 512, 3), dtype=np.uint8) * 255
# define callback function
def draw_circle(event, x, y, flags, param): def draw_circle(event, x, y, flags, param):
if event == cv.EVENT_LBUTTONDOWN: if event == cv.EVENT_LBUTTONDOWN:
# draw a black 20px radius circle on img
cv.circle(img, (x, y), 20, (0, 0, 0), -1) cv.circle(img, (x, y), 20, (0, 0, 0), -1)
# setup a window named 'show_img'
cv.namedWindow('show_img') cv.namedWindow('show_img')
# set a mouse callback
cv.setMouseCallback('show_img', draw_circle) cv.setMouseCallback('show_img', draw_circle)
while (1): while (1):
cv.imshow('show_img', img) cv.imshow('show_img', img)