A real-time computer vision application that uses MediaPipe to detect human liveness through various gesture and facial recognition tasks.
- 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
- Python 3.7+
- Webcam/Camera
- Windows/macOS/Linux
-
Install dependencies:
python setup.py
-
Run the application:
python run.py
Or directly:
python gesture_liveness.py
-
Install required packages:
pip install -r requirements.txt
-
Ensure model files are present:
face_landmarker.taskhand_landmarker.taskgesture_recognizer.task
- Blink Twice: Blink your eyes twice in succession
- Smile: Show a big smile for several frames
- Nod Head: Nod your head down once
- 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
- Task Selection: 3 random tasks are selected from the available pool
- Real-time Detection: Camera feed is processed using MediaPipe
- Stability Checking: Tasks require stable detection over multiple frames
- Timeout System: Each task has a 15-second time limit
- Scoring: Pass/fail based on successful completion (2/3 tasks needed)
- ESC: Exit during tasks
- Any Key: Close after completion
- Ensure webcam is connected and not used by other applications
- Try different camera indices if default doesn't work
- Ensure all
.taskmodel files are in the project directory - Check MediaPipe version compatibility
- Close other applications using the camera
- Ensure good lighting conditions
- Position yourself clearly in the camera frame
- 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
├── 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
debug_mp.py: Test MediaPipe installationdebug_mp_fix.py: MediaPipe compatibility checksdebug_mp_fix_2.py: Alternative MediaPipe imports
- Create a new task class inheriting the task interface
- Implement the
process(face_result, hand_result)method - Add to the
task_poolinLivenessApp.__init__()
This project is for educational and demonstration purposes.