def translate_image(image, translation):
'''
Translates the given image with the given translation vector.
'''
rows, cols, _ = np.atleast_3d(image).shape
trans_mat = np.array([[1, 0, translation[0]*cols], [0, 1, translation[1]*rows]])
return cv2.warpAffine(image, trans_mat, (cols, rows))
评论列表
文章目录