import Read_RectTXT
import numpy as np
import torchvision.transforms as transforms
import cv2 as cv
filename = 'DATA/groundtruth_rect.txt'
rect = Read_RectTXT.Read_RectTXT(filename)
img = cv.imread('DATA/img/.jpg')
a = rect[0,0]
b = rect[0,1]
c = rect[0,0]+rect[0,2]
d = rect[0,1]+rect[0,3]
# cv.rectangle(img, (a, b), (c, d), (0, 255, 0), 4)# cv2.rectangle(img, 左上角,右下角,color,宽度)
# font = cv.FONT_HERSHEY_SIMPLEX
# text = '001'
# cv.putText(img, text, (50, 50), font, 1, (0, 0, 255), 1)
# cv.imwrite('criterion.jpg', img)
cv.imwrite('criterion.jpg', img[b:d,a:c])
python opencv图像裁切与保存(标注)代码
最新推荐文章于 2023-04-21 14:33:51 发布