First of all you have to install the prerequisite software as described in this post. Keep in mind that you need to install OpenCV with contrib module to use face recognition APIs otherwise you will get an error like this: AttributeError: module 'cv2.cv2' has no attribute 'face'
Download the PyFaceRec repository in a directory of your choice. In the examples we assume you have downloaded it into C:\PyFaceRec.
The example described here is located in the SimpleFaceRecognition folder and attempt to identify faces of the members of the famous pop group Abba.
The faces to be detected are located into the data sub-directory.
While the faces database used to train the algorithm is located in the facesdb sub-directory.
Note that all the images have a resolution of 200x200 pixels. This is required by the algorithm.
Now lets try to run the example. Open a command Prompt, move into he SimpleFaceDetection folder an run the sample script as follows.
cd C:\PyFaceRec\SimpleFaceRecognition python simple_face_recognition.py
You should get an output like this.
After having loaded the images from the training database, the program shows you the best match found for each face in the data folder. You can see that each face has been correctly identified.
The OpenCV library provides different algorithms for face recognition. Try yourself to change algorithm used by un-commenting a different line in the simple_face_recognition.py script.
recognizer = cv2.face.createFisherFaceRecognizer() #recognizer = cv2.face.createEigenFaceRecognizer() #recognizer = cv2.face.createLBPHFaceRecognizer()
You will see that other algorithms provide non-optimal results. This is not always true and really depends on the data you are working with.
Another important thing is that for a correct face detection both the face to be recognized and the faces used for training should have similar lighting conditions. This simple rule is clearly not true in our sample. That's why the distance is so high denoting a low accuracy of the detection.
can you please help me! i have this error
ReplyDeleteFile "simple_face_recognition.py", line 58, in
recognizer = cv2.face.createFisherFaceRecognizer()
AttributeError: 'module' object has no attribute 'face'
The methods names have been replaced in newer versions. The new methods are:
Deleterecognizer = cv2.face.EigenFaceRecognizer_create()
recognizer = cv2.face.FisherFaceRecognizer_create()
recognizer = cv2.face.LBPHFaceRecognizer_create()
Thank you for sharing, permission to learn the code
ReplyDeleteAttention! The create methods have been replaced in a newer version.
ReplyDeleteThe current method names are:
recognizer = cv2.face.EigenFaceRecognizer_create()
recognizer = cv2.face.FisherFaceRecognizer_create()
recognizer = cv2.face.LBPHFaceRecognizer_create()
But I still getting the error
DeletePrint media is being challenged by its electronic counterpart. But there are several unique advantages that help both the mediums to create a niche place in the media industry.
ReplyDeleteafp viewer online
Did you realize there's a 12 word phrase you can communicate to your man... that will trigger intense feelings of love and impulsive attraction for you buried inside his chest?
ReplyDeleteBecause hidden in these 12 words is a "secret signal" that triggers a man's impulse to love, worship and look after you with all his heart...
12 Words That Fuel A Man's Desire Impulse
This impulse is so hardwired into a man's genetics that it will drive him to work harder than ever before to to be the best lover he can be.
In fact, triggering this dominant impulse is so essential to having the best ever relationship with your man that the moment you send your man a "Secret Signal"...
...You will instantly notice him expose his mind and heart for you in such a way he's never experienced before and he'll see you as the one and only woman in the galaxy who has ever truly fascinated him.