Reptile pictures from the calculated two-validation (I.)

A. Figure

Calculating the distance of these two pictures

II. Computing code

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

III. Precautions

cv2.imread中的参数绝对不能有中文路径

Guess you like

Origin www.cnblogs.com/pythonywy/p/12141648.html