March 2019
Intermediate to advanced
538 pages
13h 38m
English
Thanks to OpenCV's FaceRecognizer class, we can identify the person in a photo simply by calling the FaceRecognizer::predict() function on a facial image as follows:
int identity = model->predict(preprocessedFace);
This identity value will be the label number that we originally used when collecting faces for training, for example, zero for the first person, one for the second person, and so on.
The problem with this identification is that it will always predict one of the given people, even if the input photo is of an unknown person, or of a car. It would still tell you which person is the most likely person in that photo, so it can be difficult to trust the result! The solution is ...