1. 平移变换
rows, cols = img.shape[:2]
M = np.float32([[1, 0, 100], [0, 1, 50]])
res = cv.warpAffine(img, M, (cols, rows))
cv.warpAffine(图片源, 变换矩阵, 变换后图片大小)。平移是对象位置的移动。如果你知道在(x,y)方向的转变,使其为(tx,ty),可以创建转换矩阵
M = [ 1 0 t x 0 1 t y ] (1) M=\begin{bmatrix} 1&0&tx\\ 0&1&ty\\ \end{bmatrix}\tag{1} M=[1001txty](1)