import cv2
import numpy as np

img1 = cv2.imread('picture/img1.jpg', flags=cv2.IMREAD_GRAYSCALE)
img2 = cv2.imread('picture/img2.jpg', flags=cv2.IMREAD_GRAYSCALE)

ret, thresh = cv2.threshold(img1, 127, 255, 0)
ret, thresh2 = cv2.threshold(img2, 127, 255, 0)
im2, contours, hierarchy = cv2.findContours(thresh, 2, 1)
cnt1 = contours[0]
im2, contours, hierarchy = cv2.findContours(thresh2, 2, 1)
cnt2 = contours[0]

ret = cv2.matchShapes(cnt1, cnt2, 1, 0.0)
print(ret)
