Member-only story

Real-Time Facial Recognition with Python

Victor Murcia
4 min readJan 9, 2023

--

One of the first computer vision projects I remember being really stoked about was object detection. More specifically, face detection. The excitement I felt when I was able to extend what I had just learned to detect objects in real time was palpable. I remember calling my mom and my sister to try out my program once I got it working and I was positively beaming. This is a quick post showcasing how to write a real-time face/eye tracking routine in Python with OpenCV and a webcam.

Facial Recognition

The basic code structure/steps needed to use OpenCV to detect objects in real time with a webcam are as follows:

  1. Specify the classifier model to be used
  2. Initiate a video capture instance
  3. Start a loop that will analyze every video frame as it comes
  4. Convert the recorded image to gray scale
  5. Perform the object detection using the classifer
  6. Draw rectangles around the detected objects

You can see the code I used for the face detection below.

The classifier I used was a built-in model of OpenCV located within the HaarCascades. These classifiers can be…

--

--

Responses (1)