I want to code a cat recognizer with OpenCV using the Python module face-recognition.
This code works for human faces, using haarcascade_frontalface_default.xml (this is the trained model).
imagePaths = list(paths.list_images("recognition/dataset"))
knownEncodings = []
knownNames = []
# For each image, we analyze the face on it
for (i, imagePath) in enumerate(imagePaths):
name = imagePath.split(os.path.sep)[-2]
image = cv2.imread(imagePath)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
boxes = face_recognition.face_locations(rgb, model="hog")
encodings = face_recognition.face_encodings(rgb, boxes)
for encoding in encodings:
knownEncodings.append(encoding)
knownNames.append(name)
data = {"encodings": knownEncodings, "names": knownNames}
# We save the data in a file
f = open("recognition/encodings.pickle", "wb")
f.write(pickle.dumps(data))
f.close()
I tried to use haarcascade_frontalcatface.xml, to recognize cats. I recorded my cats, but the recognition program didn't recognize any cat using the encodings.pickle. Python didn't throw any error. The program worked fine for humans.
Does the face_recognition module work for cats?
