Documente Academic
Documente Profesional
Documente Cultură
Project Report
On
Real-Time Hand Gesture Recognition
In partial fulfillment of requirements for the diploma in
Computer Technology
SUBMITTED BY:
1. Mr. Bhutadiya Kiran
2. Mr. Kulkarni Devavrat
3. Mr. Dhadve Nitin
4. Mr. Warang Harmit
Under the Guidance of
Prof. Sushil Andhale
Diploma
CM
Real-Time Hand Gesture Recognition
2014 -
2015
2
MM's BGIT - Mumbai 2014 -15
CERTIFICATE
This is to certify that the project entitled HAND
DETECTION USING MULTIPLE PROPOSALS has been
carried out by the team under my guidance in partial fulfillment
of the diploma in Computer Technology MSBTE during the
academic year 2014-2015(Semester-V and Semester-VI).
Team:
Date:
Place: Mumbai
3
MM's BGIT - Mumbai 2014 -15
Team:
1. Mr. Bhutadiya Kiran
2. Mr. Kulkarni Devavrat
3. Mr. Dhadve Nitin
4. Mr. Warang Harmit
External Examiner:
Date:
ACKNOWLEDGEMENT
We also appreciate Prof. Sushil Andhale, Lecturer our Project Guide who
also put in lot of efforts in giving us the right guidance during the
development process of the project. We also appreciate her eagerness and
enthusiasm in encouraging us to develop our creative and technical ideas,
which ultimately led to success of our project.
Our special thanks also to the non-teaching staff for their great support and
kind cooperation to provide us with whatever we required for the project.
We also thank our family and our friends for their support and good wishes
for our project. Never to be forgotten, we thank God for granting us
success in our efforts during the formation of the project.
By-
5
MM's BGIT - Mumbai 2014 -15
INDEX
1 Introduction
1.1 Real-Time Hand Gesture Recognition
2 Market Survey
3 System Analysis
3.1 Static Hand Gesture
3.2 Dynamic Hand Gesture Recognition
3.3 Virtual Mouse
4 Coding
5 Testing
5.1 Formal Technical Review
5.2 Test Plan
5.3 Unit Testing
5.4 Integration Testing
5.5 System Testing
5.6 Functional Testing
5.7 Performance Testing
5.8 Stress Testing
5.9 Goals & Objectives
5.10 Test Cases
6 Modeling
6.1 Use Case Diagrams
6.2 Activity Diagrams
6.3 Sequence Diagrams
6.4 State Transition Diagrams
7 Snapshots
8 Appendix
8.1 Programming
8.2 Programming Principles
9 Bibilography
6
MM's BGIT - Mumbai 2014 -15
ABSTRACT
7
MM's BGIT - Mumbai 2014 -15
Chapter 1
Introduction
8
MM's BGIT - Mumbai 2014 -15
CHAPTER -1
INTRODUCTION
10
MM's BGIT - Mumbai 2014 -15
Chapter 2
Market
Survey
11
MM's BGIT - Mumbai 2014 -15
CHAPTER -2
MARKET SURVEY
Future Prospects:-
The hand detection is still images will further detect both
left and right hand in still images and also index finger,
middle finger, ring finger, little finger and also the thumb.
And this application will be useful in creating a platform
for gesture recognizing.
MUSIC PLAYER:
ActiveX is a Microsoft Windows protocol for component
integration. With help of ActiveX,it is possible to integrate
matlab and Microsoft media player .
Han = actxcontrol('WMPlayer.OCX.7)
It will create an object of WMPlayer. By changing the
12
MM's BGIT - Mumbai 2014 -15
13
MM's BGIT - Mumbai 2014 -15
Chapter 3
System
Analysis
14
MM's BGIT - Mumbai 2014 -15
CHAPTER -3
SYSTEM ANALYSIS
16
MM's BGIT - Mumbai 2014 -15
I) K Curvature Method
17
MM's BGIT - Mumbai 2014 -15
18
MM's BGIT - Mumbai 2014 -15
19
MM's BGIT - Mumbai 2014 -15
20
MM's BGIT - Mumbai 2014 -15
Chapter 4
Coding
21
MM's BGIT - Mumbai 2014 -15
CHAPTER - 4
CODING
clear all;
%vid = videoinput('winvideo', 1,'YUY2_640x480');
%vid = videoinput('winvideo', 1,'RGB24_640x480');
%vid = videoinput('winvideo', 1, 'YUY2_160x120');
%vid = videoinput('winvideo', 1, 'YUY2_176x144');
vid = videoinput('winvideo', 1, 'YUY2_640x480');
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb');
vid.FrameGrabInterval = 5;
num=0;
count=0;
%start the video aquisition here
cnt(1)=100;
cnt(2)=100;
import java.awt.Robot;
mouse = Robot;
t=0;
mouse.mouseMove(0, 0);
screenSize = get(0, 'screensize');
while(num<10)
%dialogue box
t=0;
str={'static gesture','dynamic gesture','virtual mouse','exit'} ;
[s,v] = listdlg('PromptString','SELECT THE OPERATION:',...
'name','HAND GESTURE RECOGNITION
SYSTEM','SelectionMode','single',...
'ListSize',[500 500],'ListString',str,'uh',30);
if(v==0)
break;
22
MM's BGIT - Mumbai 2014 -15
end
switch s
case 1
%-------------------------------------------------------------------------
%static gesture
%-------------------------------------------------------------------------
prompt = {'Enter k value','enter the angle threshold'};
dlg_title = 'threshold values';
num_lines = 1;
def = {'33','60'};
th = inputdlg(prompt,dlg_title,num_lines,def);
while(t<10)
start(vid);
CH=0;
while(vid.FramesAvailable<=30)
Lw=bwlabel(I2);
stat = regionprops(Lw,'Area');
23
MM's BGIT - Mumbai 2014 -15
[cal,index] = max([stat.Area]);
tf = ismember(Lw, index);
stats1 = regionprops(tf, 'BoundingBox', 'Centroid');
%---clc--------------------------------------------------
grayFrame=tf;
%canny for hand coutour extraction
canny_op = edge(grayFrame,'canny');
L = bwlabel(canny_op,8);
stats = regionprops(L,'Area');
[cal,index] = max([stats.Area]);
%%% display(cal);
pix = ismember(L,index);
%k = ceil(sqrt(cal)/3);
k = str2num(th{1});
% k=33;
% imshow(L);
% figure,imshow(pix);
Q=pix;
[start_row,start_col]=find(Q,1);
hand_boundary_canny = bwtraceboundary(Q,
[start_row,start_col],'ne',8,Inf,'clockwise');
Q=hand_boundary_canny;
len=size(Q);
l=len(1);
%theta=zeros(l,1);
for i=k:1:l-k
if (i==k)
continue;
end
X1=Q(i,1);
X2=Q(i+k,1);
X3=Q(i-k,1);
24
MM's BGIT - Mumbai 2014 -15
Y1=Q(i,2);
Y2=Q(i+k,2);
Y3=Q(i-k,2);
m1=(Y2-Y1)/(X2-X1);
m2=(Y3-Y1)/(X3-X1);
theta(i)=atand((m2-m1)/(1+m1*m2));
end
% imshow(qq);
% % qq=zeros(pp);
% L3 = zeros(size(Q,1),size(Q,2));
%
%
% yy=size(theta);
% t=1:yy(:,2);
%plot(t,theta,'r*');
[ww ee]=find(theta> str2num(th{2})& theta<90);
es=size(ee);
%imshow(pix);
%plot(Q(:,1),Q(:,2),'r.');
[pp bb]=size(L);
ab=zeros(pp,bb);
%ab=[];
%ab(Q)=1;
% figure,imshow(ab)
for j=1:es(1,2)
m=ee(j);
if(m>size(Q,1))
continue;
end
% ab(Q(m,1),Q(m,2))=250;
ab(Q(m,1)-1:Q(m,1)+1,Q(m,2)-1:Q(m,2)+1)=250;
%hold on;
% plot(Q(m,1),Q(m,2),'g*','LineWidth',20,...
% 'MarkerEdgeColor','y',...
% 'MarkerFaceColor','r',...
% 'MarkerSize',20);
end
25
MM's BGIT - Mumbai 2014 -15
m=ab|L;
% imshow(m);
se = strel('disk',14);
closeBW = imdilate(ab,se);
%imshow(~closeBW);
[L num]=bwlabel(closeBW);
%disp(num)
f=regionprops(L,'centroid','BoundingBox');
box=cat(1,f.BoundingBox);
centroids = cat(1, f.Centroid);
if(numel(centroids)==0)
centroids=[start_row,start_col];
end
imshow(data)
hold on
plot(centroids(:,1), centroids(:,2),'g.','LineWidth',5,...
'MarkerEdgeColor','y',...
'MarkerFaceColor','y',...
'MarkerSize',20);
%figure,imshow(ab)
% figure,plot(t,theta)
switch num
case 1
m=text(600,150,'1');
k=1;
%disp('1');
case 2
%disp('1');
m=text(600,150,'1');
k=1;
26
MM's BGIT - Mumbai 2014 -15
case 3
% disp('2');
m=text(600,150,'2');
k=2;
case 4
%disp('2');
m=text(600,150,'2');
k=2;
case 5
%disp('3');
m=text(600,150,'3');
k=3;
case 6
%disp('3');
m=text(600,150,'3');
k=3;
case 7
%disp('4');
m=text(600,150,'4');
k=4;
case 8
%disp('4');
m=text(600,150,'4');
k=4;
case 9
%disp('5');
m=text(600,150,'5');
k=5;
case 10
%disp('5');
m=text(600,150,'5');
k=5;
otherwise
%disp('5');
m=text(600,150,'5');
k=5;
end
27
MM's BGIT - Mumbai 2014 -15
%...................................................
%-----------------------------------------------------
% if(bc(:,1)>700)
% a=text(200,50,'left');
% else
% a=text(200,50,'right');
% end
%
% if (bc(:,2)>350)
% b=text(600,50,'down');
% else
% b=text(600,50,'up');
% end
%
% set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize',
30, 'Color', 'red');
% set(b, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize',
30, 'Color', 'red');
% set(m, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize',
30, 'Color', 'red');
% set(text(60,500,'DYNAMIC GESTURE
RECOGNITION'), 'FontName', 'Arial', 'FontWeight', 'bold',
'FontSize', 12, 'Color', 'green');
% mouse.mouseMove(bc(:,1), bc(:,2));
28
MM's BGIT - Mumbai 2014 -15
% pause(0.00001);
count=[];
if(vid.FramesAvailable>=15)
set(text(50,50,'.'), 'FontName', 'Arial', 'FontWeight', 'bold',
'FontSize', 50, 'Color', 'red');
set(m, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize',
10, 'Color', 'black');
count=[count ;k]
end
end
end
hold off;
num=mode(count);
count=[];
disp(num);
%warndlg(num2str(num));
mm=num2str(num);
st=' is the count';
mm=[mm st];
% Construct a questdlg with three options
choice = questdlg(mm, ...
'count', ...
'I WANT TO CONTINUE','NO','NO');
% Handle response
if(strcmp(choice,'I WANT TO CONTINUE'))
CH = 1;
t=t+1;
stop(vid);
flushdata(vid);
end
29
MM's BGIT - Mumbai 2014 -15
if(strcmp(choice,'NO'))
stop(vid) ;
break;
end
close all;
end
stop(vid);
flushdata(vid);
case 2
%-------------------------------------------------------------------------
%dynamic gesture
%-------------------------------------------------------------------------
start(vid);
while(vid.FramesAvailable<=30)
J=rgb2ycbcr(data);
L=graythresh(J(:,:,2));
BW=im2bw(J(:,:,2),L);
BW1=~BW;
M=graythresh(J(:,:,3));
BW2=im2bw(J(:,:,3),M);
o=BW1.*BW2;
roi=o;
hold on
if(bc(:,1)>350)
a=text(200,50,'left');
else
a=text(200,50,'right');
end
if (bc(:,2)>250)
b=text(600,50,'down');
else
b=text(600,50,'up');
end
% if(bc(:,1)>512)
% a=text(bc(:,1)+15,bc(:,2),'right');
% else
% a=text(bc(:,1)+15,bc(:,2),'left');
% end
%
% if (bc(:,2)>384)
% b=text(bc(:,1)+100,bc(:,2),'down');
% else
% b=text(bc(:,1)+100,bc(:,2),'up');
% end
31
MM's BGIT - Mumbai 2014 -15
%-------------------------------------------------------------------
end
end
stop(vid);
flushdata(vid);
case 3
%-------------------------------------------------------------------
%mouse
%-------------------------------------------------------------------
start(vid);
while(vid.FramesAvailable<=30)
J=rgb2ycbcr(data);
L=graythresh(J(:,:,2));
BW=im2bw(J(:,:,2),L);
BW1=~BW;
M=graythresh(J(:,:,3));
BW2=im2bw(J(:,:,3),M);
32
MM's BGIT - Mumbai 2014 -15
o=BW1.*BW2;
roi=o;
hold on
mouse.mouseMove(bc(:,1), bc(:,2));
end
end
stop(vid);
flushdata(vid);
case 4
close all;
break;
otherwise
break;
33
MM's BGIT - Mumbai 2014 -15
end
===============================================
34
MM's BGIT - Mumbai 2014 -15
Chapter 5
Testing
35
MM's BGIT - Mumbai 2014 -15
CHAPTER - 5
TESTING
Test Plan
36
MM's BGIT - Mumbai 2014 -15
Unit Testing
Integration Testing
It involves testing of combined part of application. To
determine if they function together correctly. The part can
be core module, individual application, client & server
application on n/w etc.
This type of testing is specially relevant to client/server
and distribute system.
37
MM's BGIT - Mumbai 2014 -15
System Testing
Functional Testing
Performance Testing
Stress Testing
39
MM's BGIT - Mumbai 2014 -15
Test Cases:-
Sr. Test Objective Pre- Steps I/P data Expected Actual Status
No. Cases requistes Results Results
1 TC_1 Check the K-value 1.Run the Int K-value Click on PASS
validity of K- field is program should OK
value available & 2.Select be makes
not passive static entered static
gesture as valid gesture
3.Enter int. work
K-value
2 TC_2 Check the K-value 1.Run the Int K-value Click on PASS
validity of field is program should OK
threshold available & 2.Select be makes
value not passive static entered static
gesture as valid gesture
3.Enter int. work
K-value
3 TC_3 Check the K-curvature 1.Run Real- 5 is 5 is PASS
hand gesture algorithm is 2.Select Time count count
working static Hand
gesture (5
fingers)
4 TC_4 Check the Centroid 1.Run Real- Left-up Left-up PASS
position of tracking is 2.Select Time
hand working dynamic hand
hand moving
gesture in left-
up
directio
n
5 TC_5 Check the Centroid 1.Run Real Mouse Mouse PASS
validity of tracking is 2.Select hand is pointer is pointer is
virtual mouse working virtual moving moving moving
mouse
40
MM's BGIT - Mumbai 2014 -15
Chapter 6
Modeling
41
MM's BGIT - Mumbai 2014 -15
Chapter 6
MODELING
UML Diagram
42
MM's BGIT - Mumbai 2014 -15
Communicates
The participants of an actor in a use case is shown by
connecting the actor symbol to use case symbol by a solid
path. The actor is said to 'communicate' with the use case.
This is only relation between an actor and use cases.
Extends
An extend shows the relationships between use cases.
Relationship between use case A and B indicates that an
instance of use case B may include the behavior specified
by A. An extends' relationship between use cases is
depicted with a directed arrow having dotted.
43
MM's BGIT - Mumbai 2014 -15
44
MM's BGIT - Mumbai 2014 -15
45
MM's BGIT - Mumbai 2014 -15
46
MM's BGIT - Mumbai 2014 -15
Activity Diagram
Fig b.Activity
3) Transition:
When an activity state is completed, processing moves to
another activity state. Transitions are use to mark this
movement. Transitions are modeled.
Event[guard condition]/ action
Fig c.Transition
47
MM's BGIT - Mumbai 2014 -15
4) Decisions :
It is similar to flow charts a logic where a decision is to
be made is depicted by the diamond with the options
written on either side of the arrows emerging from the
diamond within box brackets.
48
MM's BGIT - Mumbai 2014 -15
Sequence Diagram
When an objet passes a message to another object the
receiving object might in turn sends a message to another
object which in turn sends message to yet another object
and so on. This stream of message forms a sequence
diagram depicts a sequence of action that occur in a
system .The invocation of methods in each objects and the
oreder in which the invocation occur is captured in
sequence diagram.This makes the sequence diagram a
very useful tool to easily represent the dynamic behaviour
of system.
Sequence diagram are typically used to model:
1) Usage Scenarios.
2) The Logic Of Methods.
Element of sequence diagrams:
1)Class Roles:
Class roles describe the way an object will behave in
context use he UML object symbol to illustrate class roles.
But does not list the object attributes.
Object Name : Class :Class Name
Name
Fig a.Object
2)Actor : An external entity that interacts with the system.
Actor
Fig b Actor
50
MM's BGIT - Mumbai 2014 -15
52
MM's BGIT - Mumbai 2014 -15
53
MM's BGIT - Mumbai 2014 -15
Chapter 7
Snapshots
55
MM's BGIT - Mumbai 2014 -15
56
MM's BGIT - Mumbai 2014 -15
57
MM's BGIT - Mumbai 2014 -15
58
MM's BGIT - Mumbai 2014 -15
59
MM's BGIT - Mumbai 2014 -15
60
MM's BGIT - Mumbai 2014 -15
Chapter 8
Appendix
61
MM's BGIT - Mumbai 2014 -15
Chapter -8
APPENDIX
Programming
Programming Principles
Chapter 9
BIBILOGRA
PHY
63
MM's BGIT - Mumbai 2014 -15
CHAPTER -9
BIBILOGRAPHY
64
MM's BGIT - Mumbai 2014 -15
65