def resize_to_desired(input_img):
h = input_img.shape[0]
if h < 20: # pad the image to 20 or 21 pixels height if it is too short
border = math.ceil((20 - h) / 2)
new_img = cv2.copyMakeBorder(input_img, top=border, bottom=border, left=0, right=0,
borderType=cv2.BORDER_DEFAULT)
else:
new_img = input_img
return cv2.resize(new_img, (CLS_IMG_WIDTH, CLS_IMG_HEIGHT))
评论列表
文章目录