How armanlaliwala/real-time-hand-gesture-recognition-using-mediapipe-opencv works
Project Type & Purpose
• This is a standalone real-time gesture recognition tool written in Python.
• It ingests a live video feed (webcam or external camera), detects hand landmarks via MediaPipe, classifies predefined gestures (👍, 👎, ✊), annotates frames with OpenCV, and records the output (H.264).
Main Components
a. Input Devices
• Webcam or external camera (DroidCam, Iriun).
b. Video Capture Module
• OpenCV’s VideoCapture API reads frames in real time.
c. Preprocessing
d. Hand Landmark Detection
• MediaPipe Hands pipeline extracts 21 landmark points per hand.
e. Gesture Classification Logic
• NumPy‐based rules compute relative positions to decide “Thumbs Up,” “Thumbs Down,” or “Fist.”
f. Annotation & Display
g. Video Encoding & Recording
• OpenCV VideoWriter encodes annotated frames using H.264 and writes to gesture_output.mp4.
h. Storage/Output
• Persisted file (gesture_output.mp4), demo notebook (code.ipynb), and example video (gesture_recognition_output.mp4).
Component Relationships & Data Flow
1 → 2 : “Camera Frame”
2 → 3 : “Raw Frame”
3 → 4 : “Preprocessed Frame”
4 → 5 : “Landmarks”
5 → 6 : “Gesture Label”
6 ↔ 2 : “Annotated Frame” (display loop)
6 → 7 : “Encoded Frame” → 8
Architectural Patterns & Design Principles
• Pipeline pattern: each module performs a discrete step on frame data.
• Single‐process, synchronous processing loop (capture → detect → classify → display/record).
• Extensibility point: classification logic can be extended with new rules or ML models.
• Separation of concerns: detection (MediaPipe) vs. classification (NumPy logic) vs. recording (OpenCV).
Relevant Technologies & Frameworks
• Python 3.8+
• MediaPipe 0.9+ (hand tracking)
• OpenCV 4.5+ (capture, drawing, encoding)
• NumPy (gesture rule logic)
• H.264 codec (VideoWriter)