import os
import cv2
import numpy as np
for file in os.listdir(r'C:\autoMac\botu\stro2'):
img = cv2.imread(r'C:\autoMac\botu\stro2\{}'.format(file),0)
h,w = img.shape
max_h_w = max(w,h)
background = np.zeros((max_h_w,max_h_w))
background[0:h,(max_h_w//2 - w // 2):(max_h_w//2 - w // 2 + w)] = img
background = cv2.resize(background,(640,640))
cv2.imwrite(r'C:\autoMac\botu\trainbt\{}'.format(file),background)
python贴图
最新推荐文章于 2024-07-10 23:54:36 发布