From 667dc803aac9186df2eb20e47a83a544f8e791ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=A1=E5=9D=82=E6=98=B4?= Date: Mon, 23 Sep 2024 21:48:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/2024,9,23/mouse_event.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/2024,9,23/mouse_event.py b/test/2024,9,23/mouse_event.py index 44aacf0..9fc160a 100644 --- a/test/2024,9,23/mouse_event.py +++ b/test/2024,9,23/mouse_event.py @@ -2,17 +2,18 @@ from pickletools import uint8 import cv2 as cv import numpy as np - +# setup a write 3 channel image img = np.ones((512, 512, 3), dtype=np.uint8) * 255 - +# define callback function def draw_circle(event, x, y, flags, param): if event == cv.EVENT_LBUTTONDOWN: + # draw a black 20px radius circle on img cv.circle(img, (x, y), 20, (0, 0, 0), -1) - +# setup a window named 'show_img' cv.namedWindow('show_img') - +# set a mouse callback cv.setMouseCallback('show_img', draw_circle) while (1): cv.imshow('show_img', img)