We use cookies to improve your browsing experience and to analyze our website traffic. By clicking “Accept All” you agree to our use of cookies. Privacy policy.
5 readsMIT License

Face and Smile Detection with OpenCV: Real-Time and Static Image Applications

Table of contents

Face and Smile Detection with OpenCV: Real-Time and Static Image Applications

This project demonstrates how classical Haar Cascade classifiers in OpenCV can be used to detect faces, eyes, and smiles in both static images and real-time webcam feeds.

Project Overview

This project includes two Python scripts:

  1. Static Image Detection
    Detects faces, eyes, and smiles from a given image.

  2. Webcam Real-Time Detection
    Continuously detects facial features from a live webcam feed using OpenCV.

Repository

GitHub Repository:
https://github.com/TaufiaHussain/Face-webcam-Detection

Features

  • Face detection
  • Eye detection
  • Smile detection
  • Real-time camera input (OpenCV)
  • Image-based input and saving output with annotations

How to Run

1. Clone the repository:

git clone https://github.com/TaufiaHussain/Face-webcam-Detection
cd Face-webcam-Detection

2. Install dependencies:

pip install opencv-python

3. Run either script:

Static Image:

python "face eye smile detection.py"

Webcam Detection:

python "webcam detection.py"

Note: Press q to stop the webcam.

Method Used

Haar Cascades are classical machine learning models trained on positive/negative samples for object detection.

No deep learning models were used — just efficient, lightweight, and fast OpenCV-based cascades.

Output Samples

face_eye_smile_detected.jpg is automatically saved when using the static image script.

Webcam detection displays bounding boxes in real-time with the OpenCV GUI.

Applications

-Educational demos for beginners in computer vision

-Real-time smile detection

-Face tracking for UI interactions

License

This project is licensed under the MIT License. See the repository for full details.

Author

Taufia Hussain
Scientific researcher | Co-Founder@DataLens.Tools
https://github.com/TaufiaHussain | https://www.linkedin.com/in/taufia-hussain-52300015/

Table of contents

Files

Face and Smile Detection with OpenCV: Real-Time and Static Image Applications