You are on page 1of 5

VIRTUAL MOUSE USING COLOUR

SEGMENTATION
of the detected region) , Tracking the Mouse pointer(Once the
coordinates has been determined, the mouse driver is accessed and the
Samyak Jain 17BCE0139 coordinates are sent to the cursor), and finally Performing Clicking
Actions (Clicking action is based two colours 1. If Red along with
VIT UNIVERSITY
Green colour is detected, Left clicking action is performed and 2. If
Vellore samyak.jain2017@vitstudent.ac.in
Red along with Blue colour is detected, Right clicking action is
performed.

Another one proposed was the Virtual Mouse using Hand


Gesture and Color Detection technology, in which three
technologies are mainly used: object detection, image
processing and color recognition. The proposed system
Abstract— Since the computer technology continue to consists of four parts: Hand Gloves (gloves will have
grow up, the importance of human computer interaction is different colors painted on different fingers, which will
enormously increasing. Nowadays most of the mobile devices make the system faster and easier for the algorithm),
are running using a touch screen technology. However, this Webcam (necessary component for detecting the image),
technology is still not cheap enough to be used in desktop image processing and mouse movement.
systems. Creating virtual human computer interaction device In this proposed system, image processing is the main part.
such as mouse or keyboard using a webcam and computer Image processing was done in 5 steps; Color Detection
vision techniques can be an alternative for the touch screen. In (MATLAB built in function “imsubstract” can be used),
this study, finger tracking based on a Filtering the Images (Median filtering gives optimum
virtual mouse application has been designed and implemented results), Conversion of Images (after filtering was done
using a regular webcam. over, For conversion of image one may also use in built
function
The motivations is to create an object tracking application to “im2bw”), Removing small areas (here MATLAB's
interact with computer, and develop a virtual human computer “bwareaopen” function was used) and Find Centre (Here
interaction device. “bwlabel” Matlab function can be used for cropping the
genuine area). Next is Move the cursor and Mouse click
event, after Find Centre step centroid from final image,
movement has to take place and finalize (X,Y) coordinates
Keywords— HUMAN COMPUTER
where clicking action is taken.
INTERACTION, VIRTUAL MOUSE,FEATURE
EXTRACTION, VISUALIZATION, MATLAB A third example is the virtual mouse implementation using
color pointer detection. In the first step Webcam is used to
capture and recognize an object in view and tracks the user's
Introduction hand gestures using computer vision techniques. In the
second step Video is divided into Image frames based on the
In this project, the mouse cursor movement and click events are FPS (Frames per second) of the camera. In the third step red,
controlled using a camera based on colour detection and green and blue color object is extracted or detected by
segmentation technique. Here real time video has been subtracting the flipped color suppressed channel from the
captured using a Web- Camera. The user wears coloured tapes flipped Gray Scale Image. In the fourth step MATLAB is
to provide information to the system. Individual frames of the used to find the centroid of the detected region i.e. Matrix
video are separately processed. The processing techniques consisting of the X (horizontal) and Y (vertical) coordinates
involve an image subtraction algorithm to detect colours. Once of the centroid. Finally Perform Clicking Actions, where
the colours are detected, the system performs various JAVA is used to access these flags / centroids.
operations to track the cursor and performs control actions. No
additional hardware is required by the system other than the
standard webcam which is provided in every laptop computer.
SURVEY
In one proposed system we can control the mouse cursor Virtual mouse implemented with hand gesture tracking based on
movement and click events of the mouse using hand gestures. image is one of studies in human-computer interaction. In this
Proposed system was worked on eight steps; Capturing the real study that human-computer interaction is implemented with virtual
time video (webcam captures the real time video at a fixed mouse is purposed. This study consists of three main steps that are
frame rate), Flipping of Images (camera captures an image hand gesture tracking, features of hand region extraction and
which is in the form of inverted, means that if we move the
classification of these features. In this study hand gesture tracking
colour pointer towards the left, the image of the pointer moves
is generated with Camshift (Continuously Adaptive Mean Shift)
towards the right and vice-versa), Conversion of Flipped Image
algorithm, features of hand gestures are extracted with bag of
into Gray scale Image (computational complexity is reduced in
a grayscale image as compared to a coloured image), Colour visual words and these features are classified with support vector
Detection (This process creates an image which contains the machines. Detailed tests are performed to compare success of
detected object as a patch of grey surrounded by black space), tracking, features extraction and classisfication methods and that
Conversion of gray scale Image into Binary scale Image (grey this system works successfully is shown..
region of the image obtained after subtraction needs to be
converted to a binary image for XXX-X-XXXX-XXXX-
X/XX/$XX.00 ©20XX IEEE W.-W.M. Tsang and Kong-Pang Pun (2005), presented a virtual
mouse that is based on tracking the movement of a finger is
finding the region of the detected object), Finding Centroid of presented. The idea is for users to control their computer or TV
an object and plotting (MATLAB is used to find the centroid system simply by moving their fingers, without any contact on
realistic objects. A fast and robust method that can trace the improvement in performance of the existing "Virtual Marker" by
position of finger tip is proposed. The method consists of making it highly responsive in real time.
four steps. First, the skin-color pixels of figures are detected
by color segmentation using the chrominance component of Ramazan Özgür Doğan and Hülya Doğan (2015) proposed a study
the input from a CMOS image sensor. Second, density study that human-computer interaction is implemented with virtual
regularization processes are carried out to reinforce the mouse is purposed. This study consists of three main steps that are
regions of skin-colour pixels. Third, an effective window hand gesture tracking, features of hand region extraction and
search technique is applied for minimizing computational classification of these features. In this study hand gesture tracking is
cost. Fourth, a finger-tip tracking algorithm is applied to generated with Camshift (Continuously Adaptive Mean Shift)
find out the finger-tip position. Clicking action is also algorithm, features of hand gestures are extracted with bag of visual
implemented by a specific movement. The virtual mouse words and these features are classified with support vector machines.
has been designed in an embedded Linux system. The Detailed tests are performed to compare success of tracking, features
device works successfully, the response is quick and extraction and classisfication methods and that this system works
accurate positioning is obtained. successfully is shown.

Javeria Farooq and Muhaddisa Barat Ali (2014), presented that Tomas Palleja (2008) introduced a work conducted to create a
Hand gesture recognition is a natural and intuitive way to relative virtual mouse based on the interpretation of the head
interact with the computer, since interactions with the computer movements through a low cost camera. This virtual device is
can be increased through multidimensional use of hand gestures designed as a non-contact alternative for people with mobility
as compare to other input methods. The purpose of this paper is impairments. First validation results show performance close to a
to explore three different techniques for HGR (hand gesture digital joystick.
recognition) using finger tips detection. A new approach called
“Curvature of Perimeter” is presented with its application as a Farzana Jabeen and Linmi Tao (2016) described that Virtual reality
virtual mouse. The system presented, uses only a webcam and is an emerging paradigm that is trying in context to enhance their
algorithms which are developed using computer vision, image independence and quality of life. But it is not so easy to interact
and the video processing toolboxes of Matlab. with the VR applications. When you wear the virtual glasses you
won't be able to see the physical world in real. The common user
Li Wensheng, Deng Chunjian and Lv Yi (2010) presented A problem is to use the input devices (keyboard, mouse, remote
method to implement virtual mouse through machine vision are control) to change the menu and access the different features of
proposed. Firstly we present an efficient algorithm based on VR. But in case of people with special needs they will not be able
color to track the movement of fingertips in real time, then we to handle interaction with such devices. To make maximum use of
present a set of messages (including elementary fingertip virtual reality technique effective, we are proposing one bit virtual
message and simulated mouse message) that are generated mouse. By using one key, virtual mouse provides the control access
according to the result of fingertip tracking, These messages to VR application with ease as well as training environment for the
can be used to control the window based applications. We also users. The primary evaluation of the system is done with the
presents a framework to help programmers realize human- experiment. The post experiment results and disable people
computer interaction based on virtual mouse. The performance feedback show performance of the system is satisfactory.
of virtual mouse shows a great promise that we will be able to
use this methodology to control computers and achieve a more Changhyun Jeon and Dongil Shin (2017) presented a virtual
natural human-computer interaction. monitor that allows a virtual space to be controlled by the hand
mouse. It is possible to map the coordinates on the virtual monitor
Alexandre Henzen and Percy Nohama (2016), present a new to the coordinates on the real monitor accurately. A hand-mouse
solution that allows people with special needs to use all the interface based on the virtual monitor concept maintains the
features of the keyboard and mouse via sensors connected to a outstanding intuitiveness that is the strength of the previous study
user's body part in which it maintains motor control. The and enhances the accuracy of mouse functions. In order to evaluate
application developed constitutes a keyboard and mouse the intuitiveness and accuracy of the interface, we conducted an
emulator, configurable and adaptable, which was named ETM experiment with 50 volunteers ranging from teenagers to those in
(Emulator Keyboard and Mouse). The software captures their 50s. The results of this intuitiveness experiment showed that
trigger's signals connected to the USB (Universal Serial Bus), 84% of the subjects learned how to use the mouse within 1 min. In
through the adaptation of the contacts of the buttons of a addition, the accuracy experiment showed the high accuracy level
joystick. By means of a command processor and a key layout of the mouse functions [drag (80.9%), click (80%), double-click
tailored to user needs, it sends keyboard and mouse commands (76.7%)]. This is a good example of an interface for controlling a
for any Windows application. Tests conducted with cerebral system by hand in the future.
palsy in the project participants schools and volunteers with
amyotrophic lateral sclerosis, have shown satisfactory results. Byungsung Lee and Junchul Chun (2010) presented a vision-based
With the adaptation of sensors and programs developed, it framework to manipulate the augmented reality (AR) objects
optimized communication and user learning, minimized motor robustly in a marker-less AR system. It is known that one of the
limitations due to neurological diseases, and it has expanded his promising ways to develop a marker-less AR system is using
accessibility and digital and social inclusion. human's body such as hand or face for replacing fiducial markers.
This paper presents a real-time method to manipulate the AR
Ashish Mhetar (2014) proposed a product which aims to be a objects dynamically in a developed 3D hand coordinate system. To
virtual marker and also has additional advantage that it has build the marker-less system, we utilize YCbCr skin-color model
features of a Mouse incorporated into it. The existing Virtual for hand shape detection and curvature-based fingertip detection
Marker is modified to function more than a marker and act as a from an input video images. Using the detected fingertips the
mouse pointer also giving it the advantage of all the camera pose are estimated to register virtual objects on the hand
functionality of a mouse. In this paper, we have proposed a coordinate system. In order to manipulate the movements of the
hardware implementation of a Virtual Mouse which has an virtual objects rendered on the marker-less AR system
dynamically, a vision-based hand control interface, which utilizes
pattern recognition for the hand command initiation, is Camera Settings
developed. From the experiments we can prove that the The runtime operations are managed by the webcam of the
proposed hand mouse can manipulate the objects in a connected laptop or desktop. To capture a video, we need to create
feasible fashion. a Video Capture object. Its argument can be either the device
index or the name of a video file. Device index is just the number
Several authors have suggested various techniques for to specify which camera.Since we only use a single camera we
preprocessing and enhancement in the last two decades. The pass it as ‘0’. We can add additional camera to the system and
task of virtual image enhancement is to sharpen the edges pass it as 1,2 and so on. After that, you can capture frame-
to increase the contrast between suspicious regions and the byframe. But at the end, don’t forget to release the capture. We
background. Image enhancement includes intensity and could also apply color detection techniques to any image by doing
contrast manipulation, noise reduction, background simple modifications in the code.
removal, edges sharpening, filtering, etc.

We have studied different techniques for segmentation.. Some


studies focused on trained data while other targeted untrained Capturing frames
data; some studies used atlas, and some did not. A critical The infinite loop is used so that the web camera captures the frames
review of the studied literature is summarized in the compare in every instance and is open during the entire course of the
and contrast table (Table I). program. We capture the live feed stream, frame by frame. Then
we process each captured frame which is in RGB(default) color
PROBLEM STATEMENT space to HSV color space. There are more than 150 colorspace
conversion methods available in OpenCV. But we will look into
Virtual Mouse using Color only two which are most widely used ones, BGR to Gray and BGR
Segmentation to HSV

Masking technique
ARCHITURES The mask is basically creating some specific region of the image
following certain rules. Here we are creating a mask that comprises
of an object in red color. After that we perform a bitwise AND
operation on the Input image and theThreshold image, which result
in only the red colored objects are highlighted. This result of the
AND operation is stored in res. We then display the frame, res and
mask on 3 separate windows using imshow() function.

Display the frame


The imShow() is a function of HighGui and it is required to call the
waitKey regulerly. The processing of the event loop of the
imshow() function is done by calling waitKey. The function
waitKey() waits for key event for a “delay” (here, 5 milliseconds).
Windows events like redraw, resizing, input event etc. are
processed by HighGui. So we call the waitKey function, even with
a 1ms delay.

Mouse Movement
We have to first calculate the center of both detected red object
which we can easily do by taking the average of the bounding boxes
maximum and minimum points. now we got 2 co-ordinate from the
center of the 2 objects we will find the average of that and we will
get the red point shown in the image. We are converting the
detected coordinate from camera resolution to the actual screen
resolution. After that we set the location as the mouse_position. but
to move the mouse pointer it will take time. So we have to wait till
the mouse pointer reaches that point. So we started a loop and we
are not doing anything there we are just waiting will the current
mouse location is same as assigned mouse location. That is for the
open gesture.

Clicking
The next step is to implement the close gesture. The operation is
performed by clicking the object and dragging it. It is similar to the
open gesture, but the difference is we only have one object here so
we only need to calculate the center of it. And that will be placed
on the location where we will position our mouse pointer. Instead
of mouse release operation we will be performing a mouse press
operation.
IMPLEMENTATION
Drag
In order to implement the dragging we indroduce a variable
‘pinchflag’. It will be set to 1 if it was clicked earlier. So MAIN MODULE:
after clicking whenever we find the open gesture we check The main part of the project is within main module. The main
if the pinchflag is set to 1. If it is set to one then Drag module is divided into 3 parts
operation is performed otherwise the mouse move operation · Input
is performed. 5.8 DnD Frame First we create the · Processing
MyFileDropTarget class. Inside that we have one · Output
overridden method, OnDropFiles. This method accepts the
x/y position of the mouse along with the file paths that are
dropped.
Input:
This part contains all the passing of the live cam feed. All the
input comes from reading the video frames. Each frame is
File Transfer captured and send for processing.
Using the file path obtained from MyFileDropTarget class
we send the file to the other system using the python socket Processing:
module. And there it recieves and creates the file. This is the main part of the project. This module covers all the
preprocessing done on the live cam frames. This processing is
ALGORITHM done on the individual frames. It include all basic image
processing techniques like segmentation, thresholding,
The project works on the concept of colour segmentation. morphological transformation and contouring. These
The colour detected are mapped on the live cam feed and techniques will refine the image and removes noise and detect
are processed to find the appropriate gesture. The methods colors and segment it according to colors. After detection of
and concept used are: For Image Processing: colors we find contours on respective colors. There can be
maximum of 3 contours and minimum of 1 for the cursor to
● Thresholding
perform any operation.
● Segmentation
● Contouring Output:
● Morphological Transformations (Dilation/Erosion) The contours are represented as circles and is displayed in an
interface window.
For Gesture Recognition:
● Calculated Centroid Distance SCREENSHOTS
● Detected the no of contours
● Calculated maximum area of the contours detected

For Mouse actions:


● Maintained the aspect ratio of screen ● Creating a stack
of action for smooth execution of action ● Mapped the
mouse pointer to the movement of contours

STEPS FOR IMPLEMENTED ALGORITHM

1. Start Acquisition
2. Input: Image using RGB
3. Convert the RGB image into color space. (Eg. YCbCr,
LAB, HSV)
4. Extract the hand from an image using the color
Models by applying thresholding.
5. Color Based Segmentation using ROI properties.
6. Real time color based Tracking.

MODULES

CALIBRATION MODULE:
This module include the capturing of the pixel value of the
colored objects used to operate the software. For the first
time user it is mandatory for the user to run the calibrate
module so that the software can calibrate the colors and will
able to detect. Since in our project we our using red green
and yellow colors. We can also go with RGB colors but it
will be good if we go by the standard color of the software.
Bright colors are preferable and not metallic colors. The
module function works accordingly: · Just left click the
color you want to capture. · Press the respective color key
from the keyboard Egs : R for red , G for green etc · The
values will be written in the pickle file for future use
Mouse Movement using a Real Time Camera”, 2008,
Brown University,Providence ,RI ,USA, Department of
computer science
4- Kamran Niyazi, Vikram Kumar, Swapnil Mahe,
Swapnil Vyawahare, “Mouse Simulation Using Two
Coloured Tapes”, Department of Computer Science,
University of Pune, India, International Journal of
Information Sciences and Techniques (IJIST) Vol.2, No.2,
March 2012
5- K N. Shah, K R. Rathod and S. J. Agravat, “A survey on
Human Computer Interaction Mechanism Using Finger
Tracking” International Journal of Computer Trends and
Technology, 7(3), 2014, 174-177
6- Rafael C. Gonzalez and Richard E. Woods, Digital
Image Processing, 2nd edition, Prentice Hall, Upper
Saddle River, New Jersey, 07458 7 - Shahzad Malik,
“Real-time Hand Tracking and Finger Tracking for
Interaction”, CSC2503F Project Report, December
18, 2003

REFRENCES
1- A. Erdem, E. Yardimci, Y. Atalay, V. Cetin, A. E.
“Computer vision based mouse”, Acoustics,
Speech, and Signal Processing, 2002.
Proceedings. (ICASS). IEEE International
Conference
2- Chu-Feng Lien, “Portable Vision-Based HCI – A
Real-time Hand Mouse System on Handheld
Devices”, National Taiwan University, Computer
Science and Information Engineering Department
3- Hojoon Park, “A Method For Controlling The

You might also like