Skip to content

NikBandi/IEEE-Escape_Room_OpenCV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Smile Detection using MediaPipe and OpenCV

This project detects whether a person is smiling or not using MediaPipe and OpenCV.
It works by tracking facial landmarks around the lips and analyzing their positions in real time.


How it Works

  1. The webcam captures video frames using OpenCV.
  2. MediaPipe’s face landmark model detects 468 facial landmarks.
  3. The program uses four key landmarks:
    • 61: left lip corner
    • 291: right lip corner
    • 13: upper lip center
    • 14: lower lip center
  4. It calculates:
    • Mouth width: distance between the left and right lip corners
    • Mouth height: distance between the upper and lower lips
  5. The ratio of width to height determines if the person is smiling.

If the ratio is above a threshold (around 1.8), the system labels the person as smiling. Otherwise, it labels them as neutral.


Requirements

  • Python 3.8 or higher
  • OpenCV
  • MediaPipe
  • NumPy

Install dependencies with:

pip install opencv-python mediapipe numpy

How to Run

  1. Download the MediaPipe model file face_landmarker.task from the MediaPipe documentation.
  2. Place it in the same directory as the Python scripts.
  3. Run the main script:
python smile_detection.py
  1. Press q to quit the program.

Project Structure

smile-detection/
├── smile_detection.py        # Main smile detection script
├── detector.py               # Initializes and draws landmarks
├── face_landmarker.task      # MediaPipe model file
└── README.md                 # Project documentation

Customization

You can adjust the smile detection threshold in smile_detection.py:

if smile_ratio > 1.8:

Lower values make it easier to detect a smile. Higher values make detection stricter.


About

A detection system using MediaPipe and OpenCV that analyzes lip landmarks to determine whether a person is smiling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages