Skip to content

Repository files navigation

😊 Face, Eye & Smile Detection using OpenCV

This project is a real-time face, eye, and smile detection system built using Python and OpenCV. It uses Haar Cascade Classifiers to detect facial features from a live webcam feed.


📌 Features

  • 🎯 Real-time face detection
  • 👀 Detects eyes inside the detected face region
  • 😄 Detects smiles inside the detected face region
  • 📷 Uses webcam feed
  • 🖼️ Draws bounding boxes and displays detection text

🛠️ Technologies Used

  • Python
  • OpenCV
  • Haar Cascade Classifiers

📂 Project Structure

Face-Eyes-Smile-Detection/
│
├── haarcascade_frontalface_default.xml
├── haarcascade_eye.xml
├── haarcascade_smile.xml
├── main.py
└── README.md

⚠️ Make sure the Haar cascade XML files are placed in the correct directory as referenced in the code.


📦 Requirements

Install the required dependency using pip:

pip install opencv-python

▶️ How to Run

  1. Clone the repository or download the project files.
  2. Ensure your webcam is connected.
  3. Update the Haar cascade file paths if needed.
  4. Run the script:
python face_eye_smile_detection.py
  1. Press q to exit the application.

🧠 How It Works

  • Captures video frames from the webcam.
  • Converts each frame to grayscale for better detection.
  • Detects faces using haarcascade_frontalface_default.xml.
  • Defines a Region of Interest (ROI) for each face.
  • Detects eyes and smiles within the ROI.
  • Displays detection results on the video feed.

🖼️ Output Preview

  • Green rectangle → Face detected

    Screenshot 2026-01-25 152437

  • Text "Eyes Detected" → Eyes found

    Screenshot 2026-01-25 152043

  • Text "Smile Detected" → Smile found

    Screenshot 2026-01-25 152056

⚠️ Notes

  • Detection accuracy depends on lighting conditions.
  • Haar cascades work best with frontal faces.
  • Smile detection may require fine-tuning parameters for better accuracy.

📄 License

This project is open-source and free to use for educational purposes.


About

Real-time Face, Eye, and Smile Detection system built with Python and OpenCV using Haar Cascade Classifiers. Detects facial features from live webcam feeds with high-speed processing, bounding box visualization, and grayscale optimization. Perfect for computer vision, AI, and image processing learning projects.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages