📌 6.1: When it recognizes your face then -
👉 It sends mail to your mail-id by writing this is the face of your name.
📌 6.2: When it recognizes a second face, it can be your friend or family members face-
👉 Create EC2 instance in the AWS using CLI.
👉 Create 5 GB EBS volume and attach it to the instance.
In this part of the task, I have first created a dataset of 100 images and then trained my dataset with the help of the LBPH(Local Binary Pattern Histogram) Algorithm.
Note: Face recognition is different from Face detection:
- Face Detection: it has the objective of finding the faces (location and size) in an image and probably extract them to be used by the face recognition algorithm.
- Face Recognition: with the facial images already extracted, cropped, resized, and usually converted to grayscale, the face recognition algorithm is responsible for finding characteristics that best describe the image.
The face recognition systems can operate basically in two modes:
- Verification or authentication of a facial image: it basically compares the input facial image with the facial image related to the user which is requiring the authentication. It is basically a 1x1 comparison.
- Identification of facial recognition: it basically compares the input facial image with all facial images from a dataset to find the user that matches that face. It is basically a 1xN comparison.
LBPH Algorithm: 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
The LBPH algorithm is a part of the OpenCV module of python.
So, first, we have to download the file of haar cascade(face) from GitHub website and store it in our directory where our task and all the related file codes are present.
Link of the haar cascade file: link.
Then we have to create a dataset of our frontal face images using the below code in python.
It will use the webcam of the system and capture images and show it as well.
If the code is executed without any error it will display the output “Sample Collection Complete” as below:
You can see the dataset images in the directory or path given in the variable ‘file_name_path’.
Next, we have to train our dataset created by using the code below.
If the code is executed well, it will show the output: Model trained successfully
After this step, we can make two functions- one for the email and another one for the WhatsApp message.
Now we are ready for face Recognition and for the message and mail to be delivered. We have to use the code for image recognition and set a certain ‘confidence score’ so that our trained model can recognize that face. I have set a confidence score of 90% which can be changed as per the requirement or user’s wish.
Now if we run the above code, one can notice that the webcam gets active and it starts taking the images and shows this in the ‘Face Recognition’ window.
It might take just a fraction of a second to recognize the face and then it will call the functions to send mail and WhatsApp message immediately.
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. Amazon EC2’s simple web service interface allows you to obtain and configure capacity with minimal friction.
In this part of code, one must require AWS-CLI installed in its system and its path added to the env. Also, the instance is created and launched using python so the user must have configuration done. One can use the below command:
It requires AWS Access Key and AWS Security Id, which the user must-have.
We can use the below code to run the command:
import os os.system("aws ec2 run-instances --image-id <Instance_ID> --instance-type t2.micro --count 1 --subnet-id <subnet-ID> --security-group-ids <security_group_ID> --key-name <key_name>")os.system("aws ec2 create-volume --availability-zone <availabilityzone> --size 5")
Once the Volume_ID is known then we can run the last command:
os.system("aws ec2 attach-volume --volume-id <Volume_ID> --instance-id <INstance_ID> --device xvdh")
Note: The user have the access to its AWS account and should know the Instance_ID, Volume_ID, Subnet_ID, and serurity_group_ID. All of them is visible on the AWS console or one can use the AWS command below:
aws ec2 describe-instances
After the task is completed, one can check from the AWS console whether its EBS volume is created or not.