Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

AI-Hand-Gesture-Counter 🖐️

A high-performance, real-time hand landmark tracking and finger counting application. This project utilizes MediaPipe and OpenCV to provide a robust gesture-recognition interface, specifically engineered to handle complex lighting and hand orientations.

🚀 Key Features

  • Advanced Coordinate Logic: Uses Euclidean distance-based detection for the thumb to ensure 100% accuracy.
  • Optimized for Windows: Specifically configured to bypass camera privacy blocks using the CAP_DSHOW backend.
  • Real-time Performance: High-speed landmark tracking with 21 localized points.

🛠️ The Technical Journey & Debugging Mastery

Building this project involved solving several deep-level system and library conflicts.This project wasn't just about the code; it was about engineering around real-world environment hurdles, Below are the key engineering challenges I overcame:

1. Environment Isolation & Version Pinning

  • The Mistake: Running the script in a global Python environment led to an AttributeError: module 'mediapipe' has no attribute 'solutions'.
  • The Debugging Skill: I diagnosed a version mismatch in the MediaPipe library. I implemented a Virtual Environment (venv) and pinned the project to MediaPipe 0.10.21 and NumPy 1.26.4, ensuring a stable and reproducible build.

2. Hardware-OS Interfacing (The Gray Screen Fix)

  • The Mistake: Encountered a "gray screen" where the camera would initialize but fail to provide a feed due to Windows 11 privacy layers.
  • The Debugging Skill: I researched video capture backends and successfully implemented cv2.CAP_DSHOW (DirectShow). This allowed the software to communicate directly with the hardware, bypassing the OS-level gray-screen block.

3. Spatial Mathematics vs. 2D Logic

  • The Mistake: A simple Y-coordinate comparison caused a "+1 offset" error, as the thumb moves on a different axis than the fingers.
  • The Debugging Skill: I optimized the counting algorithm by moving from simple coordinate checks to Euclidean Distance calculations. By measuring the distance between the thumb tip (Landmark 4) and the pinky base (Landmark 17), the counter became 100% accurate for both left and right hands.
  • Math Logic: $d = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}$

4. Git Repository Hygiene

  • The Mistake: Staged over 10,000 files from the venv folder, causing repository bloat and massive terminal warnings.
  • The Debugging Skill: I mastered .gitignore implementation. I learned how to reset the Git index using git rm -r --cached . and successfully reduced the repository size from 200MB+ to under 1MB.

5. Managing OS Execution Policies

  • The Mistake: PowerShell blocked the virtual environment activation script (PSSecurityException).
  • The Debugging Skill: I learned to safely manage Execution Policies using Set-ExecutionPolicy -Scope Process, allowing the environment to run without compromising overall system security.

📦 Installation & Setup

  1. Clone the Project:
    git clone [https://github.com/your-username/AI-Hand-Gesture-Counter.git](https://github.com/your-username/AI-Hand-Gesture-Counter.git)
    cd AI-Hand-Gesture-Counter

About

A high-accuracy finger counting application using MediaPipe and OpenCV. Features Euclidean distance-based thumb detection and real-time landmark tracking optimized for Windows environments.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages