Skip to content

A real-time face detection project built with Python and OpenCV. It uses Haar Cascades to detect faces from a webcam feed and displays overlays such as face count, timestamp, and FPS.

Notifications You must be signed in to change notification settings

rishinduyohan/Face-Detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

🎥 Face Detector (OpenCV + Python)

Real-time face detection with FPS counter, timestamp overlay, and dynamic face-count styling.

Python OpenCV License

✨ Project Overview

This project is a clean, real-time face detection app built with OpenCV. It captures frames from your webcam, converts them to grayscale for efficient processing, detects faces using Haar Cascades, and overlays useful UI elements: a live face counter, timestamp, and a frames-per-second (FPS) indicator. Rectangle colors change dynamically based on the number of faces detected (🟩 green ≤ 2, 🟥 red ≥ 3) for instant visual feedback.

🌟 Features

  • Real-time webcam capture (VideoCapture)
  • Haar Cascade face detection (haarcascade_frontalface_default.xml)
  • Dynamic rectangle color based on face count
  • On-screen overlays: face count, timestamp, FPS
  • Simple keyboard control: press q to quit

🧰 Tech Stack

  • Python 3.8+
  • OpenCV (opencv-python)

🚀 Getting Started

1) Prerequisites

  • Python 3.8 or newer
  • Webcam access

2) Installation

pip install opencv-python
  

The Haar Cascade file is resolved via OpenCV’s built-in path: cv2.data.haarcascades + "haarcascade_frontalface_default.xml"

3) Run

python main.py
  

🕹️ Controls

  • q — Quit the app

🧪 Troubleshooting

  • Black window / no camera: ensure your webcam is connected and not used by another app.
  • Slow FPS: close other heavy apps; reduce waitKey delay or resize frames before processing.
  • No faces detected: check lighting, camera angle, and that the Haar Cascade path resolves correctly.

🗺️ Roadmap

  • 🎯 Add eye/Smile detection
  • 🕶️ Fun overlays (sunglasses/emoji)
  • 💾 Snapshot capture (s to save)
  • ⚙️ CLI flags for camera index and cascade params

🤝 Contributing

Issues and PRs are welcome! Please open an issue to discuss major changes.

About

A real-time face detection project built with Python and OpenCV. It uses Haar Cascades to detect faces from a webcam feed and displays overlays such as face count, timestamp, and FPS.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages