diff --git a/test/2024,9,23/mouse_draw_circle.jpg b/test/2024,9,23/mouse_draw_circle.jpg index d9c356f..b6c1086 100644 Binary files a/test/2024,9,23/mouse_draw_circle.jpg and b/test/2024,9,23/mouse_draw_circle.jpg differ diff --git a/test/2024,9,23/mouse_event.py b/test/2024,9,23/mouse_event.py index 6c90d0b..44aacf0 100644 --- a/test/2024,9,23/mouse_event.py +++ b/test/2024,9,23/mouse_event.py @@ -1,21 +1,25 @@ +from pickletools import uint8 + import cv2 as cv import numpy as np -img=np.ones((512,512)) +img = np.ones((512, 512, 3), dtype=np.uint8) * 255 + + +def draw_circle(event, x, y, flags, param): + if event == cv.EVENT_LBUTTONDOWN: + cv.circle(img, (x, y), 20, (0, 0, 0), -1) -def draw_circle(event,x,y,flags,param): - if event==cv.EVENT_LBUTTONDOWN: - cv.circle(img,(x,y),20,0,-1) cv.namedWindow('show_img') -cv.setMouseCallback('show_img',draw_circle) -while(1): - cv.imshow('show_img',img) - pressedKey=cv.waitKey(5) - if pressedKey==ord('q'): +cv.setMouseCallback('show_img', draw_circle) +while (1): + cv.imshow('show_img', img) + pressedKey = cv.waitKey(5) + if pressedKey == ord('q'): break - elif pressedKey==ord('s'): - cv.imwrite("mouse_draw_circle.jpg",img); + elif pressedKey == ord('s'): + cv.imwrite("mouse_draw_circle.jpg", img); print("save success") -cv.destroyAllWindows() \ No newline at end of file +cv.destroyAllWindows()