def _centre_crop_and_transform(self, input_img, scale=1.0, trans=False, vflip=False, hflip=False):
h, w = input_img.shape[:2]
cx = w // 2
cy = h // 2
crop_w, crop_h = utils.calc_crop_size(self.img_size[0], self.img_size[1], scale=scale)
input_img = utils.crop_center(input_img, cx, cy, crop_w, crop_h)
if trans:
input_img = cv2.transpose(input_img)
if hflip or vflip:
if hflip and vflip:
c = -1
else:
c = 0 if vflip else 1
input_img = cv2.flip(input_img, flipCode=c)
if scale != 1.0:
input_img = cv2.resize(input_img, self.img_size, interpolation=cv2.INTER_LINEAR)
return input_img
评论列表
文章目录