Skip to content

Algorithmic-thinker/Liveness-Detection-Eye-Blink-Head-Movement

Repository files navigation

Gesture Liveness Detection System

A real-time computer vision application that uses MediaPipe to detect human liveness through various gesture and facial recognition tasks.

Features

  • Face Detection: Blink detection, smile recognition, head nodding
  • Hand Gestures: Open hand, fist, finger counting, cheek touching
  • Real-time Processing: Live camera feed with instant feedback
  • Task Randomization: 3 random tasks selected from available pool
  • Progress Tracking: Visual progress indicators and scoring system

Requirements

  • Python 3.7+
  • Webcam/Camera
  • Windows/macOS/Linux

Quick Setup

  1. Install dependencies:

    python setup.py
  2. Run the application:

    python run.py

    Or directly:

    python gesture_liveness.py

Manual Setup

  1. Install required packages:

    pip install -r requirements.txt
  2. Ensure model files are present:

    • face_landmarker.task
    • hand_landmarker.task
    • gesture_recognizer.task

Available Tasks

Face Tasks

  • Blink Twice: Blink your eyes twice in succession
  • Smile: Show a big smile for several frames
  • Nod Head: Nod your head down once

Hand Tasks

  • Open Hand: Show an open hand with all fingers extended
  • Make Fist: Close your hand into a fist
  • Show N Fingers: Display exactly 2 or 3 fingers
  • Touch Cheek: Touch your left, right, or either cheek with your finger

How It Works

  1. Task Selection: 3 random tasks are selected from the available pool
  2. Real-time Detection: Camera feed is processed using MediaPipe
  3. Stability Checking: Tasks require stable detection over multiple frames
  4. Timeout System: Each task has a 15-second time limit
  5. Scoring: Pass/fail based on successful completion (2/3 tasks needed)

Controls

  • ESC: Exit during tasks
  • Any Key: Close after completion

Troubleshooting

Camera Issues

  • Ensure webcam is connected and not used by other applications
  • Try different camera indices if default doesn't work

MediaPipe Errors

  • Ensure all .task model files are in the project directory
  • Check MediaPipe version compatibility

Performance Issues

  • Close other applications using the camera
  • Ensure good lighting conditions
  • Position yourself clearly in the camera frame

Technical Details

  • MediaPipe Tasks API: Used for face and hand landmark detection
  • OpenCV: Camera capture and image processing
  • Real-time Processing: ~30 FPS with optimized detection algorithms
  • Stability Algorithms: Multi-frame validation for reliable detection

File Structure

├── gesture_liveness.py      # Main application
├── requirements.txt         # Python dependencies
├── setup.py                # Setup script
├── run.py                  # Quick launcher
├── face_landmarker.task    # MediaPipe face model
├── hand_landmarker.task    # MediaPipe hand model
└── gesture_recognizer.task # MediaPipe gesture model

Development

Debug Scripts

  • debug_mp.py: Test MediaPipe installation
  • debug_mp_fix.py: MediaPipe compatibility checks
  • debug_mp_fix_2.py: Alternative MediaPipe imports

Adding New Tasks

  1. Create a new task class inheriting the task interface
  2. Implement the process(face_result, hand_result) method
  3. Add to the task_pool in LivenessApp.__init__()

License

This project is for educational and demonstration purposes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors