Project
Project
Project
A PROJECT REPORT
Submitted by
KAVIYADHARSHINI D S (411720104025)
HEMA DEEPIKA S P (411720104021)
IN
COMPUTER SCIENCE AND ENGINEERING
APRIL 2024
BONAFIDE CERTIFICATE
Certified that this project report “VIRTUAL PALETTE” is the bonafide work
of “KAVIYADHARSHINI D S (411720104025)”, “HEMA DEEPIKA S P
(411720104021)” carried out the project work under my supervision.
SIGNATURE SIGNATURE
i
ACKNOWLEDGEMENT
First and fore most we bow our head to the Almighty for being our light and for his
gracious showers of blessing throughout the course of this project.
We would like to express our sincere thanks to our founder and Chairman,
Dr. K. Vasudevan, M.A., B.Ed., Ph.D., for his endeavor in educating us in his premier
institution. We are grateful to our Vice Chairman, Dr. V. Vishnu Karthik, M.D., for his keen
interest in our studies and the facilities offered in the premier institution. We would like to
express our sincere gratitude to our Administrative Officer Mr. K. Parthasarathy, B.E., for his
assistance in all our endeavors.
We thank our Principal, Dr. G. Indira, M.E., Ph.D., for her valuable support and
encouragement in all our efforts throughout this course. We would like to express our sincere
thanks to our Dean Academics, Dr. V. Mahalakshmi, M.E., Ph.D., for her great support and
encouragement and moral support given to us during this course.
We would like to express our sincere thanks to our beloved Head of the Department,
Dr. M. Preetha, MTech., Ph.D., for his support and providing us with ample time to complete
our project. We wish to express our great deal of gratitude to our project Co-Ordinator,
Dr. M. Preetha, MTech., Ph.D., and our Guide, Ms. S. Senthurya, M.E., for their cooperation
towards us at all times of need, for their guidance and valuable suggestions in every aspect for
completion of this project.
We are also thankful to all faculty members and non-teaching staffs of all Departments for
their support. Finally, we are grateful to our family and friends for their help, encouragement and
moral support given to us during our project work.
ii
ABSTRACT
Additionally, the application must offer a diverse range of drawing tools and
customization options to cater to the varied preferences and artistic styles of
users. This includes providing a selection of colors, brush sizes, and other
creative elements to enhance the drawing.
iii
TABLE OF CONTENTS
CHAPTER NO TITLE PG NO
ABSTRACT iii
1 INTRODUCTION 1
1.1 Introduction 1
1.4 Motivation 17
2 LITERATURE SURVEY 20
3 ANALYSIS 30
iii
3.3.1 Hardware components 39
3.4 Methodology 43
4 SYSTEM ARCHITECTURE 50
4.1 Modules 54
5 TYPES OF TESTING 61
6 ACCURACY 68
7 CONCLUSION 73
7.1 Applications 73
7.2 Advantages 75
APPENDICES
REFERENCES 100
iii
LIST OF FIGURES
iii
iii
CHAPTER 1
INTRODUCTION
1.1 INTRODUCTION
1
• Library Ecosystem: Python's vast library ecosystem includes powerful tools
like OpenCV and Media Pipe, which provide efficient solutions for computer
vision tasks without requiring extensive low-level coding.
• Computer Vision: Python, along with the OpenCV library, enables the
processing and analysis of visual data obtained from the webcam feed.
Understanding computer vision concepts such as image manipulation,
object detection, and feature extraction is crucial for this project.
2
• Gesture Recognition: Hand gesture recognition involves identifying and
interpreting gestures made by the user's hand. Python, coupled with
libraries like Media Pipe, simplifies the implementation of gesture
recognition algorithms by providing pre-trained models and easy-to-use
APIs.
• Practical Steps for Getting Started: To begin working on the real-time hand
gesture recognition and drawing project, follow these practical steps:
Python Installation: Install Python from the official website or using a package
manager like Anaconda, which includes popular libraries and tools for data
science and machine learning.
3
• Hands-on Projects: Start by implementing basic hand gesture recognition
tasks using OpenCV. Gradually increase the complexity of the project by
integrating Media Pipe for more advanced gesture recognition capabilities.
Further Exploration:
4
• User Interface Development: Enhance the user experience of your application
by developing a graphical user interface (GUI). Python offers several GUI
frameworks such as Tkinter, PyQt, and Kivy, which allow you to create
interactive and visually appealing interfaces for your real-time hand gesture
recognition and drawing application.
To gain further inspiration and insight into real-time hand gesture recognition and
drawing projects, consider exploring the following examples:
5
• Gesture-Based Interfaces: Investigate projects that utilize hand gestures as a
means of interacting with digital interfaces. Explore applications in fields
such as gaming, virtual reality, and augmented reality, where hand gestures
are used to control characters, manipulate objects, or navigate virtual
environments.
6
• Artistic Expressions: Discover projects that explore the intersection of art and
technology through real-time hand gesture recognition and drawing. Explore
applications where hand gestures are used as a medium for artistic
expression, enabling users to create dynamic and interactive artworks through
gesture-based interactions.
7
• Community Forums and Discussions: Join Python communities, forums, and
discussion groups to connect with fellow developers, ask questions, and share
insights. Platforms like Stack Overflow, Reddit, and GitHub offer valuable
resources and support for troubleshooting, collaboration, and knowledge
sharing.
Engage with opensource projects and collaborative initiatives in the field of real-
time interaction and gesture recognition to gain practical experience, contribute to
the community, and expand network:
8
• GitHub Repositories: Explore GitHub repositories related to computer vision,
machine learning, and interactive applications. Contribute to opensource
projects, submit pull requests, and collaborate with developers from around
the world to enhance existing projects and create new ones.
9
Ethical Considerations and Responsible Development:
Python for real-time hand gesture recognition and drawing, it's essential to consider
the ethical implications and responsibilities associated with developing and
deploying such technologies:
• Privacy and Consent: Respect user privacy and obtain consent before
collecting or processing any personal data, including hand gesture data.
Implement privacy-preserving measures to safeguard sensitive information
and ensure compliance with relevant regulations and guidelines.
10
• Accessibility and Usability: Design your applications with accessibility in
mind to ensure that they are usable and inclusive for all users, including those
with disabilities or special needs. Consider providing alternative input
methods and customization options to accommodate diverse user preferences
and requirements.
• Social Impact and Responsibility: Consider the broader social and ethical
implications of your work and strive to create positive societal impact
through responsible and ethical development practices. Engage with
stakeholders, seek feedback from affected communities, and prioritize the
well-being and interests of all individuals affected by your technology.
Harness the power of Python for real-time hand gesture recognition and drawing,
remember the importance of ethical considerations and responsible development
practices. By prioritizing privacy, fairness, transparency, accessibility, and social
impact, you can ensure that your projects contribute positively to society while
empowering users to interact with technology in meaningful and engaging ways.
Embrace the principles of ethics and responsibility as integral components of your
journey as a Python developer and technology innovator.
This concludes the detailed introduction to Python for the real-time hand gesture
recognition and drawing project, emphasizing the ethical considerations and
11
responsibilities associated with developing and deploying such technologies. By
adopting a holistic approach that integrates technical expertise with ethical
principles, you can create impactful and socially responsible projects that enhance
the human experience and promote the common good.
Artistic expression has long been a fundamental aspect of human culture, enabling
individuals to communicate, reflect, and innovate. With the advent of digital
technology, the ways in which people create art have evolved, opening up new
avenues for creativity and exploration.
In recent years, the intersection of computer vision and interactive systems has
given rise to novel applications that enable users to engage with digital art in
innovative ways. One such application is the real-time interactive drawing program
developed using Python and the Media Pipe library, which harnesses the power of
hand gestures to facilitate digital sketching.
This introduction explores the motivation behind the development of the real-time
interactive drawing program, delving into the significance of digital art and the role
of technology in fostering creative expression. We begin by discussing the
evolution of digital art and the challenges associated with traditional drawing
software. We then introduce the concept of interactive drawing applications and
highlight the unique features and capabilities of the program developed in this
paper.
12
1.2 PROBLEM DEFINITION
In the ever-evolving landscape of digital art, traditional writing methods are giving
way to innovative digital solutions. However, a significant challenge persists: the
lack of natural interaction, particularly in the realm of hand gesture recognition for
digital writing. As users seek more intuitive and efficient ways to express
themselves digitally, there is a pressing need to develop a robust system that
seamlessly translates hand gestures into digital actions, thereby enhancing the
digital writing experience.
At the heart of this challenge lies the task of recognizing human actions in real-time
using a camera. This involves capturing and interpreting hand gestures as they
occur, with minimal delay to ensure a seamless user experience. Achieving real-
time recognition is crucial for enabling responsive and fluid interaction in digital
writing applications.
Once the hand gestures are detected, the next hurdle is to translate these actions into
digital strokes on a canvas. This translation process must accurately capture the
intricacies of the gestures and render them as smooth and coherent brush strokes,
mimicking the natural flow of traditional writing instruments. The goal is to bridge
the gap between physical gestures performed by the user and their digital
representation on the canvas, creating a fluid and intuitive writing experience.
13
However, achieving accurate recognition and translation of hand gestures is no easy
feat. Variations in appearance, motion, and camera viewpoint pose significant
challenges. Lighting conditions, hand orientation, and camera angles can all impact
the recognition process, requiring the system to be robust and adaptable to diverse
scenarios.
Furthermore, the system must perform real-time processing of hand gestures while
maintaining high accuracy. It should capture subtle nuances in gesture movements
and translate them into precise digital strokes on the canvas. This level of accuracy
is essential for producing legible and aesthetically pleasing writing outcomes.
Ultimately, the success of this endeavor hinges on the system's ability to adapt to
variations in hand gestures across different users and scenarios. It must generalize
well to accommodate diverse writing styles, hand shapes, and movement patterns,
ensuring usability for a broad range of users.
14
1.3 OBJECTIVE OF THE PROJECT
• Translate Gestures into Digital Strokes on a Canvas: Once the hand gestures
are recognized, the next objective is to translate these gestures into digital
strokes on a canvas. The system should accurately map the detected gestures
to corresponding brush strokes, ensuring
smooth and coherent rendering on the digital canvas.
• Bridge the Gap between Human Actions and Digital Strokes: Another
objective is to bridge the gap between human actions captured through a
camera and their translation into digital brush strokes on a canvas. This
requires establishing a seamless connection between the physical gestures
performed by the user and the corresponding digital output, thereby creating
a natural and intuitive writing experience.
1.4 MOTIVATION
The motivation behind undertaking this project stems from several key factors:
18
to interact with digital content in novel and imaginative ways. By
empowering users to express themselves more freely and creatively, this
project aims to inspire innovation and spark new ideas in the digital writing
community.
In summary, the motivation behind this project lies in enhancing the digital writing
experience, addressing limitations of existing solutions, promoting accessibility and
inclusivity, exploring cutting-edge technologies, fostering innovation and creativity,
and meeting evolving user needs. By leveraging hand gesture recognition
technology, we aim to revolutionize the way users interact with digital platforms for
writing and communication, ultimately enriching their digital experiences and
empowering them to express themselves more effectively and creative.
19
CHAPTER 2
LITERATURE SURVEY
K Sai Sumanth Reddy, etal[1], 2022, use CNN techniques to first detect the
fingertip by an RGB camera. KCF tracker algorithm is used to convert the detected
hand region into HSV color space. The key disadvantage is that the researchers
compromised on the recognition of fingerprints by using basic algorithms. An
elementary framework which affects the accuracy of the system in real-time making
this project look downsized. the Hand landmark model to track the entire hand and
achieve accurate detection of hand coordinates within the detected hand regions.
This allows us to precisely capture the movement and position of the user's hand.
The model incorporates a gesture-based canvas, where different gestures
correspond to different operations. For instance, if a single index finger is detected,
the system enters the drawing/painting mode. This means that the user can freely
move their finger on the air canvas, and the system will capture their movements
and translate them into digital brush strokes on the canvas. This enables the user to
create digital art by simply using their finger as a brush. In addition, if two fingers,
specifically the index and ring fingers, are detected, the system switches to the
selection mode. In this mode, the user can perform selection operations, such as
choosing a specific element or area on the canvas.
20
G.Vijaya Raj Siddarth, etal[2], 2022, used the RCNN model to train its system for
faster and Regional Proposed Network (RPN) to detect the fingertip in the picture
captured by OpenCV. The system is fast at processing and good at averaged
accuracy.
The presence of any red color in the background leads to false and error predictions
while using the application. Hand landmarks for detecting hand gives out a precise
analysis of palm recognition compared to all the other existing methods/systems.
The minimal improvement needed to answer is that in this proposed system,
switching and performing the various availabilities always requires physical effort
to change the modes like from Writing to Painting, depicting shapes instead of
scribblings, Editing pdf, and Saving the work on canvas into an image. An
elementary framework which affects the accuracy of the system in real-time making
this project look downsized. the Hand landmark model to track the entire hand and
achieve accurate detection of hand coordinates within the detected hand regions.
This allows us to precisely capture the movement and position of the user's hand.
The model incorporates a gesture-based canvas, where different gestures
correspond to different operations. For instance, if a single index finger is detected,
the system enters the drawing/painting mode. This means that the user can freely
move their finger on the air canvas, and the system will capture their movements
and translate them into digital brush strokes on the canvas.
21
M. Bhargavi, etal[3], 2022, use hand landmarks for detecting hand gives out a
precise analysis of palm recognition compared to all the other existing
methods/systems. Used Python Tkinter to open PDF files and annotate/edit.
Requires physical effort to change the modes like from Writing to Painting,
depicting shapes instead of scribblings, editing pdf, and saving the work on canvas
into an image. The key disadvantage is that the researchers compromised on the
recognition of fingerprints by using basic algorithms. An elementary framework
which affects the accuracy of the system in real-time making this project look
downsized. the Hand landmark model to track the entire hand and achieve accurate
detection of hand coordinates within the detected hand regions. This allows us to
precisely capture the movement and position of the user's hand. The model
incorporates a gesture-based canvas, where different gestures correspond to
different operations. For instance, if a single index finger is detected, the system
enters the drawing/painting mode. This means that the user can freely move their
finger on the air canvas, and the system will capture their movements and translate
them into digital brush strokes on the canvas. This enables the user to create digital
art by simply using their finger as a brush. In addition, if two fingers, specifically
the index and ring fingers, are detected, the system switches to the selection mode.
In this mode, the user can perform selection operations, such as choosing a specific
element or area on the canvas.
22
Zhou Ren, etal[4],2013, used the Kinect sensor's depth and color data to determine
the hand's form. The process of gesture detection is still relatively difficult even
with the Kinect sensor. It's challenging to track something that's as small as a
finger. Hand landmarks for detecting hand gives out a precise analysis of palm
recognition compared to all the other existing methods/systems. The minimal
improvement needed to answer is that in this proposed system, switching and
performing the various availabilities always requires physical effort to change the
modes like from Writing to Painting, depicting shapes instead of scribblings,
Editing pdf, and Saving the work on canvas into an image. An elementary
framework which affects the accuracy of the system in real-time making this project
look downsized. the Hand landmark model to track the entire hand and achieve
accurate detection of hand coordinates within the detected hand regions. This
allows us to precisely capture the movement and position of the user's hand. The
model incorporates a gesture-based canvas, where different gestures correspond to
different operations. For instance, if a single index finger is detected, the system
enters the drawing/painting mode. This means that the user can freely move their
finger on the air canvas, and the system will capture their movements and translate
them into digital brush strokes on the canvas.
23
Andrea Urru, etal[5], 2022, involves placing an LED on the user's finger and
tracking it with the web camera. The character which is stored in the database will
be compared with the one that was drawn. It is also necessary that the LED light is
the only thing that is red in the web camera's field of view. Hand landmarks for
detecting hand gives out a precise analysis of palm recognition compared to all the
other existing methods/systems. The minimal improvement needed to answer is that
in this proposed system, switching and performing the various availabilities always
requires physical effort to change the modes like from Writing to Painting,
depicting shapes instead of scribblings, Editing pdf, and Saving the work on canvas
into an image. An elementary framework which affects the accuracy of the system
in real-time making this project look downsized. the Hand landmark model to track
the entire hand and achieve accurate detection of hand coordinates within the
detected hand regions. This allows us to precisely capture the movement and
position of the user's hand. The model incorporates a gesture-based canvas, where
different gestures correspond to different operations. For instance, if a single index
finger is detected, the system enters the drawing/painting mode. This means that the
user can freely move their finger on the air canvas, and the system will capture their
movements and translate them into digital brush strokes on the canvas.
24
Sahil Agrawal, etal[6], 2022, built the application in such a way that different
gestures shown in front of the camera are detected and the corresponding actions
are performed. 1-finger up – Drawing mode 2-fingers up – Selection mode All
fingers up – Clear all. Can focus on refining the system's performance under
challenging conditions and exploring additional features to enhance the overall user
experience.
The system is fast at processing and good at averaged accuracy. The presence of
any red color in the background leads to false and error predictions while using the
application. Hand landmarks for detecting hand gives out a precise analysis of palm
recognition compared to all the other existing methods/systems. The minimal
improvement needed to answer is that in this proposed system, switching and
performing the various availabilities always requires physical effort to change the
modes like from Writing to Painting, depicting shapes instead of scribblings,
Editing pdf, and Saving the work on canvas into an image. An elementary
framework which affects the accuracy of the system in real-time making this project
look downsized. the Hand landmark model to track the entire hand and achieve
accurate detection of hand coordinates within the detected hand regions. This
allows us to precisely capture the movement and position of the user's hand.
25
Revati Khade, etal[7], 2019, proposed a vision-based algorithm to recognize hand
gesture from image data. A framework for hand gesture recognition using deep
feature fusion network based on wearable sensors is proposed. A residual module is
introduced to avoid over fitting and gradient vanishing during deepening the neural
network. Used Python Tkinter to open PDF files and annotate/edit. Requires
physical effort to change the modes like from Writing to Painting, depicting shapes
instead of scribblings, editing pdf, and saving the work on canvas into an image.
The key disadvantage is that the researchers compromised on the recognition of
fingerprints by using basic algorithms. An elementary framework which affects the
accuracy of the system in real-time making this project look downsized. the Hand
landmark model to track the entire hand and achieve accurate detection of hand
coordinates within the detected hand regions. This allows us to precisely capture the
movement and position of the user's hand. The model incorporates a gesture-based
canvas, where different gestures correspond to different operations. For instance, if
a single index finger is detected, the system enters the drawing/painting mode. This
means that the user can freely move their finger on the air canvas, and the system
will capture their movements and translate them into digital brush strokes on the
canvas. This enables the user to create digital art by simply using their finger as a
brush. In addition, if two fingers, specifically the index and ring fingers, are
detected, the system switches to the selection mode. In this mode, the user can
perform selection operations, such as choosing a specific element or area on the
canvas.
26
S.U. Saoji, etal[8], 2021, conducted on the system involved collecting data from
users performing a variety of gestures using the glove with integrated sensors. The
performance of the system was evaluated using a variety of metrics, including
accuracy, precision, recall, and F1 score. One limitation is the need for a large
amount for labelled data for training the machine learning algorithms. The minimal
improvement needed to answer is that in this proposed system, switching and
performing the various availabilities always requires physical effort to change the
modes like from Writing to Painting, depicting shapes instead of scribblings,
Editing pdf, and Saving the work on canvas into an image. An elementary
framework which affects the accuracy of the system in real-time making this project
look downsized. the Hand landmark model to track the entire hand and achieve
accurate detection of hand coordinates within the detected hand regions. This
allows us to precisely capture the movement and position of the user's hand. The
model incorporates a gesture-based canvas, where different gestures correspond to
different operations. For instance, if a single index finger is detected, the system
enters the drawing/painting mode. This means that the user can freely move their
finger on the air canvas, and the system will capture their movements and translate
them into digital brush strokes on the canvas.
27
P. Ramasamy, etal[9], 2022, consumed Data acquisition, gesture recognition
representation, data environment and image processing. Performance of existing
gesture recognition detection systems with its efficiency and output accuracy
Data from six-degree-of freedom hand motions is used to generate a set of
characters or words. An elementary framework which affects the accuracy of the
system in real-time making this project look downsized. the Hand landmark model
to track the entire hand and achieve accurate detection of hand coordinates within
the detected hand regions. This allows us to precisely capture the movement and
position of the user's hand. The model incorporates a gesture-based canvas, where
different gestures correspond to different operations. For instance, if a single index
finger is detected, the system enters the drawing/painting mode. This means that the
user can freely move their finger on the air canvas, and the system will capture their
movements and translate them into digital brush strokes on the canvas. The minimal
improvement needed to answer is that in this proposed system, switching and
performing the various availabilities always requires physical effort to change the
modes like from Writing to Painting, depicting shapes instead of scribblings,
Editing pdf, and Saving the work on canvas into an image.
28
Adinarayana Salina, etal[10], 2022, used the Fingertip detection is the system which
only works with your fingers, and there are no such devices like highlighters.
Lack of pen up and down movement of the system uses RGB camera to write from
starting since depth sensing is not possible. The entire trajectory of the fingertip is
tracked and the resulting image is meaningless. The system is fast at processing and
good at averaged accuracy. The presence of any red color in the background leads
to false and error predictions while using the application. Hand landmarks for
detecting hand gives out a precise analysis of palm recognition compared to all the
other existing methods/systems. The minimal improvement needed to answer is that
in this proposed system, switching and performing the various availabilities always
requires physical effort to change the modes like from Writing to Painting,
depicting shapes instead of scribblings, Editing pdf, and Saving the work on canvas
into an image. An elementary framework which affects the accuracy of the system
in real-time making this project look downsized. the Hand landmark model to track
the entire hand and achieve accurate detection of hand coordinates within the
detected hand regions. This allows us to precisely capture the movement and
position of the user's hand. The model incorporates a gesture-based canvas, where
different gestures correspond to different operations. For instance, if a single index
finger is detected, the system enters the drawing/painting mode.
29
CHAPTER 3
SYSTEM ANALYSIS
The existing system utilizes hand gloves integrated with LED (Light Emitting
Diode) technology to facilitate hand gesture recognition and digital writing
applications. These gloves are equipped with sensors and strategically positioned
LEDs, typically located on the fingertips or along the hand's surface. The system
operates on the principle of detecting hand gestures through the activation and
detection of LEDs, enabling intuitive interaction with digital interfaces.
In this system, the hand gloves serve as the primary interface between the user and
the digital system. Made of flexible and lightweight materials, these gloves ensure
comfort and ease of movement during use. Embedded sensors or conductive fabric
detect changes in electrical conductivity as the user performs hand gestures. The
LEDs, integrated into the gloves, emit light signals corresponding to detected
gestures, providing visual feedback to the user.
30
A microcontroller or processing unit receives and processes data from the sensors to
recognize hand gestures. It analyzes input signals, determines the corresponding
gestures, and triggers appropriate actions or responses in real-time. The system is
powered by a battery or external power source to supply the necessary energy for
operation.
In summary, the existing system of hand gloves with LED technology provides an
intuitive and interactive solution for hand gesture recognition and digital writing
applications. Despite its advantages, there is room for improvement to further
enhance functionality, usability, and accessibility. Continued research and
31
innovation in this area hold the potential to unlock new possibilities for intuitive
and seamless interaction with digital interfaces.
The motivation behind the development and utilization of hand gloves with LED
technology lies in the pursuit of more intuitive and natural interfaces for digital
interaction. Traditional input methods such as keyboards and touchscreens can
sometimes feel disconnected from the user's intentions, leading to inefficiencies and
frustrations. By integrating LED-equipped hand gloves into digital writing
applications, the aim is to bridge this gap and create a more immersive and
responsive user experience.
One of the key advantages of hand gloves with LED technology is their ability to
provide real-time feedback to users. As users perform hand
Moreover, hand gloves with LED technology offer customization options that cater
to individual user preferences and requirements. Users can define their gesture
patterns and corresponding LED responses, allowing for personalized interaction
with digital applications. This flexibility empowers users to tailor their digital
writing experience to suit their unique needs and preferences, further enhancing
usability and satisfaction.
32
Additionally, the portability and flexibility of hand gloves make them suitable for a
wide range of applications and environments. Whether used in educational settings,
professional workplaces, or creative endeavors, hand gloves with LED technology
offer a versatile and accessible solution for digital interaction. Their lightweight and
ergonomic design ensure comfort during extended use, while their wireless
functionality allows for seamless integration into existing digital workflows.
Looking ahead, the development of hand gloves with LED technology represents an
exciting opportunity for innovation and advancement in human-computer
interaction. Continued research and refinement of gesture recognition algorithms,
integration with wearable technology, and exploration of new use cases will further
expand the possibilities for intuitive and immersive digital interaction. Ultimately,
the motivation behind this project is to empower users with more natural and
expressive ways to engage with digital content, fostering creativity, productivity,
and enjoyment in the digital realm.
2. Digital Canvas Interface: A digital canvas interface serves as the platform for
users to create, edit, and interact with digital content. This interface provides tools
for writing, drawing, and manipulating objects on the canvas, offering a rich and
34
dynamic environment for creative expression. Users can select different brush types,
colors, and sizes, as well as access additional features such as text input and image
insertion.
35
1. Gesture Recognition and Mapping: The system captures hand gestures using
a camera or depth sensor and analyzes them using advanced computer vision
algorithms. Each recognized gesture is mapped to a specific action or
command within the digital canvas interface, allowing users to perform
various tasks intuitively and efficiently.
2. Writing and Drawing: Users can write, draw, and sketch directly on the
digital canvas using natural hand movements. Gestures such as finger tracing,
flicking, or tapping are interpreted as strokes, lines, or shapes, enabling users
to create intricate designs and expressive artworks with ease.
3. Editing and Manipulation: The system provides tools for editing and
manipulating digital content on the canvas. Users can select, move, resize,
rotate, and delete objects using gestures, as well as apply transformations,
filters, and effects to enhance their creations.
36
integration with emerging technologies, and optimization of the user
experience to meet the evolving needs of users in digital content creation.
7. Gesture Recognition:
8. Drawing on Canvas:
- A key feature of the proposed system is the ability to draw on a virtual canvas
using hand gestures.
- Users can utilize hand movements to control the position, shape, and color of
the drawing strokes, enabling intuitive and natural digital artwork creation.
9.Color Selection:
37
- The system provides a color selection mechanism that allows users to choose
from a predefined color palette using hand gestures.
- By selecting different colors, users can personalize their drawings and artwork,
enhancing creative expression and customization options.
38
- The system offers customization options to tailor the user experience according
to individual preferences and requirements.
- Users can adjust settings such as brush size, drawing mode, and interface layout
to suit their workflow and artistic style.
39
3.3.1 Hardware components:
6. Power Source: Ensure that your computer and webcam are connected to a
40
reliable power source to prevent interruptions during hand tracking sessions.
If using a laptop, ensure that the battery is fully charged or connected to a
power outlet.
7. USB Cables: USB cables are required to connect the webcam to the computer
for video streaming and data transfer. Use high-quality USB cables with
sufficient length to ensure a stable connection and minimize signal
interference.
8. Optional Accessories: Depending on your specific setup and requirements,
you may also consider additional accessories such as extension cables, USB
hubs, or external microphones for audio input. These accessories can help
optimize the hand tracking setup and improve overall performance.
41
Google for building machine learning-based applications. It provides ready-to-use
solutions for various tasks, including hand tracking, pose estimation, and object
detection. Install Media Pipe using pip
6. Webcam Drivers and Software: Ensure that your webcam drivers are up-to-date
and compatible with your operating system. Additionally, check for any webcam
software provided by the manufacturer that may offer additional features or settings
for adjusting camera parameters.
By installing and configuring these software components, you can create a robust
42
hand tracking system using computer vision and Media Pipe in Python. Ensure that
all dependencies are properly installed and configured to ensure smooth integration
and operation of the hand tracking application.
3.4 METHODOLOGY:
1. Understanding Requirements:
43
- Based on the research findings, select appropriate tools and technologies for
implementing the hand tracking system.
- Choose computer vision libraries (e.g., OpenCV), machine learning frameworks
(e.g., Media Pipe), and programming languages (e.g., Python) suitable for the
project.
- Gather sample data for training and testing the hand tracking and gesture
recognition models.
- Collect a diverse set of hand images and videos to ensure robustness and
generalization of the models.
- Preprocess the data by cleaning, resizing, and augmenting to enhance model
performance.
- Train machine learning models for hand tracking and gesture recognition using
the collected data.
44
- Utilize techniques such as convolutional neural networks (CNNs) or deep
learning architectures to train the models.
7. Implementation of Modules:
45
10. User Feedback and Iterative Improvement:
- Gather feedback from users through usability testing and user feedback
sessions.
- Incorporate user suggestions and iterate on the design to improve user
experience and functionality.
46
- Deploy the system on target platforms, which may include desktop computers,
embedded systems, or mobile devices.
- Ensure seamless deployment by providing installation instructions, setup
guides, and troubleshooting resources for end-users.
- Provide user training sessions to familiarize users with the hand tracking system
and its functionalities.
- Develop user documentation, tutorials, and user manuals to facilitate self-
learning and troubleshooting.
- Establish a support system to address user inquiries, technical issues, and
feedback effectively.
- Implement security measures to protect sensitive data and ensure user privacy.
- Employ encryption techniques, access controls, and authentication mechanisms
to safeguard user information.
- Adhere to privacy regulations and best practices for handling user data and
maintaining confidentiality.
47
- Establish a maintenance plan for the hand tracking system to address bug fixes,
performance improvements, and software updates.
- Monitor system performance and user feedback to identify areas for
enhancement and optimization.
- Regularly update the system with new features, enhancements, and bug fixes to
ensure its relevance and effectiveness over time.
48
8. Continuous Improvement:
CHAPTER 4
SYSTEM ARCHITECTURE
49
Figure 4.1 Architecture diagram
Creating a comprehensive diagram for the modular design of the hand tracking
project requires visualization of the relationships between different modules and
their functionalities. Below is a representation of the diagram:
50
Figure 4.2 Module diagram
This representation illustrates the main components, their relationships, and the
flow of execution in the system. You can use this as a reference to create a visual
diagram using a drawing tool.
51
Each component in detail:
1.External Components:
2. Software Components:
3. Script:
- The script refers to the main Python script or program that orchestrates the hand
tracking project.
- It serves as the entry point and coordinates the execution of various
modules and functionalities.
52
- This section lists the libraries and modules imported and utilized within the
script.
- OpenCV (cv2), NumPy (np), and Media Pipe are mentioned as the key libraries
used for computer vision tasks, numerical operations, and hand tracking,
respectively.
- These are the specific modules or components defined within the script to handle
different functionalities.
- Dequeues: Used for storing the color points for drawing lines.
- Index Variables: Used to keep track of indices for different colors.
- Kernel: A NumPy array used for image processing operations like dilation.
- Colors and Color Index: Variables to manage color selection and indexing.
- Paint Window: Represents the window for displaying the drawing interface.
- Media Pipe Hands Module: Handles hand tracking and landmark detection using
the Media Pipe library.
- Media Pipe Drawing Utils: Provides utilities for drawing landmarks and
connections on the video frames.
6. Execution Flow:
- This section outlines the sequence of steps followed during the execution of the
script.
- It includes the main loop responsible for reading frames from the webcam,
performing hand tracking, processing user interactions, drawing on the canvas, and
53
displaying the output.
- After the main loop, there's a cleanup step to release resources such as the
webcam.
Each component plays a crucial role in the hand tracking project, contributing to the
overall functionality and user experience. By understanding the details of each
component, developers can effectively implement, debug, and optimize the system.
4.1 MODULES
4.1.1 LIST OF MODULES:
• Data Pre-Processing
• Data Visualization
• Hand Landmark Detection
• Gesture Recognition
• Drawing Functions
• Canvas Interaction
• Model Training
• Model Evaluation
• Model Deployment
54
• Data Pre-Processing
Description: This module manages the initial processing of input data captured
from the webcam or other sources before further analysis. It involves several
preprocessing steps to ensure the data is in a suitable format for subsequent
operations. These steps may include:
• Data Visualization
55
Description: This module focuses on visualizing the canvas and facilitating
user interaction within the drawing environment. It encompasses functions to
create, update, and manage the canvas interface, as well as interpret user inputs.
Key functionalities include:
56
• Hand Landmark Detection
• Functions:
- `detect_hand_regions`: Locates and isolates the user's hand within each
frame of the video feed.
- `locate_hand_landmarks`: Identifies key landmarks or keypoints on the
detected hand.
- `track_hand_movement`: Tracks the movement of hand landmarks over
time to enable dynamic interaction.
- `process_video_frames`: Analyzes video frames in real-time to detect and
update hand landmarks.
57
• Gesture Recognition
• Functions:
- `classify_gesture`: Analyzes hand landmark data to classify and recognize
user gestures.
- `trigger_action`: Executes corresponding actions or commands based on
recognized gestures.
- `train_gesture_model`: Trains machine learning models to classify gestures
using labeled data.
- `provide_feedback`: Offers feedback to the user regarding recognized
gestures and their effects on the drawing process.
58
• Drawing Functions
Description: This module provides tools and functionalities for drawing and
creating artistic elements on the canvas. It enables users to express their
creativity and ideas through various drawing operations. Key features include:
• Line and Stroke Drawing: Creating lines, curves, and strokes with different
thicknesses, colors, and styles.
• Shape Generation: Generating geometric shapes such as circles, rectangles,
and polygons with customizable attributes.
• Text Annotation: Adding text annotations, labels, or captions to the canvas to
convey additional information.
• Erasing and Editing: Implementing tools for erasing, undoing, and redoing
drawing actions to refine artwork.
• Functions:
- `draw_line`: Draws a line or stroke on the canvas with specified attributes
such as color, thickness, and style.
- `draw_shape`: Generates geometric shapes with customizable properties,
including size, position, and appearance.
- `add_text`: Inserts text annotations onto the canvas with options for font,
size, alignment, and color.
- `erase_drawing`: Implements tools for erasing or modifying existing
drawings on the canvas.
60
CHAPTER 5
TYPES OF TESTING
Definition:
Unit testing involves testing individual components or modules of the
hand tracking system in isolation.
Purpose:
The primary purpose of unit testing is to validate the correctness of specific
functions or classes within the system. It helps identify bugs, errors, or unexpected
behavior at an early stage of development.
Example:
In the context of hand tracking, unit tests could verify the functionality of
functions responsible for processing video frames, detecting hand landmarks, or
drawing annotations on the image. For instance, a unit test may ensure that the
function to detect hand landmarks returns the expected results for a given input
image.
61
2.Integration Testing:
Definition:
Integration testing focuses on testing the interactions and integration
between different components of the hand tracking system.
Purpose:
Integration testing ensures that individual components work together
seamlessly and produce the expected results when integrated. It helps identify
issues related to communication, compatibility, or data exchange between different
modules.
Example:
Integration tests for hand tracking may involve verifying the integration of
the webcam with the computer, the interaction between OpenCV and Media Pipe
libraries, and the overall system behavior when processing video frames in real-
time.
3. Functional Testing:
Definition:
Functional testing evaluates the system's functionality from an end-user
perspective.
62
Purpose:
Functional testing ensures that the hand tracking system meets the specified
requirements and delivers the intended functionality. It verifies that the system
correctly detects and tracks hand movements, annotates hand landmarks on the
video feed, and responds appropriately to different hand gestures.
Example:
Functional tests for hand tracking may involve verifying that the system
accurately detects hand movements, tracks hand landmarks with high precision, and
correctly interprets different gestures such as open hand, closed fist, or finger
pointing.
4. Performance Testing:
Definition:
Performance testing evaluates the speed, responsiveness, and efficiency of
the hand tracking system under various conditions.
Purpose:
Performance testing helps identify bottlenecks, optimize resource utilization,
and ensure that the system meets performance requirements. It measures parameters
such as frame rate, latency, and resource consumption to assess the system's
performance and scalability.
63
Example:
Performance tests for hand tracking may involve measuring the frame rate
of the video feed, analyzing the latency between hand movements and annotations
on the image, and assessing the system's CPU and memory usage under different
load conditions.
5.Stress Testing:
Definition:
Stress testing subjects the hand tracking system to extreme or challenging
conditions to assess its stability and robustness.
Purpose:
Stress testing helps identify vulnerabilities, assess fault tolerance, and
ensure that the system remains stable under adverse conditions. It involves testing
the system's performance with multiple users, in low-light environments, or with
occluded hand movements.
Example:
Stress tests for hand tracking may involve simulating scenarios with
multiple users interacting with the system simultaneously, testing the system's
performance in low-light conditions or high-motion environments, and assessing its
behavior when dealing with occluded or partially visible hands.
64
6.User Acceptance Testing (UAT):
Definition:
User acceptance testing involves testing the hand tracking system with
actual users to gather feedback and assess user satisfaction.
Purpose:
UAT validates the system's usability, intuitiveness, and user experience. It
helps identify usability issues, gather feedback from end-users, and ensure that the
system meets user expectations and requirements.
Example:
User acceptance tests for hand tracking may involve conducting usability
tests with target users to evaluate the system's ease of use, intuitiveness of hand
gestures, and overall satisfaction with the user interface and interaction experience.
7. Regression Testing:
Definition:
Regression testing involves retesting the hand tracking system after making
changes or updates to ensure that existing functionality remains unaffected.
Purpose:
Regression testing helps maintain the stability and reliability of the system
65
by ensuring that new changes do not introduce unintended regressions or break
existing functionality. It involves rerunning previously executed tests and verifying
that the system behaves as expected after updates.
Example:
Regression tests for hand tracking may involve retesting the system after
introducing new features, fixing bugs, or making code refactoring to ensure that
existing functionality remains intact and unchanged.
8. Error Handling and Edge Case Testing:
Definition:
Error handling and edge case testing involve testing the system's behavior in
unexpected or challenging scenarios.
Purpose:
Error handling testing ensures that the system gracefully handles errors,
exceptions, and unexpected inputs. Edge case testing assesses the system's behavior
in extreme or unusual situations, helping identify vulnerabilities and improve
robustness.
Example:
Error handling tests for hand tracking may involve deliberately introducing
errors or unexpected inputs to verify that the system handles them gracefully
without crashing or producing incorrect results. Edge case tests may involve testing
the system's behavior with rapid hand movements, complex gestures, or challenging
lighting conditions to assess its resilience and fault tolerance.
66
By implementing these testing strategies and considering each testing type's
purpose and examples, you can ensure thorough testing of your hand tracking
system, identify potential issues or vulnerabilities, and deliver a reliable, accurate,
and high-performance solution.
67
CHAPTER 6
ACCURACY
The project has been rigorously tested and found to be accurate and reliable in its
performance. It meets the intended objectives and provides a seamless user
experience, making it a successful implementation of a gesture-based drawing
application.
- The hand landmark detection provided by the Media Pipe library was
consistently accurate during testing.
- Landmarks were reliably detected across various hand positions and
orientations.
- Testing in different lighting conditions did not significantly affect landmark
detection accuracy.
- Overall, the hand landmark detection accuracy was high, with minimal instances
of misinterpretation or errors.
2. Drawing Precision:
- Hand movements were accurately translated into lines on the canvas without
noticeable jitteriness or lag.
- The program tracked hand movements smoothly, resulting in precise drawing
actions.
68
- Users reported that the drawn lines closely followed their hand movements,
indicating high drawing precision.
- Testing with different hand movements and speeds confirmed the program's
ability to accurately represent hand gestures on the canvas.
- Gesture recognition for selecting colors and clearing the canvas was reliable and
consistent.
- Users were able to perform the specified gestures, and the program responded
accurately to these actions.
- Testing across multiple users and hand orientations yielded consistent results,
demonstrating the robustness of gesture recognition.
- Users expressed satisfaction with the intuitiveness and accuracy of gesture-
based interactions.
4. Usability:
- Users found the program easy to use and navigate, with clear instructions
provided for selecting colors and clearing the canvas.
- The interface was intuitive, allowing users to interact with the program without
encountering significant difficulties.
- Feedback from users indicated high satisfaction with the overall usability of the
program, contributing to a positive user experience.
69
5. Overall Accuracy Assessment:
6. Performance:
7. Robustness:
- The program exhibited robust behavior across different operating conditions and
70
environments.
13. Conclusion:
71
- The positive feedback from users affirms the effectiveness of the program in
meeting user needs and expectations, positioning it as a valuable tool for interactive
digital drawing experiences.
14. Recommendations:
- Based on the testing results and user feedback, recommendations for further
development may include:
- Refinement of gesture recognition algorithms to enhance accuracy and
robustness.
- Integration of additional features or customization options to expand the
program's functionality and appeal to a broader user base.
- Optimization of performance to ensure efficient operation on a wide range of
hardware configurations.
- Continuous monitoring and solicitation of user feedback to guide future
enhancements and improvements, ensuring the program remains responsive to
evolving user needs and preferences.
72
CHAPTER 7
CONCLUSION
7.1 APPLICATIONS
Here's a high-level outline of how you can approach building such an application:
⚫ Design User Interface: Design the user interface for your virtual palette
application. This may include components such as color selection panels,
drawing canvas, buttons for selecting tools, and feedback indicators.
⚫ Implement Color Selection: Use computer vision techniques to detect and track
colors in the user's environment. You can use libraries like OpenCV to capture
webcam frames, process images, and extract color information.
73
⚫ Develop Drawing Tools: Implement drawing tools such as brushes, pencils,
erasers, and shapes. Use computer vision to track hand movements and gestures
for drawing on the canvas.
⚫ Enhance User Experience: Add features to enhance the user experience, such as
real-time feedback, smooth rendering of drawing strokes, and customizable
settings for preferences.
⚫ Test and Debug: Test your virtual palette application thoroughly to ensure that it
works as expected. Debug any issues or errors that arise during testing.
⚫ Optimize Performance: Optimize the performance of your application for speed,
responsiveness, and stability. This may involve optimizing algorithms, reducing
computational overhead, and improving memory management.
74
application for a virtual palette using Python and computer vision techniques.
Whether you're building a simple drawing tool or a sophisticated painting
application, leveraging the power of Python and computer vision can help you
create a compelling and innovative virtual palette experience.
7.2 ADVANTAGES:
Using Python and computer vision to create a virtual palette offers several
advantages:
75
⚫ Customization: With Python, developers can easily customize the virtual palette
to suit specific requirements and preferences. They can tailor the user interface,
drawing tools, color selection methods, and interaction mechanisms to meet the
needs of different users and applications.
⚫ Accessibility: Python and computer vision make the virtual palette accessible to
a wide range of users, including artists, designers, educators, and hobbyists. The
intuitive and interactive nature of the virtual palette, coupled with its
compatibility with standard hardware like webcams, makes it easy for users to
get started and create digital artwork without specialized equipment or
expertise.
76
7.3 FUTURE SCOPE:
While the current implementation is a good starting point, there are several
potential directions for future improvement and expansion. Here are some ideas for
the future scope of this project:
2. User Interface Refinement: Improve the user interface to make it more intuitive
and user-friendly. This could involve adding buttons or controls for color selection,
clearing the canvas, undo/redo functionality, saving drawings, or exporting
drawings to different formats.
78
image segmentation, or style transfer. This could help users generate or enhance
their drawings using advanced algorithms.
10. Cross-Platform Support: Extend support for running the application on different
platforms such as mobile devices, tablets, or web browsers. This would increase
accessibility and reach a broader audience.
Overall, the future scope of the project depends on goals, target audience, and
available resources. By incorporating some of these ideas and continuing to iterate
based on user feedback, we can create a more versatile and engaging drawing
application.
79
APPENDICES:
MODULE – 1:
Initializing the Webcam:
import cv2
while True:
# Capture frame-by-frame
ret, frame = cap.read()
80
if cv2.waitKey(1) & 0xFF == ord('q'):
break
MODULE – 2:
Hand Detection using Media Pipe:
import cv2
import mediapipe as mp
# Initialize webcam
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
81
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
MODULE – 3:
Drawing on Canvas using Hand Gestures:
import cv2
82
import numpy as np
import mediapipe as mp
# Initialize webcam
cap = cv2.VideoCapture(0)
# Initialize canvas
canvas = np.zeros((480, 640, 3), dtype=np.uint8)
while True:
ret, frame = cap.read()
if not ret:
break
83
for hand_landmarks in results.multi_hand_landmarks:
for landmark in hand_landmarks.landmark:
x, y = int(landmark.x * 640), int(landmark.y * 480)
cv2.circle(frame, (x, y), 5, (0, 255, 0), -1)
# Draw on canvas
cv2.circle(canvas, (x, y), 5, (255, 255, 255), -1)
MODULE – 4:
Hand Gesture Recognition:
import cv2
import mediapipe as mp
84
mp_hands = mp.solutions.hands
hands = mp_hands.Hands()
# Initialize webcam
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
85
if cv2.waitKey(1) & 0xFF == ord('q'):
break
MODULE – 5:
Hand Tracking with Depth Sensing:
import cv2
import mediapipe as mp
# Initialize webcam
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
86
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
MODULE – 6:
Color Palette Selection:
import cv2
87
import numpy as np
# Initialize webcam
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
88
cv2.destroyAllWindows()
MODULE – 7:
Color Selection on Canvas:
import cv2
import numpy as np
# Initialize canvas
canvas = np.zeros((480, 640, 3), dtype=np.uint8)
# Initialize webcam
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
89
# Display the resulting frame
cv2.imshow('Color Palette', frame)
cv2.imshow('Canvas', canvas)
90
FUNCTIONALITY OF CODE:
python
# All the imports go here
import cv2
import numpy as np
import mediapipe as mp
from collections import deque
from mediapipe.python.solutions import hands
from mediapipe.python.solutions.drawing_utils import draw_landmarks
These are the necessary imports for the script. It uses the OpenCV library (cv2),
NumPy (np), and Mediapipe (mp) for hand tracking.
python
# Giving different arrays to handle colour points of different colours
bpoints = [deque(maxlen=1024)]
gpoints = [deque(maxlen=1024)]
rpoints = [deque(maxlen=1024)]
ypoints = [deque(maxlen=1024)]
Dequeues (deque) are used to store points for different colors (blue, green, red,
yellow). The maximum length is set to 1024.
python
# These indexes will be used to mark the points in particular arrays of specific
colours
91
blue_index = 0
green_index = 0
red_index = 0
yellow_index = 0
Indexes to keep track of the current position in each color's deque.
python
# The kernel to be used for dilation purpose
kernel = np.ones((5, 5), np.uint8)
A kernel used for image dilation.
python
colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (0, 255, 255), (255, 255, 0), (255, 0,
255)]
colorIndex = 0
Colors for drawing (blue, green, red, yellow, cyan, magenta), and
colorIndex keeps track of the current drawing color.
python
# Here is the code for Canvas setup
paintWindow = np.zeros((471, 636, 3)) + 255
paintWindow = cv2.rectangle(paintWindow, (40, 1), (140, 65), (0, 0, 0), 2)
# (Other rectangles and text drawing skipped for brevity)
cv2.namedWindow('Paint', cv2.WINDOW_AUTOSIZE)
Setting up the canvas using a NumPy array (paintWindow). Several rectangles are
drawn for different colors and a window named 'Paint' is created.
python
# initialize mediapipe
mpHands = mp.solutions.hands
92
hands = mpHands.Hands(max_num_hands=1, min_detection_confidence=0.7)
mpDraw = mp.solutions.drawing_utils
Initializing the Mediapipe hands module for hand tracking.
python
# Initialize the webcam
cap = cv2.VideoCapture(0)
ret = True
while ret:
# Read each frame from the webcam
ret, frame = cap.read()
x, y, c = frame.shape
frame = cv2.flip(frame, 1)
framergb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
Setting up the webcam capture and reading each frame. The frame is flipped
horizontally for a mirrored view, and color conversion to RGB is performed.
python
# (Rectangles and text drawing for buttons skipped for brevity)
Drawing rectangles and text for buttons on the frame.
python
# Get hand landmark prediction
result = hands.process(framergb)
Processing the frame with the hand tracking model.
python
# Post-process the result
if result.multi_hand_landmarks:
landmarks = []
93
for handslms in result.multi_hand_landmarks:
for lm in handslms.landmark:
lmx = int(lm.x * 640)
lmy = int(lm.y * 480)
landmarks.append([lmx, lmy])
mpDraw.draw_landmarks(frame,handslms,
mpHands.HAND_CONNECTIONS)
If hand landmarks are detected, extract the landmark coordinates, and draw the
landmarks on the frame.
python
fore_finger = (landmarks[8][0], landmarks[8][1])
center = fore_finger
thumb = (landmarks[4][0], landmarks[4][1])
cv2.circle(frame, center, 3, (0, 255, 0), -1)
Get the coordinates of the forefinger and thumb. Draw a green circle at the center of
the forefinger.
python
if thumb[1] - center[1] < 30:
bpoints.append(deque(maxlen=512))
blue_index += 1
# (Similar appending for other color points skipped for brevity)
If the distance between the thumb and the forefinger in the vertical direction
is less than 30, it's considered a click. Append new deques for each color and
increment the respective index.
python
elif center[1] <= 65:
94
if 40 <= center[0] <= 140:
bpoints = [deque(maxlen=512)]
gpoints = [deque(maxlen=512)]
rpoints = [deque(maxlen=512)]
ypoints = [deque(maxlen=512)]
blue_index = 0
green_index = 0
red_index = 0
yellow_index = 0
paintWindow[67:, :, :] = 255
# (Checking for other color buttons skipped for brevity)
If the center of the hand is in the top region (button area), check which button is
pressed. If the "CLEAR" button is pressed, reset all color points and clear the
canvas.
python
else:
if colorIndex == 0:
bpoints[blue_index].appendleft(center)
elif colorIndex == 1:
gpoints[green_index].appendleft(center)
elif colorIndex == 2:
rpoints[red_index].appendleft(center)
elif colorIndex == 3:
ypoints[yellow_index].appendleft(center)
If the hand is not in the button area, append the current hand position to the deque
of the selected color.
95
python
# Append the next deques when nothing is detected to avoid messing up
else:
bpoints.append(deque(maxlen=512))
blue_index += 1
# (Similar appending for other color points skipped for brevity)
If no hand is detected, append new deques to avoid messing up the drawing.
python
# Draw lines of all the colors on the canvas and frame
points = [bpoints, gpoints, rpoints, ypoints]
for i in range(len(points)):
for j in range(len(points[i])):
for k in range(1, len(points[i][j])):
if points[i][j][k - 1] is None or points[i][j][k] is None:
continue
cv2.line(frame, points[i][j][k - 1], points[i][j][k], colors
[i], 2)
cv2.line(paintWindow, points[i][j][k - 1], points[i][j][k], colors[i], 2)
Draw lines connecting points in the deques for each color on both the frame and the
canvas.
python
cv2.imshow("Output", frame)
cv2.imshow("Paint", paintWindow)
if cv2.waitKey(1) == ord('q'):
break
Show the output frame and the canvas. Exit the loop if the 'q' key is pressed.
96
python
# Release the webcam and destroy all active windows
cap.release()
cv2.destroyAllWindows()
Release the webcam and close all OpenCV windows.
A2: SCREENSHOT
97
Figure A2.2 : Output Stroke
REFERENCES:
98
[3] M. Bhargavi, Dr. B. Esther Sunanda, M.R.S. Ananya, M. Tulasi Sree,
N. Kavya “Air Canvas Using Opencv, Mediapipe” IRJMETS
Volume:04/Issue:05/May-2022.
[4] Zhou Ren, Junsong Yuan, Jingjing Meng, Zhengyou Zhang “Robust Hand
Gesture Recognition with Kinect Sensor” 1520-9210/$31.00 © 2013 IEEE.
[5] Andrea Urru, Lizy Abraham, Niccolò Normani, Mariusz P. Wilk ID, Michael
Walsh, Brendan O’Flynn “Hand Tracking and Gesture Recognition Using Lensless
Smart Sensors” Sensors 2018, 18, 2834.
[6] Sahil Agrawal, Shravani Belgamwar “An Arduino based Gesture Control
System for Human Interface” 978-1-5386-5257-2/18/$31.00 ©2018 IEEE.
[7] Revati Khade, Prajakta Vidhate, Saina Rasal “Virtual Paint Application by
Hand Gesture Recognition System” International Journal of Technical Research
and Applications e-ISSN: 2320-8163, Volume 7, Issue 3 (MARCH-APRIL 2019)
[8] S.U. Saoji, Akash Kumar Choudhary, Nishtha Dua, Bharat Phogat “Air Canvas
Application Using OpenCV and NumPy in Python” IRJET Aug 2021 Volume: 08
Issue: 08
99
[10] Adinarayana Salina, K. Kaivalya, K. Sriharsha, K. Praveen, M. Nirosha
“Creating Air Canvas Using Computer Vision “IJAEM Volume 4, Issue 6 June
2022.
PUBLICATION:
100
101
102
103
104
105