A real-time hand detection and sign language recognition system that can identify hand gestures for letters A-L using computer vision and machine learning.
- Real-time Hand Detection: Uses MediaPipe-based hand tracking to detect hands in live video
- Data Collection: Automated system to collect training images for different hand gestures
- Sign Language Recognition: Trained model to recognize hand signs for letters A through L
- Live Prediction: Real-time classification of hand gestures with visual feedback
HandDetection/
├── dataCollection.py # Script to collect training data
├── test.py # Main application for real-time recognition
├── model/
│ ├── keras_model.h5 # Trained neural network model
│ └── labels.txt # Class labels (A-L)
├── Data/ # Training data organized by letter
│ ├── A/
│ ├── B/
│ ├── C/
│ └── ... (through L)
└── README.md
- Python 3.7+
- OpenCV
- CVZone
- NumPy
- TensorFlow/Keras
- Webcam
- Clone this repository:
git clone https://github.com/yourusername/HandDetection.git
cd HandDetection
- Install required packages:
pip install opencv-python
pip install cvzone
pip install numpy
pip install tensorflow
To collect training data for a specific letter:
- Open
dataCollection.py
- Change the
folder
variable to the desired letter (e.g.,"Data/A"
for letter A) - Run the script:
python dataCollection.py
- Position your hand in the camera view showing the desired letter sign
- Press 's' to save images
- Collect multiple images (recommended: 100+ per letter)
To run the hand sign recognition:
python test.py
- Position your hand in front of the camera
- The system will detect your hand and predict the letter
- The predicted letter will be displayed on the screen
- Hand Detection: Uses CVZone's HandDetector to locate hands in the camera feed
- Image Preprocessing:
- Crops the hand region with offset for better detection
- Resizes to 300x300 pixels
- Centers the hand image on a white background
- Maintains aspect ratio to prevent distortion
- Data Storage: Saves preprocessed images with timestamps
- Real-time Detection: Continuously captures frames from webcam
- Hand Preprocessing: Same preprocessing as data collection
- Classification: Uses trained Keras model to predict the letter
- Visual Feedback: Displays the predicted letter on the video feed
- Architecture: CNN (Convolutional Neural Network)
- Input Size: 300x300x3 (RGB images)
- Classes: 12 (Letters A through L)
- Framework: TensorFlow/Keras
- Data Collection Mode: Press 's' to save an image
- Exit: Press any key to close the application
- Lighting: Ensure good lighting conditions
- Background: Use a plain background for better hand detection
- Hand Position: Keep your hand clearly visible and well-positioned
- Consistency: Maintain consistent hand poses during data collection
- Distance: Keep a consistent distance from the camera
- Extend to full alphabet (A-Z)
- Add number recognition (0-9)
- Implement word and sentence recognition
- Add voice feedback
- Improve model accuracy with data augmentation
- Add gesture-to-text functionality
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature
) - Commit your changes (
git commit -am 'Add new feature'
) - Push to the branch (
git push origin feature/new-feature
) - Create a Pull Request
This project is open source and available under the MIT License.
- CVZone library for simplified computer vision operations
- MediaPipe for hand tracking technology
- OpenCV for computer vision functionality
If you have any questions or suggestions, feel free to open an issue or contact me.
Note: This project is designed for educational purposes and basic sign language recognition. For production use, consider collecting more diverse training data and implementing additional error handling.