python opencv 画点获取外接矩形

目录

打点就行:

选多个点:


打点就行:


import cv2

# 定义全局变量,存储鼠标选择的点坐标
point = []

# 定义鼠标事件回调函数
def select_point(event, x, y, flags, param):
    global point

    if flags == cv2.EVENT_FLAG_RBUTTON:
        point = []
        cv2.imshow('image', img)
    if event == cv2.EVENT_LBUTTONDOWN:
        point = [x, y]

    elif event == cv2.EVENT_MOUSEMOVE:
        img_temp = img.copy()
        if len(point) > 0:
            cv2.rec

你可能感兴趣的:(python宝典,opencv,python,计算机视觉)