Click here to Skip to main content
6,630,289 members and growing! (15,752 online)
Email Password   helpLost your password?
General Reading » Hardware & System » Mouse Topics     Intermediate

Mouse gestures recognition

By Konstantin Boukreev

Feedforward multilayer neural network and mouse gesture recognition
VC6Win2K, Dev
Posted:22 Nov 2001
Views:204,604
Bookmarked:137 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
88 votes for this article.
Popularity: 9.40 Rating: 4.83 out of 5

1

2

3
8 votes, 18.2%
4
36 votes, 81.8%
5

Sample Image

Introduction

Recently I installed Opera 5 and was impressed on a Gesture UI. Moreover several weeks ago I noticed a discussion on CodeProject's Lounge about it. To all appearances people want to know about it too :). IMHO, the neural network most suitable for this purpose. As I a little know neural network I tried to implement such feature themselves.

Neural Network

What is Neural Network ? Hm it's not easy to say. A rephrased definition Zurada, J.M.:

"Neural network software is a software which can acquire, store, and utilize experiential knowledge."

I think I can point any person concerned to theory directly to several neural network sites. Here is small list of web resources about Neural networks:

Implementation

Let's return to mouse gestures. After some research I have chosen a multilayer perceptron and standard back-propagation algorithm for training. The main problem was in the representation of an input data for neural network. The best result I found was in the transformation of a mouse path into a vector of cosines and sines.

For example:

path   {170:82 172:83 175:85 177:86 ...} 
transformed into 
vector {0.45 0.55 0.45 0.71 ... 0.89 0.83 0.89 0.71 ...}

Recognition algorithm.

  1. record a mouse path
  2. smooth a path to a base points
  3. transform points to angles' vector
  4. compute sines and cosines
  5. pass values (cosines and sines) to network's inputs
  6. apply softmax function on an output network vector
  7. find and verify a winner

Neural network architecture.

  • input layers : 32 sinapses
  • hidded layer : 32 neurons
  • output layer : 29 axons (one for each gesture)
  • fully connected layers
  • transfer function : log-sigmoid
  • incremental training algorithm, standard back-propagation method
  • momentum, variable learning rate (slowly reduced)
  • input noise

Application

Training

Sample Image

Before testing the recognition ability you must train the network (or you can load an file image of trained net). You can customize the parameters of the training process, namely: maximum number of cycles, a momentum value, a learning rate, a minimum value of mean square error (in other words "target error"). The training process will stop after achieving either of the conditions: maximum number of cycles or target error. During the training process you can keep an eye on a error's graph, a current gesture (with noise) and 2D network presentation.

Testing

As soon as you have a trained net, you can test it. Select the patterns (or test all of them), a speed value and a noise level. Besides, you can familiarize oneself with ideal presentation of gestures via setting minimal noise and minimal speed.

Recognition

For recognition of mouse gestures you must press right mouse button during moving a mouse. For example for recognition "left" gesture, press right mouse button and move a mouse to the left. If a neural network can recognize the gesture, then you will see the name, probability and ideal presentation of winner. Because of freeware nature of GestureApp the mouse path must have at least 16 points :(. Sorry I didn't implemented a "stretch a path" feature so far.

Note: the direction is very important.

The network is trained to recognize the gestures but not 2D images. Hence, you can draw the "circle" gesture a thousand different ways, but the only valid way is: press mouse button and move a mouse to the right and down and so on. Once more: it's gesture, not 2D image.

Mouse gestures

Compatibility

Compatible with Win2k, WinXP, Win98, WinMe. Unfortunately doesn't work on WinNT because of the need for the AlphaBlend API.

Acknowledgement

Special Thanks:
My wife Julia for her nice artwork ;)

And thanks to:
Pedro Pombeiro for Selection slider control

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Konstantin Boukreev


Member
I am freelance programmer. About 3 years of experience in C++ and I would rather use ATL, STL, WTL but not MFC Smile. Main backgrounds are Win32 API, COM and Networking. Now I am interested about AI (Neural Network, Fuzzy Logic and GA). Currently based in Vladivostok, Russia.
Occupation: Web Developer
Location: Russian Federation Russian Federation

Other popular Hardware & System articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 43 (Total in Forum: 43) (Refresh)FirstPrevNext
GeneralStill very nice but needs a few changes Pinmemberbaylorw16:21 17 Nov '08  
Generaldigitizer or pen tablet processing PinmemberHOYAM11:50 11 Jul '07  
Generalge processing I also need document about image processing and code Pinmember16:54 1 Mar '07  
GeneralIntegrate the project in a console opengl application? HELP! Pinmemberninkata0:46 1 Mar '07  
QuestionMean square least to fit a circle PinmemberMichae_geffen11:00 7 Jan '07  
Generalneed algorithm for VB6. anyone could help? PLEASE... PinmemberSmart Canix4:46 25 Jun '04  
GeneralContinous Monitoring Pinmemberadsjk12:13 29 Dec '03  
GeneralInterpolating < 16 points. Code included Pinmemberadamtegen12:09 11 Nov '03  
GeneralRe: Interpolating < 16 points. Code included PinmemberApuhjee6:45 19 Sep '08  
GeneralCompiling with .NET Pinmemberquorm14:35 26 Aug '03  
GeneralRe: Compiling with .NET PinmemberJohn M. Drescher15:01 26 Aug '03  
GeneralRe: Compiling with .NET Pinmemberquorm15:41 26 Aug '03  
GeneralRe: Compiling with .NET PinmemberJohn M. Drescher15:50 26 Aug '03  
GeneralNot really know how to use your app! PinmemberChua Wen Ching8:27 1 Jul '03  
GeneralRe: Not really know how to use your app! Pinmembermatlin1239:51 26 Jul '03  
GeneralNeed help in image recognition Pinmemberalexpop4:36 19 Jun '03  
GeneralNeed help in speech recognition PinmemberMahesh Bhargava20:36 30 May '06  
GeneralNeed help in image recognition Pinmemberalexpop4:29 19 Jun '03  
GeneralA great try, however ... Pinmemberxxxyyyzzz19:37 22 Oct '02  
Generalwhat is this proggy good for ? PinsussAnonymous6:39 19 Jul '02  
GeneralReally Cool PinmemberTom Mason6:12 21 Mar '02  
GeneralYou may consider a little improvements... Pinmemberigor196022:49 4 Jan '02  
GeneralRe: You may consider a little improvements... PinmemberKonstantin Boukreev22:58 13 Jan '02  
GeneralRe: You may consider a little improvements... PinsussAnonymous5:47 25 Sep '02  
GeneralCongratulations!!! PinmemberKonstantin Vasserman3:25 18 Dec '01  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 22 Nov 2001
Editor: Chris Maunder
Copyright 2001 by Konstantin Boukreev
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project