import cv2
import numpyas np
imgfile1="e:\dog.jpg"
imgfile2="e:\dog2.jpg"
img1=cv2.imread(imgfile1)
img2=cv2.imread(imgfile2)
diff=cv2.subtract(img1,img2)
result=not np.any(diff)
if resultis True:
print("两张图片一样")
cv2.namedWindow("小狗图片")
cv2.imshow("小狗图片",img1)
cv2.waitKey(0)
cv2.destroyAllWindows()
else:
print("两张图片不一样")