The next step for my IOT project is to use facial recognition so that the Raspberry P can decide whether or not to alert the home owner.
I'll use OpenCV for this part. OpenCV is a very capable free package for computer vision and imaging.
OpenCV can be installed for Python and comes in four different options:
- Main modules: opencv-python
- Main modules with extra modules such as contributions from the opencv community: opencv-contrib-python
- Headless mode (no GUI modules): opencv-python-headless
- Headless mode with extra modules: opencv-contrib-python-headless
As I want to use it in a headless Raspberry Pi later, I'll go for the first option for development and the fourth option for deployment.
Detecting a face using openCv is a two step process:
1. Detect the faces in a picture
2. Identify a face from step 1. That will require a training set of some images of the person that shall be identified.
Face Detecton
OpenCV is using Haar Cascades to detect various objects such as faces, eyes, mouths and license plates for example. The models are available as xml files at the OpenCV Github repository and no machine learning training will be necessary for this step.
After downloading the file haarcascade_frontalcatface to a local folder, my script will apply the Haar cascade model to a webcam session:
The Haar cascade algorithm is quite sensitive to noise. In the image below, five faces were detected, but only one face was authentic.
In the right region, some false faces were detected. |
No comments:
Post a Comment