AI/ML

Real-Time Finger Counting Using Python, OpenCV & MediaPipe

Intermediate Difficulty
1 Hr Est. Time
0 items Components Needed

About This Project

Ever wanted to control something on your screen just by holding up fingers? This project turns any webcam into a simple gesture-recognition tool using computer vision — a great entry point into AI/ML for anyone coming from an embedded systems or Arduino background.

The project uses MediaPipe Hands, a pre-trained hand-tracking model from Google, to detect 21 landmark points on a hand in every video frame — knuckles, fingertips, and the wrist. OpenCV handles capturing the webcam feed and drawing the results on screen.

The finger-counting logic itself is simple geometry: for four of the five fingers, if the fingertip landmark sits above the middle-joint landmark in the frame, that finger is counted as "up." The thumb is a special case since it moves sideways rather than up-down, so it's checked by comparing X-coordinates instead of Y.

The output window shows:

  • A live skeleton overlay of your detected hand
  • A large on-screen number counting fingers from 0 to 5
  • Real-time FPS count
  • Detected hand label (Left / Right)

This is a solid beginner AI/ML project because it introduces:

  • Real-time video processing with OpenCV
  • Using a pre-trained ML model (MediaPipe) without training anything yourself
  • Basic landmark/geometry-based logic for gesture recognition

Where to take it next: this finger count can become an input trigger for other projects — for example, sending a gesture command over serial or Wi-Fi to an ESP32 to control an LED, servo, or relay. That's a natural bridge between this AI/ML tutorial and your embedded systems projects.

Components Required

Step-by-Step Instructions

  1. Install Python
  2. Open the project folder in VSCode
  3. Create a virtual environment : python -m venv venv
  4. Install dependencies : pip install -r requirements.txt
  5. Select the Python interpreter in VSCode
  6. Run the script : python finger_detection.py

Source Code

Arduino / ESP32 Sketch
Download the code files on GitHub :-
https://github.com/vsiplnotification-alt/fingerdetection.git

Completed this project?

Get an official Project Completion Certificate with a unique ID & QR verification — perfect for internships, resumes, and college submissions.

Get Certificate →