Face Recognition on BrainyPi
by dhruvarora561 in Circuits > Computers
238 Views, 3 Favorites, 0 Comments
Face Recognition on BrainyPi
- In recent years, face recognition technology has become increasingly popular and is being used in a variety of applications such as security systems, biometrics, and social media platforms. OpenCV, an open-source computer vision library, has made it possible to develop face recognition applications with ease.
- In this blog, we will explore the use of OpenCV for face recognition on a single board computer called BrainyPi. BrainyPi is a powerful, affordable, and compact computer that is ideal for developing projects that require image processing and machine learning capabilities.
- Face recognition using OpenCV and face recognition library in Python involves the following steps:
- Face detection: The first step in face recognition is to detect the face in the image. This is done using the Haar Cascade Classifier, which is a pre-trained classifier that can detect faces in an image. The classifier is trained on thousands of positive and negative images to accurately detect faces.
- Face alignment: Once the face is detected, it needs to be aligned in a standard format for further processing. This is done by locating the facial landmarks on the face, such as the eyes, nose, and mouth, and then applying an affine transformation to align the face.
- Feature extraction: Next, features are extracted from the aligned face. These features are unique to each face and are used to distinguish one face from another. The face recognition library uses deep neural networks to extract these features.
- Face matching: Finally, the extracted features are compared to a database of known faces to identify the person in the image. This is done using algorithms such as k-nearest neighbors or support vector machines.
- The source code contains three python files
- faceRecognition.py file is the main file of the program. When this file is run it opens up the camera and then tries to match the face in the camera to the faces stored the dataset.
- registerFace.py file is used to register the fave of the user. First the user has to enter their name and then stand in front of the camera and press space key to store the image.
- faceRecUtils.py file is where the actual recognition happens faceRecognition.py file calls the methods inside this file and then the image is passed through the recogniseFace function. Finally the output is passed to the faceRecognition.py file and then the output is displayed on the screen
Supplies
- Brainy Pi
- Keyboard
- Mouse
- Internet Connection
- Monitor
Installing Dependencies
- Start by cloning the repository as shown below
git clone https://github.com/dhruvarora561/brainypi-opencv-examples.git
- Change to directory `face-recognition`
cd face-recognition
- Now, we need to create a virtual environment
python -m venv venv
- Activating the virtual environment differs from windows to linux to mac os
cd venv/Scripts
activate
- We also need to install cmake before installing python packages
- To install cmake visit their website and download the cmake package for windows.
- Run the package and make sure to select the add to path option.
- Open up a terminal and check the installation of cmake
cmake --version
- Now, we will begin installation of dependencies
pip install -r requirements.txt
- Now, that we have installed all the required dependencies, we can now run the program
Running the Program
- In the face-recognition directory open up a terminal and type the following to run the program
python faceRecognition.py
- Give it a few seconds and it will start up your camera.
- To register your face press `space` key
- To exit out of the program press `esc` key
- Images are stored in the dataset folder of the program.
- The program identifies the person via the name of the image stored in the dataset folder.