Computer Control Using Hand Gesture
Computer Control Using Hand Gesture
CERTIFICATE
DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING
(Approved by AICTE, Permanently Affiliated to JNTUK, KAKINADA & Accredited by NAAC with ‘A’ Grade)
1-378, A.D.B. Road, Surampalem, Near Peddapuram – 533437
This is to certify that the Mini Project Report entitled “COMPUTER CONTROL USING HAND
GESTURE” is being submitted by A.V.Sai Manikanta (16A31A0217), B.V.Durga Prasad (16A31A0220),
B.Sankar (16A31A0219), and N.Sai Surya (16A31A0240) in partial fulfillment for the award of the Degree
of Bachelor of Technology in Electrical & Electronics Engineering of Pragati Engineering College, for the
record of bonafide work carried out by them.
Sri.S.ASHOK REDDY
M. Tech
Assistant Professor
Dr. K. SATYANARAYANA
M. Tech., PhD, MIE, MIEEE, MISTE, C Eng.
Professor&H.O.D- E.E.E.
ACKNOWLEDGEMENT
We express our thanks to our guide Sri.S.ASHOK REDDY, Assistant Professor in Electrical
and Electronics Engineering, who deserves a special note of thanks and gratitude, for having extended
their fullest co-operation and guidance, without this project would never have materialized.
We wish to express our special thanks to our beloved Dr. S. SAMBHU PRASAD, Principal for
giving us guidelines and encouragement.
We wish to express our sincere gratitude to our beloved and respected Dr.P.KRISHNA RAO,
Chairman and Sri. M. V. HARANATHA BABU, Director and Sri.M.SATISH, Vice President for their
encouragement and blessings.
We are thankful to all our faculty members of the department for their valuable
suggestions. Our sincere thanks also extended to all the teaching and non-teaching staff of Pragati
Engineering College.
CONTENTS
LIST OF FIGURES 3
LIST OF TABLES 4
ABBREVATIONS 5
ABSTRACT 6
1.3 DEFINITIONS 9
1.3.4 Python 11
1.4 Features 11
3.5 Applications 22
Fig 2.2: Real Time Portable Ultrasonic Range Metre for different values 15
LIST OF TABLES
The main objective of this project is to create a Hand gesture controlled computer .It is an innovative
technique of interaction between human and computer. As compared to existing techniques, hand gesture
technique has the advantage of being easy to use. By using this technique the traditional way of using
mouse and keyboard will be change because one can interact with the computer with hand gestures.
In this technique, ultrasonic sensor is used to classify the hand movement in real-time. Ultrasonic sensor
measures the distance of hand by using sound waves. The main idea of our approach is to speed up the
interaction with computer, using general purpose hardware like personal computer, Arduino UNO board and
low cost sensor like ultrasonic sensor. In this way any user can easily interact with the computer using hand
gestures.
CHAPTER-1
INTRODUCTION
The project was originally used for an interaction between human and computer in an easier
way. We all know that humans interact in the physical world by the means of the five senses. However,
gestures have been an important means of communication in the physical world from ancient times, even
before the invention of any language. In this era of machines taking control of every complex works,
interactions with machines have become more important than ever. Since this project deals with gesture
controlled laptop, the primary focus will be on the use of hand gestures for specific applications only.
There are several ways to capture a human gesture that a computer would be able to recognize. The gesture
can be captured using distance measurement, camera, or a data glove. Gestures can also be captured via
Bluetooth or infrared waves, Acoustic, Tactile, optical or with a motion technology. The embedded systems
designed for specific control functions can be optimized to reduce the size and cost of the device and
increase the reliability and performance.
Here this project consists of mainly three components –Arduino Uno, Ultrasonic sensors, and a laptop. The
ultrasonic sensors hooked to the Arduino are used to determine the gestures and the distance of the hand
from the ultrasonic sensors. The code loaded in Arduino finds the respective keyword for the distance found
and sends it to Windows OS. Python code that runs in the background recognizes the keywords and
generates the corresponding virtual keystrokes for Windows. The hotkeys then control particular function of
the application of intends to run VLC Media Player and web page.
Python is a high-level programming language designed to be easy to read and simple to implement.
It is open source, which means it is free to use, even for commercial applications. Python is considered a
scripting language, like Ruby or Perl and is often used for creating web applications and dynamic Web
content.
1.4 Features:
The following list shows typical characteristics enabled by the detection system.
Transparent object detectable
Ultrasonic waves can reflect off a glass or liquid surface and return to the sensor head, even
transparent targets can be detected.
Resistant to mist and dirt
Detection is not affected by accumulation of dust or dirt.
Complex shaped object detectable
Presence detection is stable even for targets such as mesh trays or springs.
CHAPTER-2
LITERATURE SURVEY
2.2Table of Contents:
Circuit Diagram
Hardware Required
Circuit Design of Ultrasonic Range Meter
Working
Arduino Uno
Ultrasonic Sensor HC-SR04
16X2 LCD Display
10KΩ POT
Pins 15 and 16 (LED+ and LED-) of the LCD are backlight pins. They are connected to Vcc and Gnd respectively
.Four data pins of LCD are used to display the information.
Pins 11, 12, 13 and 14 of LCD (D4 – D7) are connected to pins 5, 4, 3 and 2 of Arduino.
Pins RS and E (pins 4 and 6) of LCD are connected to pins 7 and 6 of Arduino respectively while RW (pin 5) is
connected to ground. Pins 1 and 2 (Vss and Vdd) are connected to ground and Vcc respectively.
In order to control the contrast of the LCD display, pin 3 (VE) of LCD is connected to the wiper of a 10 KΩ POT
with the other terminals of POT connected to Vcc and Gnd.
2.2.4 Working:
Ultrasonic sensor is the main module in the range meter circuit. An ultrasonic sensor
consists of an ultrasound transmitter and a receiver. The transmitter sends a sonic burst of 8 pulses at 40
KHz frequency. This signal hits the target and the echo is received by the receiver module. By measuring
the time between the events of sending the pulse and receiving the echo, the distance can be calculated.
The ultrasonic sensor used here is HC-SR04. It can be used to measure distance in the range of 2cm to
400cm with accurate readings.
The sensor module consists of 4 pins: Vcc, Gnd, Trig and Echo. When the Trig pin is high for a duration of
at least 10µs, the ultrasonic sensor sends the ultrasound signals. The Echo pin is high from the moment of
sending the signal and receiving it.
CHAPTER-3
PROBLEM FORMULATION AND STATEMENT
ULTRASONIC ULTRASONIC
SENSOR SENSOR
AURDINO
UNO
LAP
TOP
From the above figure 3.2, we see that two ultrasonic sensors are connected to Arduino Uno board and the
board is connected to Laptop through USB. The ultrasonic sensors have a transmitter and a receiver where
the transmitter emits ultrasonic waves.
Our main objective is to control the computer (or) laptop using a hand gesture. A gesture is a
motion of the body that conveys information This Gesture controlling is based on specifying hand position
from the ultrasonic sensor.
The hand gestures in front of the Ultrasonic sensors can be calibrated so that they can perform five different
tasks on your computer. Before taking a look at the gestures, let us first see the tasks that we can
accomplish.
The steps that are planned to complete the project are as follows:
1. Connect the Arduino which consists of 5v power supply to laptop through USB device
2. Connect the reflectance sensors to the Arduino board and test to ensure it is working properly.
4. The code loaded in Arduino finds the respective keyword for the distance found and sends it to
Windows OS.
5. Python code that runs in the background recognizes the keywords and generates the corresponding
virtual keystrokes for Windows
The main advantage of using hand gestures is to interact with computer as a non -contact human
computer input modality
Reduce hardware cost by eliminating use of mouse
Convenient for users those who are not comfortable with touch pad
There is no need of sound to be created so no interruption of background noise
A number of functions of computer can be operated by using ultrasonic sensor.
PRAGATI ENGINEERING COLLEGE Page 21
COMPUTER CONTROL USING HAND GESTURE
Using this technique it is easy to interact with the computer and there is no language barrier.
By using this system we can control our laptop from a small distance and it can help to control laptop
in conference room presentation.
3.5 Applications:
The hand gesture control computer can be used for VR (virtual reality), AR (augmented reality), and
3D Design.
Gestures can be used in videogames to try and make the game players experience more interactive.
Navigate in a virtual environment.
Interact with 3D world, System control and image scaling.
This type of hand gesture control of computers can be mostly used in Reading Sign Language.
Communicating in a video conferencing.
CHAPTER-4
HARDWARE IMPLEMENTATION
Arduino UNO x 1
Ultrasonic Sensors x 2
USB Cable (for Arduino)
Few Connecting Wires
A Laptop with internet connection
4.2.1 Sensor:
A device that measures or detects a real-world condition, such as motion, heat or light
and converts the condition into an analog or digital representation. An optical sensor detects the
intensity or brightness of light, or the intensity of red, green and blue for color systems.
To read hand gestures, will need to program an Arduino and design a Python code. As
mentioned earlier that Windows does not recognize commands given by Arduino, hence we use
Python to establish serial connection and turn the data received into virtual keystrokes.
These virtual keystrokes control the Hotkeys of VLC media player and web page
which in turn will control playback of video or audio being played and switch between two tabs.
The Arduino IDE software works well for programming the Arduino but for Python we need to
perform a few more steps after installing
Python 2.7
The steps are as follows:
(1) Upgrade pip function of Python
4.3.2.Software Requirement:
1. Arduino IDE
2. Python 2.7.14
3. VLC Media Player
4.5.1Programming Guide:
The Arduino should be programmed to read the distance of hand from the US
sensor. The complete program is given at the end of this page; the explanation for the program is
given below. The ultrasonic sensor measure the distance between the sensor and the hand by
reading the value of distance we can arrive at certain actions to be controlled with gestures, for
example in this program I have programmed 5 actions as a demo.
Action 1: Place your hand in front of the Right Ultrasonic Sensor at a distance (between
15CM to 35CM) for a small duration and move your hand away from the sensor. From the
figure (4.5.2) .The gesture will Scroll down the Web Page or Decrease the Volume.
Fig
Action 2: Place your hand in front of the Right Ultrasonic Sensor at a distance (between
15CM to 35CM) for a small duration and move your hand towards the sensor. From the
figure (4.5.3). The gesture will Scroll up the Web Page or Increase the Volume.
Fig
(4.3) shows scrolling up of web page
Action 3: Swipe your hand in front of the Right Ultrasonic Sensor. From figure (4.5.4) .The
gesture will move to the Next Tab.
Fig
Action 4: Swipe your hand in front of the Left Ultrasonic Sensor. From the figure
(4.5.4).The gesture will move to the Previous Tab or Play/Pause the Video.
Fig
Action 5: Swipe your hand across both the sensors (Left Sensor first). This action will
Switch between Tasks.
The Above Actions should be produced on the Python GUI output screen as shown below:
Fig
Arduino code:
Let us see how the program is written to perform the above actions. So, like all programs
We start with defining the I/O pins as shown below. The two US sensors are connected to
Digital pins 11, 10, 6 and 5 and are powered by +5V pin. The trigger pins are output pin
and
Echo pins are input pins.
The Serial communication between Arduino and python takes places at a baud rate of
9600
const int trigPin1 = 11; // the number of the trigger output pin ( sensor 1 )
const int echoPin1 = 10; // the number of the echo input pin ( sensor 1 )
const int trigPin2 = 6; // the number of the trigger output pin ( sensor 2 )
const int echoPin2 = 5; // the number of the echo input pin ( sensor 2 )
long duration;
int distance1, distance2;
float r;
unsigned long temp=0;
int temp1=0;
int l=0;
The function void find_distance (void); is used to returns the value in cm. we should not
trigger the both ultrasonic sensor at the same time. it might cause error result due to the
intraction of the both soundswaves. Here the pulseIn function won’t wait more than
5000us for the ultrasonic sound to come back.
We have to initialize the trigger and echo pins of both the sensor as input and output:
void setup()
{
Serial.begin(9600);
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
delay (1000);
}
Here the function find_distane () will stores the current distance measured by the
ultrasonic sensor in the global variable "distance1 and distance2". we have to place our
hands in front of the right sensor in the range between 15 to 35cm .
void loop()
{
Find_distance();
if(distance2<=35 && distance2>=15)
{
temp=millis();
while(millis()<=(temp+300))
find_distance();
Here the below condition becomes true if we moves our hand away from the right sensor,
closer to the sensor, swipe in front of right sensor. Based on the action, here the word
“down”, ”up” or “next” will be sent out through serial port
if(distance2<=35 && distance2>=15)
{
temp=distance2;
while(distance2<=50 || distance2==0)
{
find_distance();
if((temp+6)<distance2)
{
Serial.println("down");
}
else if((temp-6)>distance2)
{
Serial.println("up");
}
}
}
else
{
Serial.println("next");
}
}
once if we placed our hands in front of the left sensor in the range between 15 to 35cm if the
condition becomes true.
else if(distance1<=35 && distance1>=15)
{
temp=millis();
while(millis()<=(temp+300))
{
find_distance();
if our hand detects in the right sensor before 300 milli seconds this condition becomes true.
( usually it happens if we swipe our hand from left to right sensor ).it sends change serially
And it stores the variable 1 and break the loop.
if(distance2<=35 && distance2>=15)
{
Serial.println("change");
l=1;
break;
}
}
if we swipe our hand in front of left sensor then condition becomes true and enters into the loop then
the "previous" will send to serially.this loop will rotate untill we remove our hand infront of
The left sensor. This will avoid not to enter this if condition again.
if(l==0)
{
Serial.println("previous");
while(distance1<=35 && distance1>=15)
find_distance();
}
l=0;
}
}
Phython code:
Let us import all the three required modules for this project. They are pyautogui, serial
python and time.
The module PyAutoGUI will help us for programmatically control the mouse and the
keyboard.
With the help of PyAutoGUI, we can write a Python Program to mimic the actions of mouse
like
Left click, right click, scroll, etc. and keyboard like keypress, enter text, multiple key press,
etc.
Without physically doing them.
import pyautogui
Next we establish connection with the Arduino through COM port. In my computer the
Arduino
Is connected to COM 18. Use device manager to find to which COM port your Arduino is
Arduino Serial = serial.Serial ('com18', 9600) #Create Serial port object called Arduino Serial
Data
Time sleep(2) #wait for 2 seconds for the communication to get established
Arduino_Serial = serial.Serial('com12',9600)
while 1:
incoming_data = str (Arduino_Serial.readline())
print incoming_data
if 'next' in incoming_data:
pyautogui.hotkey('ctrl', 'pgdn')
if 'previous' in incoming_data:
pyautogui.hotkey('ctrl', 'pgup')
Here if incoming data is 'down' it performs "down arrow" operation which scrolls down the
page
if 'down' in incoming_data:
#pyautogui.press('down')
pyautogui.scroll(-100)
Here if incoming data is 'up' performs "up arrow" operation which scrolls up the page
if 'up' in incoming_data:
#pyautogui.press('up')
pyautogui.scroll(100)
Here if incoming data is 'change' performs "alt+tab" operation which switches the tab
if 'change' in incoming_data:
pyautogui.keyDown('alt')
pyautogui.press('tab')
pyautogui.keyUp('alt')
incoming_data = "";
Chapter-5
RESULT
Result:
The hand Gesture Control Computer kit was tested by our team members with 3 trials.
We tested the kit by playing a video in a VLC player and web Browser purpose. We Checked
for different commands like switching to a next tab, switching to a previous tab, scroll down
in a web page, scroll up in a web page, play/pause video in vlc player, increase volume and
decrease volume and switch between two tasks(chrome and VLC player).In The very first 1 st
trial, the commands: switching to a next tab, switching to a previous tab, scroll down in a web
page are Worked out perfectly.so we perform 2 more trials to workout the other commands
but it was not perfectly done. There is a need to update the code for such commands.
There is a great scope of updating the code to try with many functions. We can use
this basic code to surf in any file applications as opening a document, editing a text ,We can
use notepad. We can also implement automation techniques by updating the code as per
requirement.
Conclusion:
Gesture recognition is very challenging and interesting task in terms of accuracy and
usefulness in computer vision.
Most important advantage is that we can efficiently interact with the application from a
distance without any physical restriction
This prototype implements several applications that demonstrate the usefulness, validity
and flexibility of the system to interact with this information via natural hand gesture.
The importance of gesture recognition lies in building efficient human machine interaction.
Gesture recognition promises wide ranging applications in field from photo journalism
through medical technology to biometrics.
Future Scope:
Hand gesture technique is not only limited to gaming, using basic function of computer it can
be useful for medical applications.
Hand gesture technique can work as input method between medical instruments and
human body as proposed.
Rotation, background variations, illumination change and pose variation of hand makes the
problem more challenging.
It can be used for operating each and every functions of computer
REFERENCES:
[1]Cost effective hand gesture computer control interface, Gergely Sziládi ; Tibor
Ujbányi; József Katona 2016 7th IEEE International Conference on Cognitive Info
communications
[2]Vision based computer mouse control using hand gestures , Sandeep Thakur; Rajesh
Mehra ; Buddhi Prakash, 2015 International Conference on Soft Computing Techniques and
Implementations (ICSCTI)
[3]A basic hand gesture control system for PC applications C. J. Cohen ;G. Beach
;G.Foulk Proceedings 30th Applied Imagery Pattern Recognition Workshop (AIPR 2001).
Analysis and Understanding of Time Varying Imagery
[4]A system for controlling personal computers by hand gestures using a wireless
sensor vice, Kaoru magishi; LeiJing; Zixue Cheng 2014 IEEE International Symposium
on Independent Computing (ISIC)
[6]Power point control using hand gesture recognition based on hog feature extraction
and k-nn classification, Tejashree P. Salunke; S. D. Bharkad,2017 International Conference
on Computing Methodologies and Communication (ICCMC)
[7]Distance Measurement using Ultrasonic Sensor and Arduino, CH. Neeraja Soni1,
CH.Sarita2, ShrikantMaheshwari3, Basantkumar Sahu4, Bhavishya Jain5, Garima
Shrivastava6 Student1, 2, 3, 4, 5, Assistant Profeesor 6 YITM, Rajnandgaon, India
[8]Comfortable mouse control using 3Ddepth sensor, Szilvia Szeghalmy; Marianna Zichar;
Attila Fazekas, 2013 IEEE4th International Conference on Cognitive Info communications
[10]Distance Sensing with Ultrasonic Sensor and Arduino, N. Anju Latha1 , B. Rama
Murthy2, K. Bharat Kumar 3 Department of Instrumentation, Sri Krishnadevaraya
University, Anantapur, A.P., India
APPENDIX:
ARDUINO CODE:
const int trigPin1 = 11; // the number of the trigger output pin ( sensor 1 )
const int echoPin1 = 10; // the number of the echo input pin ( sensor 1 )
const int trigPin2 = 6; // the number of the trigger output pin ( sensor 2 )
const int echoPin2 = 5; // the number of the echo input pin ( sensor 2 )
////////////////////////////////// variables used for distance calculation
long duration;
int distance1, distance2;
float r;
unsigned long temp=0;
int temp1=0;
int l=0;
////////////////////////////////
Void find_distance (void); // this function returns the value in cm.
/*we should not trigger the both ultrasonic sensor at the same time.
It might cause error result due to the interaction of the both sounds waves.*/
void find_distance (void)
{
digitalWrite(trigPin1, LOW);
delayMicroseconds(2);
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
duration = pulseIn(echoPin1, HIGH, 5000); // here this pulsein function won’t wait more then
5000us for the ultrasonic sound to came back. (due to
this it won’t measure more than 60cm)
r = 3.4 * duration / 2; // calculation to get the measurement in cm using the time returned
by the pulsein function.
distance1 = r / 100.00;
/////////////////////////////////////////upper part for left sensor and lower part for right sensor
digitalWrite(trigPin2, LOW);
delayMicroseconds(2);
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
duration = pulseIn(echoPin2, HIGH, 5000);
r = 3.4 * duration / 2;
distance2 = r / 100.00;
delay(100);
}
void setup()
{
Serial.begin(9600);
pinMode(trigPin1, OUTPUT); // initialize the trigger and echo pins of both the sensor as
input and output:
pinMode(echoPin1, INPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
delay (1000);
}
void loop()
{
find_distance(); // this function will stores the current distance measured by the
Ultrasonic sensor in the global variable "distance1 and distance2".
if(distance2<=35 && distance2>=15) // if we placed our hands in front of the right sensor in
The range between 15 to 35cm this condition becomes true.
{
temp=millis(); // store the current time in the variable temp. (" millis " Returns
the no of milliseconds since the Arduino board began
running the current program )
while(millis()<=(temp+300)) // this loop measures the distance for another 300 milli
Seconds. ( it helps to find the difference between swipe
and stay of our hand in front of the right sensor )
find_distance();
if(distance2<=35 && distance2>=15) // this condition will true if we place our hand in front
Of the right sensor for more than 300 milli seconds.
{
Temp =distance2; // store current position of our hand in the variable temp.
while(distance2<=50 || distance2==0) // this loop will run untill we removes our hand in front
Of the right sensor.
{
find_distance (); // call this function continuously to get the live data.
if((temp+6)<distance2) // condition becomes true if we moves our hand away