You are on page 1of 2

Virtual Air Painting in Python

Parthsarthi Gupta
#
School of EEE, VIT University, Tamil Nadu
RoboVITics
VIT University, Tamil Nadu
In the positive case, it highlights the
This document gives instructions in a very object.
understandable and basic manner to design
one’s own virtual air painting project/
Color: Here we chose any object of any
application by using python as the coding
language. specified color.
The range of the color is specified in
Keywords— Virtual Air Painting, Live Object form of Hue, Saturation and Value or HSV.
Tracking, Python, OpenCV If the color value of the object matches
the range, it is identified and highlighted on
I. INTRODUCTION the screen.
This document is a guide to build one’s
own Virtual Air Painting application from
scratch in the most elementary way. C. Moving Object
Once the object is detected, it is vital
The primary webcam of the device is that it is trace all along its path, rather than
used to obtain the input data. The screen just momentarily.
acts as the output device.

It makes use of Object tracking using


color ranges and then printing lines as it
moves using the contours of the object. We look for the boundary conditions;
II. Approach and Development Stages the points where the color value abruptly
One must start by interfacing OpenCV changes around the range of the object;
and finish with the output of being able to that represents the movement of the objects
paint of the screen with an object of the in form of pixels.
color of your choice. These boundaries are known as
Special care has been taken to keep it as contours. We define contours for minimum
simplified as possible, enabling it to be area of the object to prevent errors.
beneficial to lay-men. We draw a circle around the area to
A. Interfacing highlight the tracked object.
Post the installation of python, pip and D. Tracing Movement/ Painting
numpy libraries must be installed. We start by listing the location of the
This should be done by using command object on the screen in form of the pixel
prompt. number.

B. The Object We run two loops. One, starting from the


The object can be detected in two ways. first to the second last and the second, from
the second to the last.
Haar Cascades: These are XML files We draw a small incremental line
made by sampling the different images of between consecutive points.
the object on a server, capturing the needed
part and formed into a file known as a
Cascade.
While our program is running, the IDLE,
matches the pixels in the captured frame to
the Cascade file.
We continue further in the loop if the samples by matching the pixels of the
successive points are the same. frame with respect to the samples.
The later focuses on matching the
E. Figure object’s color to the predefined range in
The green color has been chosen for the terms of hue, saturation, value and is
object for this very project. comparatively faster, efficient and
Attention should be paid to the yellow elementary level concept with respect to
circle, which highlights the location of the thee former.
contour area, with which, the colored Paint lines are displayed by tracing the
object has been tracked. contours of the object.
The trails of the movement of the object ACKNOWLEDGMENT
appear as clearly show in Fig. 1. The completion of this undertaking
could not have been possible without the
Fig. 1 Example of a working application guidance of our respected seniors.
We are very grateful to our mentor, Mr.
Himanshu Khemani, for his immaculate
F. Special Attention: Haar guidance, who has been vital in the
Cascades completion of this wonderful project.
The concept of a Haar Cascade starts
with comparison of a known image to an
obtained image; return true if the image REFERENCES
matches the template till a certain [1] www.pythonprogramming.net
[2] www.opencv.org
threshold. [3] Sentdex channel , YouTube
Haar cascades are designed to be
foolproof in detecting the object of one’s
liking. Hence it is vital to train the
cascaded with thousands of possible
images of the object.
This is done on a server, and providing
the link to the images. Dimensions to the
positive images are provided.
Once trained, the server could shut down
and the XML file can be used as it is.
Training of the cascade could take hours
or days, depending on the specification of
the machine, server and the link speed.
G. Links
The link to a sample working
application with the instructions to run
the application can be accessed by the
following link.

https://github.com/Severus11/Virtual_
Air_Painting/tree/Abstract

IV. CONCLUSIONS
The project- Virtual Air Painting can
work on two prominent principles- Haar
Cascade and Color detection.
The former, detects a specific type of
object with respect to the XML file of

You might also like