A real-time AI-powered hand finger counter using Python, OpenCV, and MediaPipe. This project detects hands through a webcam and counts the number of fingers held up in real-time.
- Real-time Detection: High-speed hand tracking using MediaPipe.
- Dual Hand Support: Counts fingers from both hands simultaneously.
- Robust Logic:
- Uses distance-based logic for Thumb detection.
- Uses Y-coordinate comparison for the other four fingers.
- Sleek UI: Displays the total count in a styled overlay on the video feed.
The application displays a live feed with:
- Hand landmarks and skeletal connections.
- An overlay box showing the total count of fingers currently visible.
- Python 3.8+
- Webcam
-
Clone the repository:
git clone https://github.com/Tusm11/Finger-Counter.git
-
Install dependencies:
pip install opencv-python mediapipe
-
Run the application:
python main.py
- Press any key: Closes the application.
- Hand Tracking: MediaPipe identifies 21 key landmarks for each hand.
- Thumb Detection: Calculates the Euclidean distance between the thumb tip and the index base. If the distance exceeds a threshold, the thumb is considered "open".
- Finger Detection: Compares the Y-coordinate of each finger's tip with its middle joint. If the tip is higher (lower Y-value in image coordinates), the finger is considered "open".
- Summation: Adds up all "open" fingers across all detected hands.