Skip to content

aliallouf/Fingers-Counter-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Fingers-Counter-Python

A real-time fingers counter using Python, OpenCV, and Mediapipe.

Real-Time Fingers Counter

Project Status

This project is a real-time fingers counter that uses a webcam to detect a human hand and count the number of fingers being held up. It leverages the power of computer vision libraries to perform hand landmark detection and display the count on the screen.

Features

  • Real-time video capture from a webcam.
  • Accurate hand detection using Google's Mediapipe library.
  • Visualization of hand landmarks and connections.
  • Logic to count the number of extended fingers.
  • Display of the finger count as an on-screen overlay.

Getting Started

Prerequisites

  • Python 3.6+
  • A webcam

Installation

  1. Clone the repository: git clone https://github.com/aliallouf/Fingers-Counter-Python.git cd Fingers-Counter-Python
  2. Install the required Python packages: pip install opencv-python mediapipe

Usage

To run the application, simply execute the main Python script:

python main.py

Press q to exit the application.

Code Breakdown

  • cam = cv2.VideoCapture(0): Initializes the webcam.
  • hands = mp_hands.Hands(...): Sets up the Mediapipe hand detection model.
  • results = hands.process(frame_rgb): Processes each frame to find hand landmarks.
  • Finger Counting Logic: The core logic compares the Y-coordinates of the fingertip landmarks with their corresponding knuckle landmarks to determine if a finger is extended.
  • cv2.putText(...): Renders the finger count as text on the output frame.

About

A real-time fingers counter using Python, OpenCV, and Mediapipe.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages