Python Code for Facial Recognition and Security Automation.

mahima gautam
3 min readJul 17, 2021

Task DescriptionIn this task we would do the following:

📌 When it recognizes users face then do the following —
⚜It sends mail to your mail-id by writing this is the face of your name.
⚜Second, it sends a WhatsApp message to your friend, it can be anything.
⚜Create EC2 instance in the AWS using CLI.
⚜Create 5GB EBS volume and attach it to the instance.

What is facial Recognition System ?

A facial recognition system is a technology capable of matching a human face from a digital image or a video frame against a database of faces, typically employed to authenticate users through ID verification services, works by pinpointing and measuring facial features from a given image.

Face recognition systems use computer algorithms to pick out specific, distinctive details about a person’s face. These details, such as distance between the eyes or shape of the chin, are then converted into a mathematical representation and compared to data on other faces collected in a face recognition database.

Difference between Face Detection and Facial Recognition?

  • 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.

Our Pre-requisite:

a)AWS CLI Configured
b)Python ≥ 3.6
c)Working Camera
d)Libraries Installed :
— opencv python
— opencv contrib python
— pywhatkit
— pillow …please check below for more.

Approach to be used?

We will be using Haarcascade Face Detection to Generate our Image data set and later on that data set we will be training the Model using LBPH .

To learn more please visit: https://towardsdatascience.com/face-recognition-how-lbph-works-90ec258c3d6b

Now let’s get Started and jump directly to the code Part:-

✔ Step-1: Creating a Dataset using Haarcascade Face Detection

✔ Step-2: Training the Model using the LBPH Algorithm.

✔ Step-3: Defining the Function for sending mail and Whatsapp.

✔ Step-4: Calling the Function for sending mail and Whatsapp.

✔ Step-5: Defining the Function for Launching EC2 , EBS and Attaching Both.

Final — Result:

--

--