An advanced computer vision system for comparing and analyzing hand gestures using MediaPipe and OpenCV.
This project provides a sophisticated gesture recognition system that can:
- Record reference gestures from video files
- Capture live gestures using your webcam
- Compare gestures using advanced similarity algorithms
- Provide detailed scoring and quality assessment
- 🎥 Real-time Gesture Capture: Live webcam gesture recording
- 📹 Video Processing: Extract hand keypoints from reference videos
- 🔍 Advanced Comparison: Cosine similarity-based gesture matching
- 📊 Intelligent Scoring: Aggressive scoring algorithm for precise matching
- 🎯 Quality Assessment: Qualitative feedback on gesture similarity
- 🤖 MediaPipe Integration: Leverages Google's MediaPipe for accurate hand tracking
- 📈 Frame-by-Frame Analysis: Detailed comparison across multiple video frames
- Keypoint Extraction: Uses MediaPipe to extract 21 hand landmarks per hand
- Feature Vector: Creates 126-dimensional feature vectors (21 points × 3 coordinates × 2 hands)
- Similarity Calculation: Computes cosine similarity between reference and live gestures
- Scoring Algorithm: Applies aggressive penalty for medium-quality matches to ensure precision
| Score Range | Assessment | Description |
|---|---|---|
| 90-100% | Excellent | Near-perfect gesture match |
| 70-89% | Good | Strong similarity with minor differences |
| 50-69% | Fair | Moderate similarity |
| 30-49% | Poor | Significant differences |
| 0-29% | Failed | Gestures don't match |
- Python 3.8+
- PyTorch
- OpenCV
- MediaPipe
- NumPy
-
Clone the repository
git clone https://github.com/yourusername/gesture-recognition.git cd gesture-recognition -
Install dependencies
pip install opencv-python mediapipe numpy
-
Prepare your reference video
- Place your reference gesture video as
reference_video.mp4in the project directory - Ensure clear hand visibility and good lighting
- Place your reference gesture video as
-
Prepare reference video
- Place your reference gesture video as
reference_video.mp4 - Ensure clear hand visibility
- Place your reference gesture video as
-
Run the gesture comparison
python gesture_recognition.py
-
Follow the interactive process
- The system will automatically process your reference video
- Your webcam will activate for live gesture recording
- Perform your gesture in front of the camera
- Press 'q' to stop recording and see the similarity results
Frames collected: 45 (reference), 38 (live)
Raw Similarity Score: 87.34%
Final Score: 42.15%
Assessment: Fair match
Edit gesture_recognition.py to adjust:
MIN_FRAMES_REQUIRED: Minimum frames for valid gesture (default: 10)FPS_REDUCTION_FACTOR: Frame processing rate (default: 2)FIXED_KEYPOINTS: Number of keypoints per gesture (default: 126)
The apply_aggressive_scoring() function can be modified to change how similarity scores are transformed:
def apply_aggressive_scoring(normalized_similarity):
# Modify these ranges to adjust scoring sensitivity
if normalized_similarity >= 0.90:
return normalized_similarity * 100 # Keep high scores
elif 0.80 <= normalized_similarity < 0.90:
# Aggressive penalty for medium scores
return (0.20 + (normalized_similarity - 0.80) * 3) * 100
# ... continue customization- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- MediaPipe: For excellent hand tracking capabilities
- OpenCV: For computer vision processing
- NumPy: For numerical computations
Built with ❤️ by Rithwik