def imcv2_affine_trans(im):
# Scale and translate
h, w, c = im.shape
scale = np.random.uniform() / 10. + 1.
max_offx = (scale - 1.) * w
max_offy = (scale - 1.) * h
offx = int(np.random.uniform() * max_offx)
offy = int(np.random.uniform() * max_offy)
im = cv2.resize(im, (0, 0), fx=scale, fy=scale)
im = im[offy: (offy + h), offx: (offx + w)]
flip = np.random.uniform() > 0.5
if flip:
im = cv2.flip(im, 1)
return im, [scale, [offx, offy], flip]
评论列表
文章目录