I was able to extract all 8 symbols from each card in the Double\Spot It game. Now I’m trying and can’t determine which symbol is common to both cards (every two cards have one common symbol that can appear at different angles and sizes) I tried to compare all symbols using MSE and rotations but the results are not correct in most cases.
In the picture for example the dragon is the same symbol between the two cards but the result returned a dolphin and a soul key (marked in green)
def MSE(img1, img2):
squared_diff = (img1 -img2) ** 2
summed = np.sum(squared_diff)
num_pix = img1.shape[0] * img1.shape[1] #img1 and 2 should have same shape
err = summed / num_pix
return err
def match_roteted(img1, img2):
angles = [x * 15 for x in range(1, 360 // 15)]
img2_overlay = overlay_image(img2)
min_score = 99999
for angle in angles:
rotated = rotate_image(img1, angle)
img1_overlay = overlay_image(rotated)
score = MSE(img1_overlay, img2_overlay)
if score < min_score:
min_score = score
return min_score