Task 6 : program that notify you when your face is detected in the camera.

Abhinav Shreyash
2 min readJun 24, 2021

--

So the Task is like this . . .

❄️ 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.
👉 Send sms of your name

below is the link to the full code at the bottom of the blog …

It contain 3 major files (the fourth one being for the pre-trained face recognition ml model)

so . . ..

we run the file called

image_recog.py

the first three lines for it are .. .

import cv2 = > for image capturing throught the camera and image rcogntion stuff

import what_sms as whs = > for sending the whatsapp and sms to the designated recipent and will be asked at the run time for the twilio account credentials and the purchased twilio phone number

import send_email as em = > on run time it will ask for the sender email smtp server and the smtp port , email id and email password, and the recipient email id

so first we initialized our pretrained face recognition model called Haarcascade_frontalface_default.xml

face_cascade = cv2.CascadeClassifier(‘haarcascade_frontalface_default.xml’)

then we open up the webcam by creating object

cam = cv2.Videocapture(0)

then we click the photo every time and then at each frame we put the image in the machine learning model as input and check the number of faces available and the points that signify those facical features detected by the model.

and whenever it click the photo and detect a human face ,

it send email ,and whatsapp and sms to the recipient we previously entered on the runtime.

!! you need “pywhatkit” and “twilio” python modules in the python environment in which you are running , and always run with all the three files in the same folder .

Continuing further inside the while loop ,

step 1: capture the photo using the cam object we previously created

step 2: convert the image to grayscale as the colour image is incompatible with with the haarcascade model,

step3 :using the above created haarcascade classifier object “face_cascade”

we define faces = face_cascade.detectMultiScale(gray,1.1,4) , for multiple face detection.

step4 : then it gives output in a list of multiple faces , we plot each face to the corresponding colour image to obtain the result in the coloured format.

step5 : and whenever we find a face we send the email ,whatsapp and sms to the recipient.

Thank you for reading . ..

and if it made sense(or not) then please feel free to try it out ,the link’s given below , you might get how it works once you see it running.

#worldrecordholder #training #internship #makingindiafutureready #summer #summertraining #python #machinelearning #aws #awscli #cv2 #rightmentor #linuxworld #vimaldaga #righteducation

--

--