def images_the_same(image1, image2):
"""
:param image1: path of image1
:param image2: path of image2
:return: True if images are the same, False if images are not the same
"""
im1 = cv.imread(image1)
im2 = cv.imread(image2)
if im1.shape != im2.shape:
return False
difference = cv.subtract(im1, im2)
b, g, r = cv.split(difference)
if cv.countNonZero(b) == 0 and cv.countNonZero(g) == 0 and cv.countNonZero(r) == 0:
return True
return False
print(images_the_same('cards/firstone.png', 'current_card.png')) # result = True
print(images_the_same('current_card.png', 'cards/firstone.png')) # result = False
How is it possible that the results are different for the first function call, while the second function call with different order shows a different result? It worked fine a few days ago. Is there something missing here? Is the function not implemented correctly?