πŸ€– LateAI
Home β€Ί Tutorials β€Ί Face Detection 60 FPS
πŸ˜€

Face Detection 60 FPS

Beginner Β· 1 hour
πŸ“Ά Beginner ⏱ 1 hour πŸ’° Free (software only) 🏷 CV Zone

πŸ“Œ Overview

Face detection with OpenCV's built-in Haar cascade classifier runs at roughly 60 frames per second on an ordinary laptop.

Compared with deep-learning options such as MediaPipe, a Haar cascade is tiny and barely touches the CPU, which suits resource-constrained hardware or scenes that need maximum frame rate - and it is the best place to start understanding classic computer vision detection.

🧰 What you need

πŸ”§ Step by step

1

Install OpenCV

pip install opencv-python

The Haar models ship with OpenCV, so there is nothing extra to download

2

Load the cascade classifier

Load the face detection xml model with CascadeClassifier

The common one: frontal face (haarcascade_frontalface_default)

3

Convert to grayscale and detect

detectMultiScale slides a window over the grayscale image

Working in grayscale speeds detection up considerably

4

Draw the boxes

Draw a rectangle for each returned (x, y, w, h)

You can add anti-aliased lines and text labels

5

Tune the parameters

scaleFactor, minNeighbors, and minSize trade missed detections against false positives

Raising minNeighbors reduces false positives; lowering it reduces misses

6

Compare frame rates and apply it

Measure and display the FPS on the frame

It can feed downstream work such as green screen, effects, or attendance

πŸ’‘ Tips

View original β†— ← Back to LateAI home