NAME

matching.pl - sample use of gestures engine


USAGE

1.

Start it up

2.

Draw something in the canvas (with button1 down)

3.

Press 'Record'

4.

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

5.

Do 2-4 again some times

6.

Draw something similar to one of the recorded strokes

7.

Press 'Match'

8.

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


DESCRIPTION

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

Look at the following for details on the algorithms themselves:


HOW IT WORKS

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

"Match"

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

"Record"

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

"Clear"

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.


LICENSE

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