话不多说,上代码,看结果。
import cv2 import numpy as np def draw_Circle(event, x, y, flags, param): if event == cv2.EVENT_LBUTTONDOWN: cv2.circle(img, (x, y), 50, [255, 0, 0], 3) # 蓝色 if event == cv2.EVENT_LBUTTONUP: cv2.circle(img, (x, y), 50, [0, 0, 0], 3) # 黑色 if event == cv2.EVENT_RBUTTONUP: cv2.circle(img, (x, y), 50, [0, 0, 255], 3) # 红色 if event == cv2.EVENT_RBUTTONDOWN: cv2.circle(img, (x, y), 50, [0, 255, 255], 3) # 黄色 if event == cv2.EVENT_MOUSEWHEEL: cv2.circle(img, (x, y), 50, [0, 255, 0], 3) # 绿色 img = np.ones((500, 500, 3), np.uint8) img = img * 255 cv2.namedWindow('img') cv2.setMouseCallback('img', draw_Circle) while 1: cv2.imshow("img", img) if cv2.waitKey(10) & 0xFF == 27: break cv2.destroyAllWindows() # 销毁所有窗口
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)