python-OpenCV-鼠标交互

2023-04-11 13:58:51

© Fu Xianjun. All Rights Reserved.

文章目录

一、使用步骤

1.引入库

代码如下:

import cv2

2.读入数据

代码如下:

def draw_circle(event, x, y, flags, param):
    if event == cv2.EVENT_LBUTTONDOWN:
        cv2.circle(img, center=(x,y),radius = 5,color=(0, 255, 0),thickness=-1)
    elif event == cv2.EVENT_RBUTTONDOWN:
        cir.circle(img, center=(x,y), radius=5,color=(0, 255, 0), thickness=1)

img = cv2.imread("yiqing.png")

cv2.nameWindow(winname='drawing')
cv2.setMpuseCallback('drawing', draw_circle)

while True:
    cv2.imshow('drawing',img)
    if cv2.waitKey(1) & OxFF == ord('q'):
        break
cv2.destroyAllWindows()
  • 作者:yk2000000
  • 原文链接:https://blog.csdn.net/yk2000000/article/details/118371479
    更新时间:2023-04-11 13:58:51