Face Recognition and Identification Arduino Face I
Face Recognition and Identification Arduino Face I
by Yahiya Mulla
Facial recognition AKA face ID is one of the most step 3: Data collection
important feature on mobile phones nowadays.
Step 4: Training
So, I had a question "can I have a face id for my
Arduino project" and the answer is yes... step 5: Face recognition
Step 1: Access to webcam I will explain all the steps below. I hope that this will
help you out.
step 2: Face identi cation.
https://youtu.be/hldWNSvZf1Q
Face Recognition and Identification | Arduino Face ID Using OpenCV Python and Arduino.: Page 1
The 1st step for facial recognition was to have access If Opencv is installed on your computer then you are
to a camera or a computer vision. Since India is under good to go. If not then follow this step.
lockdown the cheapest solution which I found was to
use my computers webcam to which I had access with open command prompt and type "pip install opencv".
a python program using openCV module.
Warning: You may get an error as "'pip' is not
You might be thinking what is OpenCV, isn't it? recognized as an internal or external command". for
which You need to add the path of your pip
OpenCV (Open Source Computer Vision Library) is an installation to your PATH system variable. Go through
open-source computer vision and machine learning this post it may help you.
software library. OpenCV was built to provide a
common infrastructure for computer vision https://stackover ow.com/questions/23708898/pip-i...
applications and to accelerate the use of machine
perception in commercial products. Once OpenCV is installed we are good to go... To check
if its properly installed open your Python interpreter There you go, Now you have access to the webcam.
and import the library. See the image above that Well done. let us proceed to step 2.
should be your output.
Download
https://www.instructables.com/ORIG/FEX/8IUD/KBGQGCYL/FEX8IUDKBGQGCYL.py
…
with the help of the same OpenCV module, we have Download "haarcascade_frontalface_default" and
to identify whether there is a face on the video stream place it in the main project folder.
or not.
Download "Face_identi cation.py" and place it in the
OpenCV provides a training method or pre-trained main project folder. All the explanation is provided in
models called as Cascade Classi er. The pre-trained it.
models are located in the data folder in the OpenCV
installation. I'm providing that le just download it Now you can identify the faces in a video stream. So
and place it in your project folder. The folder where let's proceed to step 3.
the "AccessTo_webcam.py" le is stored. If you have
not created one then do it.
Face Recognition and Identification | Arduino Face ID Using OpenCV Python and Arduino.: Page 2
Download
https://www.instructables.com/ORIG/FPA/8EJC/KBGQGDHL/FPA8EJCKBGQGDHL.py
…
Download
https://www.instructables.com/ORIG/FQS/81KL/KBGQGD5N/FQS81KLKBGQGD5N.xml
…
To recognize the faces we need to train our python Now go ahead create your own folders and name
program. For which we need some data. them.
Data collection is rather the easiest step in this Once the folders are created then start collecting
project. create a folder named "image_data" in your images of that speci c person. I recommend
main project folder. Inside the "image_data" folder collecting nearly about 20 images per person. You can
create some additional folders with the person's also add more images but see to it that data collected
name, where we will store the data. for example: for all the persons contains the same number of
images. It helps to provide accuracy.
In the "image_data" folder I have created two more
folders named "HRK" and "Yahiya". as shown in the that's it now let's move on to step 4.
above image.
Face Recognition and Identification | Arduino Face ID Using OpenCV Python and Arduino.: Page 3
Step 4: Training
In brief, we will go through all the folders and images and name will be X itself. We load the image to nd
which are present in the "image_data" folder and his face i.e Region of interest and append the data to
create a dictionary that will contain the label ID and a list.
the corresponding name. Simultaneously we will load
the image to detect the face in each and every image similar steps will be followed for person Y. And nally,
which we call it "Region of Interest" and create a ".yml" we will create a ".yml" le.
le which contains that information.
Download the "face_trainer.py" le and place it in the
Assuming that you have data collected for person X main project folder. All the necessary explanation is
and Y. provided in that le itself.
we will label person X as 1 which will be his label ID When you run this program it will go through all the
images and create two les named "labels.pickle" and so let's proceed to step 5.
"trainner.yml". Now you have trained your own model.
Download
https://www.instructables.com/ORIG/FXX/L5LF/KBGQGKN3/FXXL5LFKBGQGKN3.py
…
If you have gone through all the steps properly then data is matched then we say that the person is
you may have created your own trained data. Now we recognized it is just that simple...
will use that data for face recognition.
Download "face_recognise.py" and run it. All the
Basically we will load our trained models into the necessary information is provided in it. Now your face
python le, Access our webcam, and identify Faces in may have been recognized. if the accuracy is not good
the video stream and do a comparison or prediction then try updating the data. if you are all good to go
between the current face which is identi ed in the then lets proceed to step 6/
video stream, and the model which was trained. if the
Download
https://www.instructables.com/ORIG/F4Q/E4A0/KBGQGM2O/F4QE4A0KBGQGM2O.py
…
Face Recognition and Identification | Arduino Face ID Using OpenCV Python and Arduino.: Page 4
Step 6: Programming Arduino
The last and the nal step is programming Arduino, then the label ID provided is 2. Once label ID is 2 I will
And to provide a mode of communication between send '1' as the serial data to my Arduino. Which will
python and Arduino. For communication, I used turn on my LED chaser circuit. If label ID is other than
"Serial Communication". Go through the video which I 2 then i will send '0' as the serial data, which will turn
have linked above to nd how Serial Communication o my LED chaser Circuit.
works and to establish one.You will nd all the
required les in the video description. Download the "ard_chaser.ino" le. It is a simple LED
chaser program that uses serial communication.
If you have gone through the video then let me
explain to you what I did. When my face is recognized Simillerly download "face_recogniser1.py" that will
establish the serial communication between Arduino related to python and Arduino. Share this if you liked
and the python program. it. Keep supporting.
There you go. I hope that you have learned something Thank you.
new. Subscribe to my youtube channel for more stu
https://youtu.be/j6qkLfTKdpg
Download
https://www.instructables.com/ORIG/FRR/24RL/KBQIL9YV/FRR24RLKBQIL9YV.ino
…
Download
https://www.instructables.com/ORIG/FTV/C805/KBQILA4N/FTVC805KBQILA4N.py
…
Very interesting, Yahia. I was looking for something like that about AI. Thanks.
Your welcome, Amedo1. Check my YouTube channel ones. It's just started but I will post stuff
related to python, Arduino and electronics.
Face Recognition and Identification | Arduino Face ID Using OpenCV Python and Arduino.: Page 5