NAME - sample use of gestures engine



Start it up


Draw something in the canvas (with button1 down)


Press 'Record'


Press 'Clear' (you have to do this before drawing any new stroke)


Do 2-4 again some times


Draw something similar to one of the recorded strokes


Press 'Match'


Look at STDOUT (the strokes are named with numbers in order of recording)


This program is used to try out various normalization / segmentation / matching algorithms.

Look at the following for details on the algorithms themselves:


First of all, it creates a Tk window with a canvas and three buttons: "Match", "Record" and "Clear", with the following bindings:


calls sub match() to perform the matching of the entered stroke with the @knows_strokes


calls sub record() to add the entered stroke to the @known_strokes


calls sub clear() to clean up the stroke

ButtonPress-1 on the canvas

calls sub start_stroke(Ev('x'),Ev('y')) to set up the recording of the stroke

B1-Motion on the canvas

calls sub update_stroke(Ev('x'),Ev('y')) to add points to the stroke

ButtonRelease-1 on the canvas

calls sub end_stroke(Ev('x'),Ev('y')) to finish recording the stroke

Then it sets up the various parameters for the normalizer, the segmenter and the matcher, and finally calls Tk::MainLoop.

sub start_stroke

Initializes @stroke to the point of ButtonPress, and starts a line ($curline) in the canvas

sub update_stroke

Adds the point to @stroke and to the $curline

sub end_stroke

Adds the last point to @stroke

sub match

After having normalized and segmented the current stroke, calls sub Similarity1::similarity for each @known_strokes, printing scores, and keeping track of the "nearest" (i.e. the one with the lowest score).

At the end, prints the index of the best match.

sub record

Normalizes and segment the current stroke, and pushes it into @known_strokes (adding the first point, since the segments are relative).

sub clear

Just cleans up the canvas.


This code is copyright (C) 2002 Gianni Ceccarelli Released under the GNU LGPL, version 2.1

Last updated: Thu Apr 11 13:46:34 2002