The Code Project
View our advertisersAdvertise with us
All Topics, MFC / C++ >> C++ / MFC >> Mouse Topics

Mouse gestures recognition
By Konstantin Boukreev

Feedforward multilayer neural network and mouse gesture recognition 
 C++ (VC6)
Windows (Win98, Win2K)
Win32, VS
Dev
 Posted 23 Nov 2001
Articles by this author
94,505 views
Search:
Toolbox
Broken Article?
VS.NET 2003 for $899
Ultimate Toolbox $499
Print version
Send to a friend

Sign in / Sign up
 Email
 Password
Remember me
Lost your Password?
 


75 members have rated this article. Result:
Popularity: 9.04. Rating: 4.82 out of 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

About Konstantin Boukreev


I am freelance programmer. About 3 years of experience in C++ and I would rather use ATL, STL, WTL but not MFC . 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.

Click here to view Konstantin Boukreev's online profile.


Other popular articles:

[Top] Sign in to vote for this article:     PoorExcellent  

Premium Sponsor

Hint: For a faster board use IE 4+ or Mozilla, choose 'Message View' from the View dropdown and hit 'Set Options'.
FAQ Noise tolerance    Search comments  
 View   Per page  
New MessageMsgs 1 to 25 of 36 (Total: 36) (Refresh)[First] [Prev] [Next] [    ]
Subject 
Author 
Date 
  need algorithm for VB6. anyone could help? PLEASE...
 Smart Canix 9:46 25 Jun '04 
  Continous Monitoring
 adsjk 17:13 29 Dec '03 
  Interpolating < 16 points. Code included
 adamtegen 17:09 11 Nov '03 
  Compiling with .NET
 quorm 19:35 26 Aug '03 
  Re: Compiling with .NET
 John M. Drescher 20:01 26 Aug '03 
  Re: Compiling with .NET
 quorm 20:41 26 Aug '03 
  Re: Compiling with .NET
 John M. Drescher 20:50 26 Aug '03 
  Not really know how to use your app!
 Chua Wen Ching 13:27 1 Jul '03 
  Re: Not really know how to use your app!
 matlin123 14:51 26 Jul '03 
  Need help in image recognition
 alexpop 9:36 19 Jun '03 
  Need help in image recognition
 alexpop 9:29 19 Jun '03 
  A great try, however ...
 xxxyyyzzz 0:37 23 Oct '02 
  what is this proggy good for ?
Unconfirmed/Anonymous posting Anonymous 11:39 19 Jul '02 
  Really Cool
 Tom Mason 11:12 21 Mar '02 
  You may consider a little improvements...
Unconfirmed/Anonymous posting igor1960 3:49 5 Jan '02 
  Re: You may consider a little improvements...
 Konstantin Boukreev 3:58 14 Jan '02 
  Re: You may consider a little improvements...
Unconfirmed/Anonymous posting Anonymous 10:47 25 Sep '02 
  Congratulations!!!
 Konstantin Vasserman 8:25 18 Dec '01 
  Re: Congratulations!!!
 Konstantin Boukreev 8:33 18 Dec '01 
  Re: Congratulations!!!
 Konstantin Vasserman 8:50 18 Dec '01 
  Re: Congratulations!!!
 Konstantin Boukreev 9:10 18 Dec '01 
 
> Боюсь что мне прийдется тебя разочаровать.

Нет проблем

> Я как раз надеялся, что ты можешь какого-нибудь хорошего чтива
> или хороших сайтов по этой тематике порекомендовать

С удовольствием.

Начнем с книг на русском.
"Искусственные нейронные сети" Круглов и Борисов. 2001.

Скоро должна выйти "Основные концепции нейронных сетей" Каллан.
на www.books.ru уже можно заказать http://books.ru/shop/books/21475

На http://neurnews.iu4.bmstu.ru/book/ есть подборка всеких разных материалов.

В инете можно найтьи статьи С.Короткий. Достаточно интересно.
Можно скачать с http://stud.math.rsu.ru/actuar/dima/neiro5.ru.html.

Также если хочешь то могу выслать учебное пособие
"И.Заенцев Нейронные сети:основные модели"
в pdf (900 k)

Вот еще на русском, конспект лекций
http://nuweb.jinr.ru/~nazaren/unc/nn_ru.html








 
[Reply][Email][View Thread][Get Link][Modify|Delete]
  Re: Congratulations!!!
 Konstantin Vasserman 9:30 18 Dec '01 
  Re: Congratulations!!!
 Konstantin Boukreev 9:40 18 Dec '01 
  Re: Congratulations!!!
 Konstantin Boukreev 9:17 18 Dec '01 
  Too good
 Robert Cao 2:19 18 Dec '01 
Last Visit: 13:42 Monday 12th September, 2005[First] [Prev] [Next] [    ]

General comment    News / Info    Question    Answer    Joke / Game    Admin message


All Topics, MFC / C++ >> C++ / MFC >> Mouse Topics
Updated: 23 Nov 2001
Article content copyright Konstantin Boukreev, 2001
everything else Copyright © CodeProject, 1999-2005.
Advertise on The Code Project | Privacy

The Ultimate Toolbox ? MSDN Communities | ASP Alliance ? Developer Fusion ? Developersdex ? DevGuru ? Programmers Heaven ? Planet Source Code ? Tek-Tips Forums ?