赞
踩
- import cv2
-
- import numpy as np
-
- image1 = cv2.imread('A.jpg')
-
- image2 = cv2.imread('B.jpg')
- difference = cv2.subtract(image1, image2)
- result = not np.any(difference) #if difference is all zeros it will return False
-
-
- if result is True:
- print("两张图片一样")
- else:
- cv2.imwrite("result.jpg", difference)
-
- print ("两张图片不一样")
比较的原图
代码运行结果:
比较两张相同的图:
代码运行结果:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。