Face Recognition Program Using Python

Task Description

❄️ Create a program that perform below mentioned task upon recognizing a particular face.

📌 When it recognize your face then —
👉 It send mail to your mail id by writing this is face of your_name.
👉 Second it send whatsapp message to your friend, it can be anything.

📌 When it recognize second face, it can be your friend or family members face.
👉 Create EC2 instance in the AWS using CLI.
👉 Create 5GB EBS volume and attach it to the instance.

This was a team task.

In this task, we have used Haarcascade as our face detection model which we have downloaded from below link:-

https://github.com/opencv/opencv/tree/master/data/haarcascades

But, if we want our computer will detect and recognize our face and accordingly do different tasks, then we have to create and train one model which will do face recognition. For doing this, we have to install library called “opencv-python” using “pip” command and then import “cv2” module in our program. One of the popular algorithm we have used is LBPH (Local Binary Patterns Histogram) that we can use to create face recognition model. But, for training this model we have to provide multiple images captured as training data to this model as we know that one image consists of multiple pixels which are equivalent to individual feature and one entire image is equivalent to one observation/record. For creating training data, we captured multiple images that will have our face detected which will be stored in some data path.

After creating training dataset, we first created model using LBPH algorithm using method called face_LBPHFaceRecognizer.create() but in order to do this, we have to install library called opencv-contrib-python using “pip” command. Then use “train()” to train our model using training dataset.

pip install opencv-contrib-python

Now, we will run face recognition program by testing our model such that if confidence score is greater than say 85%, then it will recognize our face and print one message. We want as soon as it recognizes the face, it will do the following:-

Now, from our python program if we want to connect to AWS SNS service, then we have to use a library called “boto3” but first we need to install it using “pip” command and use “client()” function and specify service and region name in which you are using this service. For sending SMS, use “publish()” function and provide phone no and message as argument to this function.

First, we have to specify it’s path in environmental variables and then we have used os module to run “terraform init” command which is used to initialize a working directory containing Terraform configuration files. This is the first command that should be run after writing a new Terraform configuration or cloning an existing one from version control. For running terraform file having (.tf) extension, we can use “terraform apply” command.

If none of face is detected and recognized by model, then it will finally print message as “NO face found.” I have uploaded my code on below specified GitHub URL.

You can also refer below video for more clear view and see entire practical working of program.

Thanks for reading!!