img = cv2.imread(file) # BGR
读取图片
cv2.imwrite(file, img[ymin:ymax, xmin:xmax])
保存图片
cv2.setNumThreads(0)
禁用线程优化
im = cv2.resize(cutout, (224, 224)) # BGR
图像缩放,采用双线性插值
cv2.rectangle(img, c1, c2, color, thickness=tl, lineType=cv2.LINE_AA)
画一个简单矩形
cv2.rectangle(mosaic, (block_x, block_y), (block_x + w, block_y + h), (255, 255, 255), thickness=3)
t_size = cv2.getTextSize(label, 0, fontScale=tl / 3, thickness=tf)[0]
计算文本尺寸
cv2.putText(img, label, (c1[0], c1[1] - 2), 0, tl / 3, [225, 255, 255], thickness=tf, lineType=cv2.LINE_AA)
绘制文本
self.cap = cv2.VideoCapture(path) # 初始化视频对象
视频,可以是路径,可以是摄像头
self.nframes = int(self.ca