【Python】图像识别的常用功能函数
目录
ROI 坐标和大小获取
ROI 坐标和大小获取
import cv2# 读取图片
image = cv2.imread('1.jpg')# 显示图片并选择ROI
roi = cv2.selectROI(image, fromCenter=False, showCrosshair=True)# 打印ROI坐标和大小
print(f"ROI: {roi}")# 显示选择的ROI区域
x, y, w, h = roi
roi_image = image[y:y+h, x:x+w]
cv2.imshow('ROI', roi_image)
cv2.waitKey(0)
cv2.destroyAllWindows()