You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
417 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import cv2 as cv
import numpy as np
def panning(image_path,x,y):
img = cv.imread(image_path)
height, width, channel = img.shape
# 构建移动矩阵,x轴移 dx 个像素y轴移 dy 个像素
dx = int(x)
dy = int(y)
M = np.float32([[1, 0, dx], [0, 1, dy]])
img = cv.warpAffine(img, M, (width, height))
cv.imshow('result',img)
cv.waitKey(0)
cv.destroyAllWindows()