Face detection is getting important in many places. Knowing the importance and relevance,Almost all major industry vendors are doing something or other in this field.
Raspberry Pi with Camera connection kit
OpenCV libarary
Pre-trained classifier files for face and eyes
Putty for connecting Raspi to your laptop (or Monitor and keyboard to work on Raspi directly)
Camera connection kit:
Camera module need to connected to raspi using flex cable
Setting up the environment raspberry pi :
Required libraries need to be installed by executing below commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Confirm camera is working or not by executing this command
sudo raspistill -o filename.jpg
Setting the coding environment:
Python code is used to build the face detection which uses Haar cascade classifier (pre -trained)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Now run the python code, `sudo python facedetect.py`
Result image will be stored in the file.
After identifying /detecting the face, we can compare with known face DB.
Face Recognition can be used in numerous ways as we can provide contextual information to the user
1. Preferred treatment to customer (loyal or otherwise) depending on the customer profile
2. Warning to the user if he enters dangerZone or unauthorized zone
3. Can give specific treatment in case of senior citizens or kids
If one does not have camera , still he can run this program using the stock images from gallery ( in stead of live source)
Tweaked code for that case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thanks Siva – it works. Please can you publish more such simple tutorials so beginners like me can benefit