cv2抠图示例

import cv2

# 读取图片
img = cv2.imread('demo.png')

# h、w为想要截取的图片大小
h, w = 35, 170
# 坐标
x, y= 500, 425

targetImg = img[(y):(y + h), (x):(x + w)]
cv2.imwrite('targetImg.png', targetImg)
原文地址:https://www.cnblogs.com/hui-code/p/13922879.html