So I have some code looking like this for a face recognition project I am trying to do
import cv2
import face_recognition
import matplotlib.pyplot as plt
import numpy as np
path = 'youtube_stuff2/'
vid = cv2.VideoCapture(path+'obama.webm')
obama= face_recognition.load_image_file(path+'obama.jpg')
obama_encodings = face_recognition.face_encodings(obama)[0]
all_encoding = [obama]
images = face_recognition.load_image_file(path+'obama.jpg')
locations = face_recognition.face_locations(images)
encodings = face_recognition.face_encodings(images)
#print(encodings.shape)
print(face_recognition.compare_faces([obama],encodings[0]))
Since they are both the same images I would expect a "True" result but instead I get this
ValueError: operands could not be broadcast together with shapes (1,1499,1200,3) (128,)
I don't understand why my encoding has a different shape given it is the same image. Any help on this would be appreciated. P.S the images is linked here
In this line
print(face_recognition.compare_faces([obama],encodings[0]))
use obama_encodings
instead of obama
.