A real-time hand gesture recognition system built with Python and OpenCV. This project captures live video from your webcam, detects a hand inside a defined Region of Interest (ROI), analyzes convexity defects, and estimates the number of fingers extended.
- Real-time webcam capture
- Region of Interest (ROI) based detection
- Contour detection and convex hull visualization
- Convexity defect analysis
- Finger counting using geometric angle calculation
- Live on-screen finger count display
- The webcam feed is captured using OpenCV.
- A fixed Region of Interest (ROI) is defined where the hand should be placed.
- The ROI is converted to grayscale and blurred to reduce noise.
- Otsu thresholding is applied to segment the hand from the background.
- The largest contour is assumed to be the hand.
- A convex hull is generated around the hand contour.
- Convexity defects (gaps between fingers) are detected.
- Using triangle geometry and cosine rule, angles are calculated.
- Angles less than or equal to 90° are counted as extended fingers.
This approach uses classical computer vision techniques — no machine learning or deep learning is involved.
Make sure Python 3.8+ is installed.
Install required dependencies:
pip install opencv-python numpyRun the script:
python main.pyControls:
- Place your hand inside the green rectangle.
- Press Q to exit the application.
This project is open-source and available under the MIT License.