Skip to content

Repository files navigation

Emoji fication Demo

MAASTTTII

A real-time camera-based emoji display application that uses MediaPipe to detect your poses and facial expressions, then displays the corresponding emoji in a separate window.

Features

  • Hand Detection: Raise a hand above your shoulder → displays hands up emoji 🙌
  • Tongue Out Detection: Stick your tongue out → displays tongue emoji 😛
  • Side Eye Detection: Turn your head sideways → displays side eye emoji 🙄
  • Smile Detection: Show your teeth → displays smiling emoji 😊
  • Default State: Straight face → displays neutral emoji 😐
  • Real-time Processing: Live camera feed with instant emoji reactions

Detection Priority

  1. Hands Up (highest priority) — overrides all facial expression detection
  2. Tongue Out — detected when tongue tip extends past lower lip
  3. Side Eye — detected when nose offset from face center exceeds threshold
  4. Smiling — detected via brightness of the mouth region (teeth visible)
  5. Straight Face — default when none of the above are triggered

Requirements

  • Python 3.12
  • A webcam
  • Required Python packages (see requirements.txt)

Installation

pip install -r requirements.txt

Usage

python emoji_reactor3.py

What Happens

  1. Run the script — your webcam starts immediately.
  2. Two windows will open:
    • Camera Feed: Shows your live camera with the current detection state overlaid
    • Emoji Output: Displays the corresponding emoji based on your expression or pose
  3. Controls:
    • Press q to quit the application
    • Raise a hand above your shoulder for the hands up emoji 🙌
    • Stick your tongue out for the tongue emoji 😛
    • Turn your head to trigger the side eye emoji 🙄
    • Show your teeth / smile for the smiling emoji 😊
    • Keep a straight face for the neutral emoji 😐

How It Works

The application uses two MediaPipe solutions running in parallel each frame:

  1. Pose Detection — Monitors shoulder and wrist landmark positions to detect raised hands
  2. Face Mesh Detection — Analyzes 468 facial landmarks to detect expressions:
    • Teeth/Smile: Measures average pixel brightness of the mouth bounding box region
    • Tongue Out: Measures the distance from tongue-tip landmark to lower lip midpoint
    • Side Eye: Measures horizontal offset of the nose tip from the midpoint between both outer eye corners

Customization

Adjusting Detection Sensitivity

Edit the threshold constants at the top of emoji_reactor3.py:

Constant Default Effect
SMILE_THRESHOLD 0.22 Mouth aspect ratio for smile detection
HEAD_TURN_THRESHOLD 0.04 Nose offset for side-eye trigger
TONGUE_THRESHOLD 0.04 Tongue-tip distance for tongue-out trigger
TEETH_BRIGHTNESS_THRESHOLD 120 Pixel brightness to detect visible teeth

Changing Emoji Images

Replace the image files in the project root with your own:

File Emoji State
smile.jpg 😊 Smiling with teeth
plain.png 😐 Straight / neutral face
air.jpg 🙌 Hands raised up
tongue.jpg 😛 Tongue out
sideye.jpeg 🙄 Head turned / side eye

Script Versions

File Features
emoji_reactor.py v1 — Smile + Hands Up only
emoji_reactor2.py v2 — Added Side Eye + Tongue Out (ratio-based)
emoji_reactor3.py v3 ✅ Latest — Improved smile via teeth brightness detection

Technical Details

  • Uses OpenCV for camera capture and window display
  • Uses MediaPipe Pose (33 landmarks) for hand/shoulder tracking
  • Uses MediaPipe FaceMesh (468 landmarks) for facial expression detection
  • Frames are converted to RGB before MediaPipe processing, then back to BGR for display

Dependencies

  • opencv-python — Computer vision and camera capture
  • mediapipe — Pose and Face Mesh landmark detection
  • numpy — Numerical computing for landmark geometry

See requirements.txt for version constraints and requirements-lock.txt for pinned versions.

License

MIT License — see LICENSE for details.

About

I trained a computer to detect my side eye

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages