Существует несколько способов решения этой задачи с использованием различных библиотек Python, включая numpy & math, imagehash и pillow.
Вот один способ (который я изменил, чтобы сравнить только 2 изображения).
# This module is used to load images
from PIL import Image
# This module contains a number of arithmetical image operations
from PIL import ImageChops
def image_pixel_differences(base_image, compare_image):
"""
Calculates the bounding box of the non-zero regions in the image.
:param base_image: target image to find
:param compare_image: set of images containing the target image
:return: The bounding box is returned as a 4-tuple defining the
left, upper, right, and lower pixel coordinate. If the image
is completely empty, this method returns None.
"""
# Returns the absolute value of the pixel-by-pixel
# difference between two images.
diff = ImageChops.difference(base_image, compare_image)
if diff.getbbox():
return False
else:
return True
base_image = Image.open('image01.jpeg')
compare_image = Image.open('image02.jpeg')
results = image_pixel_differences (base_image, compare_image)
У меня есть дополнительные примеры, поэтому, пожалуйста, дайте мне знать, если этот не работает для вас.