判断两图片是否一样

import cv2
import numpy as np
try:
    image1 = cv2.imread('0.png')
    image2 = cv2.imread('0.png')
    diff = cv2.subtract(image1, image2)
    result = not np.any(diff)  # any()方法是查看两矩阵是否有一个对应元素相等
    if result is True:
        print('the screencap is same with the last')
except cv2.error:
    print('cv2.subtract encontered:' + str(cv2.error))

你可能感兴趣的:(判断两图片是否一样)