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)
posted @ 2020-11-03 22:04  疯狂列表推导式  阅读(536)  评论(0编辑  收藏  举报