1.3 Solution (Methodology used)
1.4 Proposed Algorithm and Implementation
1.5 Code Implementation
This chapter gives a brief introduction to the proposed system and the report. Here we will discuss the origin and background of the problem.
Recognizing a Face is a very important task for a camera surveillance-based security system. We can extract the face from an image using computer vision techniques and then use a library to recognize the Face.
When we talk about AI, computer vision is definitely one of the top applications in people’s minds. Hype aside, I have always been fascinated by it because it pertains to human sight, arguably the most important human sense organ.
· Variation in illumination.
· Variation in expression.
· Similar Faces
· Image Resolution
· Pose variation
1.3 Solution (Methodology Used)
LBPH is one of the widely used computer vision applications. It makes use of various methods like object detection, OCR, segmentation, etc. Hardware, requires a camera and a good GPU, CPU, and Arduino UNO. To make it simple this blog post will focus on a two-step process.
- Detection: Firstly, an image or a frame of the video sequence is passed to the detection algorithm from a camera or an already stored file, which detects the face and returns the bounding box location of that face.
2. Recognition: The LBPH is applied to the detected face for recognition. The output can be stored in a database or can be plotted on the image for visualization.
3. Sending Information to Arduino UNO: In this, we send a signal to the servo motor so that our gate opens.
1.4 Code Implementation
Step1: Face Detection for data
We will detect our face using the LBPH algorithm.
The local Binary Patterns Histogram algorithm was proposed in 2006. It is based on a local binary operator. It is widely used in facial recognition due to its computational simplicity and discriminative power.
The steps involved to achieve this are:
· creating dataset
· face acquisition
· feature extraction
Working of LBPH (Easy Explanation):
The LBP feature vector, in its simplest form, is created in the following manner:
· Divide the examined window into cells (e.g. 16x16 pixels for each cell).
· For each pixel in a cell, compare the pixel to each of its 8 neighbors (on its left-top, left-middle, left-bottom, right-top, etc.). Follow the pixels along a circle, i.e. clockwise or counterclockwise.
· Where the center pixel’s value is greater than the neighbor’s value, write “0”. Otherwise, write “1”. This gives an 8-digit binary number (which is usually converted to decimal for convenience).
· Compute the histogram, over the cell, of the frequency of each “number” occurring (i.e., each combination of which pixels are smaller and which are greater than the center). This histogram can be seen as a 256-dimensional feature vector.
· Optionally normalize the histogram.
· Concatenate (normalized) histograms of all cells. This gives a feature vector for the entire window.
Our data looks like this
Similarly, We have used the LBPH to Detect the face and collect our training data, and here’s how it worked out for us!!
As we can see above our LBPH model is Doing good Work, Now let’s move to the next step.
Step2: The training model
Now here we are using LBPH to train our model.
This is done by the data we have collected as shown above.
It takes data from the location we mentioned in the code and trains the model accordingly.
Step3: Saving Our model
By this, we save our model in the jayesh_model so that we can call our model anywhere we want to use it
Step4: Building connection between Arduino UNO and Python ML code
1)First download Arduino IDE: https://www.arduino.cc/en/software
2)Download pyfirmata: This is the library to work on Arduino with python code.
To install it check this link: https://pypi.org/project/pyFirmata/
3)Connecting Arduino UNO with Laptop USB port :
4) Then open Arduino IDE and select the USB port which it is showing :
5) Then select this setting from the file:
6) Then without changing anything upload this code to your Arduino UNO:
Now we are ready to use our Arduino for python coding.
Step5: Now building the connection between the servo motor and Arduino UNO
- Connecting servo motor to Arduino
See in this image we connected three wires to the servo motor.
2) Now here see yellow dots and the color of the wire we have connected to the board.
Yellow wire => №2
Black wire => GND
Orange wire => 5V
Step6: Now build a connection between LED and Arduino UNO
- See Our Green LED has Yellow and Orange wire and our Red LED has Red and Brown wire.
2)Connections on a breadboard:
We have used 2 resistors of 100 Ohm each.
3)Connection of Bread Board on Arduino:
Look for yellow dots to know the port number.
Complete Look of Box:
Here is our servo motor and two LEDs..
Step 7: Recognition and door opening
Now here in the first yellow block :
. we are assigning the port which we have selected in the IDE of Arduino UNO before.
. Then we are are assigning the pin number to which we have attached the wire of LED
In the second yellow box :
. We have made a function to give the angle at which our servo will move
TO KNOW BASICS OF THE WORKING OF SERVO WITH ARDUINO PLEASE REFER THIS VIDEO : https://youtu.be/BS_dBX9RHtE
. Here we have load our model name jayesh.yml
. Then make a function to face_detector to recognize my face
. Now here we can see yellow dots.
this line “board.digital[pin1].write(1)” means we are sending signal to the Red LED connected on pin1 menteoned above in code .
this line “board.digital[pin1].write(0)” means we are not sending signal to the Red LED connected on pin1 menteoned above in code .
this line “board.digital[pin2].write(1)” means we are sending signal to the Green LED connected on pin2 menteoned above in code .
. Then in yellow block we are moving our servo degree by degree if our confidance in > 86.
Thankyou : )
My CODE is HERE : https://github.com/jayesh49/LBPH-Door-UnLock-Aurdino-UNO-.git