def cropImg(img,oriRio=0.24/0.36):
#oriImg = cv2.imread(img)
#img = np.swapaxes(img,0,2)
h = img.shape[0]
w = img.shape[1]
# from the middle of the long side (the middle two points)to
# crop based on the shorter side, then according to the ucf101
# ratio to crop the other side
if h <= w * oriRio:
crop_ws = w/2-1-int(h/(oriRio*2))
crop_we = w/2+int(h/(oriRio*2))
subImg = img[:,crop_ws:crop_we,:]
else:
crop_hs = h/2-1-int(w*(oriRio/2))
crop_he = h/2+int(w*(oriRio/2))
subImg = img[crop_hs:crop_he,:,:]
return subImg
评论列表
文章目录