Final Project
Final Project
Submitted by
Y. JYOHINI [Link].22811A0477
[Link] [Link].23815A0412
K. TULASI [Link].22811A0479
[Link] PRASAD [Link].23815A0423
10
AVANTHI INSTITUTE OF ENGINEERING & TECHNOLOGY
(Approved by AICTE and Permanently Affiliated to JNTU Vizianagaram, AP) (A NAAC A+
Accredited Institution)
TAMARAM (P.O), MAKAVARAPALEM (M.O), NARSIPATNAM (R.D), ANAKAPALLE DISTRICT-
531113
CERTIFICATE
This is to certify that the project work entitled “Hand Gesture Recognition System For
Finger Counting Using Computer Vision And Machine Learning (python)” is being
submitted for the partial fulfilment of requirements for the award of Bachelor of Technology
in Electronics and Communication Engineering at AVANTHI INSTITUTE OF
ENGINEERING & TECHNOLOGY, Makavarapalem, Anakapalle is a Bonafide work
done by
under the guidance and supervision during 2025-2026 and it
has been found suitable for acceptance according to the requirements of the university.
EXTERNAL EXAMINER
ACKNOWLEDGMENT
Concentration, dedication, and application are necessary but not sufficient to achieve any goal.
Therefore, it is our pleasant duty to offer our service of acknowledgement to those honorable
personalities of the department who helped us to follow the path to success for the completion
of this project.
We express our heartiest thanks to the management and our college principal Dr.C.P.V.N.J
MOHAN RAO [Link]., Ph.D for extending his utmost support and cooperation in providing all
provisions for the successful completion of the project.
We are also thankful to Dr. E. GOVINDA M. Tech., Ph.D., Head of the department of Electronics
and communication engineering for providing his support and encouragement at every step in
completing this project successfully.
We are also grateful to the project guide Ms. S. SIRISHA [Link] Assistant Professor,
department of ECE, for her excellent guidance right from selection of the project and her
valuable suggestions throughout the project.
We would like to express our special gratitude to teaching and non-teaching staff of the
Electronics and Communication Department, my friends and my seniors, who are always a
source of inspiration for us and played an important role in making the project a memorable
one.
PROJECT ASSOCIATES
Y. JYOHINI (22811A0477)
M. NAVYASRI (22815A0412)
K. TULASI (22811A0479)
[Link] PRASAD (23815A0423)
2
DECLARATION
We here by declare that the project entitled “Hand Gesture Recognition System For Finger
Counting Using Computer Vision And Machine Learning (python)” is a bonafide work
done by us and submitted for the partial fulfilment for the award of degree of BACHELOR OF
TECHNOLOGY in the department of ELECTRONICS AND COMMUNICATION
ENGINEERING at AVANTHI INSTITUTE OF ENGINEERING AND [Link]
the best of our knowledge, the matter embodied in the project has not been submitted to any
other University/Institute of any degree.
PROJECT ASSOCIATES
Y. JYOHINI (22811A0477)
M. NAVYASRI (22815A0412)
K. TULASI (22811A0479)
[Link] PRASAD (23815A0423)
3
TABLE OF CONTENTS
ABSTRACT
CHAPTER-1 INTRODUCTION
1.0 INTRODUCTION
2.0 OVERVIEW
3.0 EXISTING SYSTEM
4.0 PROPOSED SYSTEM
4
CHAPTER-5 SYSTEM DESIGN
5.1 INPUT DESIGN
5.2 OUTPUT DESIGN
5.3 DATA FLOW DIAGRAM
5.4 UML DIAGRAM
CHAPTER-6 IMPLEMENTATION
6.1 MAIN SAMPLE CODE
CHAPTER-8 TESTING
8.1 INTRODUCTION TO TESTING
8.2 SAMPLE TEST CASES
CHAPTER-9 CONCLUSION
CHAPTER-10 REFERENCES
LIST OF FIGURES
5.3 DATA FLOW DIAGRAM (DFD)
[Link] USE CASE DIAGRAM
[Link] CLASS DIAGRAM
[Link] SEQUENCE DIAGRAM
[Link] ACTIVITY DIAGRAM
LIST OF TABLES
3.4.1 HARDWARE REQUIREMENTS
3.4.2 SOFTWARE REQUIREMENTS
8.2 SAMPLE TEST CASES
5
ABSTRACT
Hand Gesture Recognition is an emerging field in Computer Vision that enables natural interaction
between humans and machines. This project focuses on developing a real-time finger counting
system using Computer Vision and Machine Learning techniques implemented in [Link]
system captures live video input through a webcam and processes the frames to detect hand
landmarks. Using MediaPipe’s hand tracking model and OpenCV, the system identifies finger
positions and counts the number of raised fingers accurately. The proposed model leverages
landmark detection rather than traditional image thresholding, thereby improving accuracy under
varying lighting conditions. The system can detect multiple hands and compute total finger count
in real time. This project demonstrates the practical implementation of Machine Learning-based
pose estimtion for gesture recognition. The application is developed using Streamlit for user
interaction and WebRTC for real-time video streaming. It provides a simple and interactive
interface where users can display their fingers in front of the camera and receive instant results.
This project has applications in human-computer interaction, virtual classrooms, sign language
systems, gaming, robotics control, and touchless interfaces. The system is lightweight, efficient,
and deployable on standard computing devices without requiring specialized hardware.
The overall objective is to build an accurate, user-friendly, and scalable finger recognition system
using modern AI tools.
6
CHAPTER-1
INTRODUCTION
7
1.1 INTRODUCTION
In recent years, Human-Computer Interaction (HCI) has evolved significantly with the
integration of Artificial Intelligence and Computer Vision technologies. Traditional input
devices such as keyboards and mice are gradually being complemented by gesture-based
systems. Hand gesture recognition is one such technology that enables intuitive communication
between humans and machines.
The system uses landmark-based hand detection techniques instead of simple contour detection
methods. MediaPipe’s machine learning model detects 21 key hand landmarks, which are used
to determine whether fingers are raised or folded. This approach improves accuracy and
reduces dependency on background conditions.
The system is developed in Python due to its powerful ecosystem of libraries such as OpenCV,
MediaPipe, NumPy, and Streamlit. The application processes video frames in real-time and
overlays the detected finger count on the screen.
1.2 Overview
The Hand Gesture Recognition System is designed to detect and count the number of raised fingers
using real-time video input. The system architecture consists of four major modules:
The webcam captures live video frames which are processed using OpenCV. Each frame is converted
from BGR to RGB format and passed to the MediaPipe Hands model. The model detects hand
landmarks and provides 21 coordinate points per detected hand.
8
The system identifies finger tips and compares their positions relative to lower joints. If the tip is
positioned above the lower joint (in Y-axis), the finger is considered raised. Special logic is used for
thumb detection depending on left- or right-hand orientation.
The counted fingers are displayed on-screen in real time. The application supports detection of two
hands simultaneously and calculates total finger count. The system is lightweight, runs efficiently, and
provides accurate detection under moderate lighting conditions.
Earlier hand gesture recognition systems relied on traditional image processing techniques such as:
These systems were highly dependent on lighting conditions and background uniformity.
Limitations:
Most existing systems used thresholding to separate hand from background and convex hull defects to
count fingers. However, noise and shadows caused frequent misclassification.
These drawbacks created the need for a more reliable ML-based approach.
9
1.4 Proposed System
Overview of Proposed System
The proposed system uses a Machine Learning-based hand landmark detection model provided by
MediaPipe. Instead of relying on pixel segmentation, the system detects 21 key hand landmarks.
Working Principle
The implementation is based on your working application code which integrates OpenCV, MediaPipe,
Streamlit, and WebRTC for real-time performance.
10
CHAPTER-2
LITERATURE SURVEY
11
2. LITERATURE SURVEY
Hand Gesture Recognition has been widely researched in the fields of Computer Vision, Artificial
Intelligence, and Human-Computer Interaction. Over the past two decades, several techniques have
been proposed ranging from traditional image processing approaches to advanced deep learning models.
This section reviews existing methodologies, algorithms, tools, and recent advancements relevant to
finger counting systems.
Early hand gesture recognition systems were primarily based on classical image processing techniques.
These methods did not rely on machine learning but instead used pixel-level operations to extract hand
features.
One of the earliest techniques involved detecting skin-colored regions in images using HSV or YCbCr
color space. Pixels matching predefined skin color ranges were segmented to isolate the hand.
Limitations:
Background Subtraction
This technique required a static background. The moving object (hand) was extracted by subtracting
the current frame from a reference background.
Limitations:
After segmentation, contour detection was applied to identify hand boundaries. Convex hull and
convexity defects were used to count fingers.
Limitations:
12
● Noise-sensitive
● Inaccurate for partially closed fingers
● Cannot distinguish left and right hand reliably
Although these methods were computationally simple, they lacked robustness and scalability.
● High accuracy
● Learns complex features
● Suitable for static gesture classification
Disadvantages:
Advantages:
Good generalization
Disadvantages:
13
The modern approach uses landmark-based detection instead of pixel segmentation.
MediaPipe uses:
The landmark model predicts 3D coordinates of hand joints. Finger counting can be implemented using
geometric comparisons between tip and joint positions.
Advantages:
● Real-time performance
● Lighting robust
● Multi-hand support
● No heavy dataset training required
14
Python
Widely used programming language due to its extensive AI ecosystem and ease of implementation.
OpenCV
Used for:
● Video capturing
● Frame processing
● Image transformations
● Drawing overlays
MediaPipe
Provides:
NumPy
Used for numerical operations and coordinate calculations.
Streamlit
Used for building interactive web-based UI for real-time applications.
WebRTC
Enables real-time video streaming in browser-based applications.
● Higher accuracy
15
● Low latency
● Device independence
● Scalability
Deep learning models combined with efficient frameworks such as MediaPipe have significantly
enhanced real-time gesture recognition performance.
Therefore, the proposed system adopts a landmark-based approach using MediaPipe integrated with
OpenCV and Streamlit to achieve efficient and accurate finger counting.
16
CHAPTER-3
SYSTEM ANALYSIS
17
3. SYSTEM ANALYSIS
System Analysis is the process of examining the proposed Hand Gesture Recognition System to
understand its requirements, feasibility, performance expectations, and constraints. The primary goal of
this system is to detect and count raised fingers in real time using computer vision and machine learning
techniques.
The system captures live video through a webcam and processes frames using OpenCV and MediaPipe
libraries. It identifies hand landmarks and applies geometric logic to determine which fingers are raised.
The final output is displayed in real time through an interactive Streamlit web interface.
This analysis ensures that the system is technically implementable, economically viable, and
operationally practical. It also defines functional and non-functional requirements clearly before
development and deployment.
The system does not require specialized hardware and runs efficiently on standard computing devices.
Since the implementation is based on Python and open-source tools, the development cost is minimal.
The design focuses on real-time performance, accuracy, ease of use, and scalability. The analysis phase
helps in identifying possible risks such as lighting dependency, camera quality issues, and performance
bottlenecks.
Overall, the system is designed to be lightweight, efficient, and user-friendly while maintaining high
accuracy in finger counting tasks.
Feasibility study evaluates whether the proposed system can be developed successfully within available
resources and constraints.
18
The required software tools are stable, well-documented, and widely supported. Hence, the project is
technically achievable.
The system is easy to operate and can be used by students, researchers, and developers without
difficulty.
Since the project requires only a basic computer and webcam, it is highly economical.
19
● The primary input is real-time image frames captured from the camera.
The processing is performed continuously for each frame to ensure real-time response.
20
3.3.2 Usability Requirements
21
3.4.1 Hardware Requirements
Component Specification
Minimum 4 GB (8 GB
RAM recommended)
Software Version/Details
22
CHAPTER-4
SOFTWARE ENVIRONMENT
23
4. SOFTWARE ENVIRONMENT
The Software Environment defines the technological ecosystem used to design, develop, test, and
deploy the Hand Gesture Recognition System for Finger Counting. The system is developed using
Python as the core programming language due to its simplicity and extensive AI/ML library support.
The project relies on OpenCV for image processing and MediaPipe for real-time hand landmark
detection.
The application interface is built using Streamlit, which enables rapid development of web-based
interactive applications. Real-time video streaming is achieved through the Streamlit-WebRTC
framework. NumPy is used for numerical computations and coordinate comparisons during finger
counting.
The software stack is lightweight and platform-independent, allowing execution on Windows, Linux,
and macOS systems. All libraries used are open-source and actively maintained. The development
environment supports rapid prototyping and real-time testing.
The system does not require high-end infrastructure and can run on a standard laptop with a webcam.
The modular design ensures scalability and future enhancement capabilities.
The proposed system is platform-independent and can operate on multiple operating systems such as
Windows, Linux, and macOS. During development and testing, Windows 10/11 was primarily used
due to compatibility with Python libraries and ease of installation.
The operating system provides support for webcam drivers, Python runtime environment, and necessary
dependencies for OpenCV and MediaPipe. It also manages hardware resource allocation such as CPU
and memory usage.
The system does not require any specialized OS configuration. It runs in a browser environment through
Streamlit, making it flexible and accessible. The cross-platform capability ensures wider usability and
deployment in academic and research environments.
24
4.2 Programming Language & Algorithm
Algorithm Steps:
1. Capture video frame
2. Convert BGR image to RGB
3. Detect hand landmarks using MediaPipe
4. Extract fingertip coordinates
5. Compare fingertip with lower joint
6. If fingertip is above joint → Finger is raised
7. Repeat for all fingers
8. Display total count
# Other fingers
for tip_id in FINGER_TIPS:
if landmarks[tip_id].y < landmarks[tip_id - 2].y:
finger_count += 1
25
Explanation:
● landmarks[tip_id].y < landmarks[tip_id - 2].y checks if finger tip is above lower joint.
● Thumb logic is based on horizontal position (X-axis).
● Works efficiently in real time.
1. OpenCV
● Video capture
● Frame processing
● Drawing text and shapes
● Image transformations
2. MediaPipe
● Real-time hand detection
● 21 landmark prediction
● Optimized ML model
3. NumPy
● Array operations
● Coordinate comparison
● Mathematical computations
4. Streamlit
● Web-based UI
● Real-time display
● Interactive deployment
5. Streamlit-WebRTC
● Real-time video streaming
● Browser-based camera access
26
IDEs Used:
● Visual Studio Code (VS Code)
● PyCharm
● Jupyter Notebook (for testing algorithms)
Tools Used:
● Python Interpreter
● Pip Package Manager
● Git (for version control)
● Web Browser (Chrome/Edge) for Streamlit app
VS Code is preferred due to extensions, debugging tools, and integrated terminal support. The
development tools simplify coding, debugging, and deployment.
For advanced deep learning models, GPU acceleration can improve performance. However, for finger
counting, CPU processing is sufficient.
Deployment Options:
● Local deployment (streamlit run [Link])
● Cloud deployment (Streamlit Cloud, Heroku, AWS)
● Browser-based access
● Cross-device compatibility
The system runs locally without storing video data externally. It can also be hosted online for remote
access.
27
4.7 Version Control & Collaboration
Version control is important for managing code updates and collaboration.
Tools Used:
● Git
● GitHub / GitLab (optional repository hosting)
Benefits:
● Track code changes
● Maintain project history
● Support team collaboration
● Easy rollback to previous versions
● Manage feature updates
Using version control ensures project reliability and structured development workflow.
28
CHAPTER-5
SYSTEM DESIGN
29
5. SYSTEM DESIGN
System Design defines the overall architecture and structure of the Hand Gesture Recognition System
for Finger Counting. It describes how input data is collected, processed, and converted into meaningful
output. The system is designed using a modular approach to ensure scalability, maintainability, and
real-time performance.
● Input Module
● Processing Module
● Output Module
The webcam captures live video frames which are processed using OpenCV and MediaPipe. The
detected landmarks are analyzed using a geometric algorithm to count raised fingers. The final result is
displayed on the screen through the Streamlit interface.
The system is lightweight and follows a real-time processing pipeline. It supports detection of up to two
hands simultaneously and calculates the total finger count dynamically. The architecture ensures
smooth execution with minimal latency.
Input Design focuses on how data is captured and provided to the system for processing.
In this project, the primary input is live video captured from a webcam. The video stream consists of
continuous image frames. Each frame is processed individually.
Input Components:
30
4. Image converted from BGR to RGB
5. Frame passed to MediaPipe model
The input module is designed to ensure smooth and continuous video acquisition without interruption.
Output Design defines how the processed results are presented to the user.
The system displays results in real time through a web-based Streamlit interface. The detected hand
landmarks are drawn on the screen, and the total finger count is displayed clearly.
Output Components:
31
5.3 Data Flow Diagram (DFD)
Explanation
In this project, the system does not take static hand images as input. Instead, it continuously captures
live video frames from the webcam and processes them in real time.
There is no gesture dictionary, database, or command execution module in your system. The output is
simply the total number of raised fingers.
32
33
34
DFD Components Explanation
External Entity:
● User (Shows hand gesture)
Process 1:
● Webcam Video Capture
Process 2:
● Frame Preprocessing (Flip + RGB Conversion)
Process 3:
● MediaPipe Hand Detection
Process 4:
● Landmark-Based Finger Counting
Process 5:
● Display Module (Streamlit UI)
Data Flow:
● Live Video Frames
● Landmark Coordinates
● Finger Count Value
In the Hand Gesture Recognition System for Finger Counting, UML diagrams are used to illustrate the
system structure and behavior clearly. These diagrams provide a visual representation of how different
modules such as webcam input, hand detection, finger counting logic, and display interface interact
with each other.
35
● Represent system architecture clearly
● Define relationships between components
● Show interaction between user and system
● Explain data flow and processing steps
● Improve system documentation
● Assist in debugging and maintenance
● Provide clarity for academic evaluation
1. Structural Diagrams
Thesediagramsdescribethestaticstructureofthesystem.
Examples:
● Class Diagram
● Object Diagram
● Component Diagram
● Deployment Diagram
In this project, the Class Diagram is used to represent system classes such as video processor, hand
detector, and UI module.
2. Behavioral Diagrams
Thesediagramsrepresentdynamicbehaviorandinteractions.
Examples:
Thus, UML plays a vital role in clearly defining and documenting the design of the proposed real-time
finger counting system. It ensures better understanding, scalability, and maintainability of the software
architecture.
36
[Link] Use Case Diagram
Explanation
The Use Case Diagram represents interaction between the user and the system.
In this project, the primary actor is the User who interacts with the system through webcam gestures.
● Capture Video
● Detect Hand
● Count Fingers
The user only provides gesture input, while the system automatically processes and displays the result.
37
Explanation
The Class Diagram represents the static structure of the system.
Main Classes:
Relationships:
● Stream lit App initializes Hand Tracking Processor
● Hand Tracking Processor uses MediaPipe Hands
● Finger Counter processes landmark data
● Output is displayed via Stream lit App
38
Explanation
The Sequence Diagram shows how objects interact in a time sequence when the system runs.
Flow:
1. User starts app
2. Webcam captures frame
3. Frame sent to Hand Tracking Processor
4. MediaPipe detects landmarks
5. Finger Counter calculates count
6. Result returned to UI
7. Display updated
39
Explanation
The Activity Diagram represents workflow of the system from start to finish.
Steps:
● Start
● Activate Webcam
● Capture Frame
● Convert to RGB
● Detect Hand
40
● Are Hands Detected?
● Display Count
● Repeat
41
CHAPTER-6
IMPLEMENTATION
42
6. IMPLEMENTATION
import streamlit as st
import cv2
import mediapipe as mp
import numpy as np
import av
from streamlit_webrtc import webrtc_streamer, VideoProcessorBase
mp_drawing = [Link].drawing_utils
mp_hands = [Link]
class HandTrackingProcessor(VideoProcessorBase):
def __init__(self):
[Link] = mp_hands.Hands(min_detection_confidence=0.8,
min_tracking_confidence=0.5,
max_num_hands=2)
results = [Link](image_rgb)
total_fingers = 0
43
mp_drawing.DrawingSpec(color=(250, 44, 250), thickness=2, circle_radius=2)
)
landmarks = hand_landmarks.landmark
label = [Link][0].label # "Left" or "Right"
finger_count = 0
if label == "Right":
if landmarks[THUMB_TIP].x < landmarks[THUMB_TIP - 1].x:
finger_count += 1
else:
if landmarks[THUMB_TIP].x > landmarks[THUMB_TIP - 1].x:
finger_count += 1
total_fingers += finger_count
# Streamlit UI
st.set_page_config(page_title="Finger Counter with MediaPipe", layout="centered")
[Link]("✋ Real-time Finger Count using MediaPipe & Streamlit")
webrtc_streamer(
key="finger-counter",
video_processor_factory=HandTrackingProcessor,
media_stream_constraints={"video": True, "audio": False}
)
44
45
7. OUTPUT SCREENS
46
47
CHAPTER-8
TESTING
48
8. TESTING
Testing is an important phase in software development that ensures the system functions correctly,
efficiently, and reliably. In the Hand Gesture Recognition System for Finger Counting, testing was
conducted to verify real-time performance, accuracy of finger detection, and overall system stability.
The testing process focused on validating whether the system correctly detects hand landmarks and
counts raised fingers under different conditions. Since the system processes live video input, special
attention was given to frame rate, latency, and detection accuracy.
Both functional and non-functional testing methods were applied. Functional testing ensured that the
webcam activates correctly, hand landmarks are detected, and finger counts are displayed accurately.
Non-functional testing evaluated system performance, usability, and responsiveness.
The system was tested under various lighting conditions such as low light, bright light, and normal
indoor lighting. It was also tested with different hand orientations, distances from the camera, and
multiple hand detection scenarios.
Edge cases such as partially visible hands, rapid movement, and background clutter were tested to
ensure robustness. Performance testing verified that the system maintains smooth operation at
approximately 15–30 frames per second without lag.
Compatibility testing was conducted on different operating systems and browsers to confirm cross-
platform functionality. The system was also tested for error handling, ensuring it does not crash when
no hand is detected.
Overall, testing confirms that the system performs reliably in real-time conditions and meets the project
objectives.
49
8.2 Sample Test Cases
Test Case
ID Test Scenario Input Condition Expected Output Actual Result Status
Webcam activates
TC01 Start Application Run Streamlit app successfully Webcam started Pass
TC07 Fast Movement Move hand quickly System tracks continuously Minor frame drop Pass
50
9. CONCLUSION
The Hand Gesture Recognition System for Finger Counting successfully demonstrates real-time
human-computer interaction using Computer Vision and Machine Learning techniques. The system
efficiently detects hand landmarks and accurately counts raised fingers using a geometric landmark-
based approach.
By leveraging MediaPipe and OpenCV, the project achieves real-time performance without requiring
complex model training or expensive hardware. The use of Streamlit provides an interactive and user-
friendly interface, making the application easy to operate.
The system performs reliably under various lighting conditions and supports detection of up to two
hands simultaneously. Testing results confirm that the solution meets functional and performance
requirements.
This project highlights the practical application of AI-based vision systems in touchless interaction
environments. It can be extended in the future to support advanced gesture recognition, sign language
translation, robotics control, or virtual classroom applications.
Overall, the project fulfills its objective of building an accurate, efficient, and scalable real-time finger
counting system using modern computer vision technologies.
51
10. REFERENCES
52