一.图
二.计算代码
import cv2 import numpy as np def get_image_deviation(): ''' 计算slideimg.png 与 slideimg.png 位移的距离 ''' print(sys.path) slideimg = cv2.imread('图片路径1') bgimg = cv2.imread(f'图片路径2') result = cv2.matchtemplate(slideimg, bgimg, cv2.tm_ccoeff_normed) y, x = np.unravel_index(result.argmax(), result.shape) return x
三.注意点
cv2.imread中的参数绝对不能有中文路径