Skip to content

devesssi/emotion-detect-mediapipe-opencv-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

# Emotion Detector (Django + MediaPipe + OpenCV)

A real-time webcam-based emotion detection application built as a Django assignment project. It uses MediaPipe and OpenCV to detect facial landmarks and classify emotions—Happy, Sad, or Neutral—in live video streams.

---

## 🧠 Features

- Real-time emotion detection via webcam.
- Detects **Happy**, **Sad**, and **Neutral** emotions.
- Utilizes **MediaPipe** for facial landmark tracking.
- Displays emotion overlays on video frames using **OpenCV**.
- Cleanly integrated into a Django backend.

---

## 🛠️ Tech Stack

| Component         | Technology    |
|------------------|----------------|
| Backend Framework| Django         |
| Video Processing | OpenCV         |
| Landmark Detection | MediaPipe   |
| Numerical Computation | NumPy   |
| UI               | HTML / CSS / JS (via Django templates) |

---

## ⚙️ Installation & Setup

1. **Clone the repository**

   ```bash
   git clone https://github.com/devesssi/emotion-detect-mediapipe-opencv-.git
   cd emotion-detect-mediapipe-opencv-
  1. Set up a virtual environment

    python -m venv venv
    source venv/bin/activate            # On Windows: venv\Scripts\activate
  2. Install dependencies

    pip install -r requirements.txt
  3. Apply Django migrations

    python manage.py migrate
  4. Run the development server

    python manage.py runserver
  5. Access the web app

    Visit http://127.0.0.1:8000/ in your browser. Grant webcam access when prompted to start emotion detection.


🚀 Project Structure

emotion-detect-mediapipe-opencv-/
│
├── emotion_detector/           # Django application
│   ├── migrations/
│   ├── views.py               # Handles video streaming and processing
│   ├── urls.py                # Routes for the app
│   └── templates/             # HTML templates (index.html, etc.)
│
├── emotion_detector.py        # Standalone script (if present)
├── manage.py                  # Django management script
├── requirements.txt           # Project dependencies
└── README.md                  # Project documentation

🎥 How It Works

  1. When you access the app in your browser, it initializes the webcam.
  2. OpenCV captures video frames.
  3. MediaPipe processes each frame to find facial landmarks.
  4. A simple expression classifier (based on NumPy thresholds or distances) categorizes emotions.
  5. The current emotion label is overlayed on the video feed and sent back to the web client via Django's streaming view.

📚 Emotion Classes

(These are the only emotions currently supported, but more can be added by extending the logic.)


🧪 Running the Emotion Detector

  • Launch the app: python manage.py runserver
  • Open your browser to http://127.0.0.1:8000/
  • Allow webcam permissions, then observe real-time emotion detection.

📝 Assignment Context

This project is built as an academic assignment. It focuses on:

  • Integrating MediaPipe and OpenCV in a Django environment.
  • Real-time emotion tracking from live webcam data.
  • Simple yet effective algorithm for classifying basic emotions.

🔧 Future Enhancements

  • Add more emotion classes (e.g. angry, surprised).
  • Improve classifier using ML (e.g. train lightweight ConvNet).
  • Option to record and download emotion logs.
  • Enhance front-end for better UI/UX and performance.

🤝 Contributing

As an assignment project, direct contributions are limited. However, feedback, bug reports, or suggestions are welcome via GitHub Issues.


📄 License

This project is licensed under the MIT License. © 2025 devesssi

About

This is a Emotion detector built using django ...mediapipe,opencv and more

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published