A robust and efficient hand tracking solution built with MediaPipe and OpenCV, designed to detect and track hand landmarks in real-time. This module serves as a foundation for building more complex hand gesture-based applications.
- Real-time hand detection and tracking
- 21 hand landmark detection points
- Finger position identification
- Modular design for easy integration
- Optimized performance using MediaPipe's ML pipeline
- Python - Core programming language
- OpenCV - Computer vision and image processing
- MediaPipe - Machine learning pipeline and hand tracking solutions
- NumPy - Numerical computing and array operations
- Python 3.9 or higher
- Webcam or video input device
- Clone the repository:
git clone https://github.com/navid001/Hand-Tracking-Module.git
cd Hand-Tracking-Module- Create and activate a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install required packages:
pip install -r requirements.txtimport cv2
from hand_tracking_module import HandTracker
# Initialize the hand tracker
tracker = HandTracker()
# Start video capture
cap = cv2.VideoCapture(0)
while True:
success, image = cap.read()
if not success:
break
# Process the image and get hand landmarks
image = tracker.find_hands(image)
landmark_list = tracker.find_position(image)
cv2.imshow("Hand Tracking", image)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()The module detects 21 hand landmarks, numbered from 0 to 20:
- 0-4: Thumb
- 5-8: Index finger
- 9-12: Middle finger
- 13-16: Ring finger
- 17-20: Pinky
You can customize the tracking parameters when initializing the HandTracker:
tracker = HandTracker(
static_image_mode=False,
max_num_hands=2,
min_detection_confidence=0.5,
min_tracking_confidence=0.5
)- The module is optimized for real-time processing
- Recommended minimum specifications:
- CPU: Dual-core processor, 2.0 GHz or higher
- RAM: 4GB or higher
- Camera: 30 FPS minimum
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- MediaPipe team for their excellent hand tracking solutions
- OpenCV community for their comprehensive computer vision tools
Your Name - @navid001 Project Link: https://github.com/navid001/Hand-Tracking-Module