python 判断 图片是否相同
二、
import cv2
import numpy as np
image1 = cv2.imread("1.png")
image2 = cv2.imread("22.png")
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 ("两张图片不一样")
结果改一下:
diff = cv2.subtract(preFrame, frame2)
if np.max(diff)<10:
print('diff<10', self.cam_no,np.max(diff))
return True
if not np.any(diff): # 判断为图片相同
return True
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/79222991
- 点赞
- 收藏
- 关注作者
评论(0)