Version 1 of Handwriting Word Recognizer

Updated 2003-06-12 05:28:53

Handwriting Word Recognizer


http://www.psnw.com/~alcald/sr.jpg


Under Construction


 This a modification of the "Mouse-stroke character recognizer" by Mike Hall

which in turn borrows code from several other sources.

 I am working on a medical records application for doctors. I was intrigued

by handwriting recognition, especially where the application can be trained to read the average physician's human unreadable, but never the less consistent chicken scratch. Illegible handwriting is a big problem in the medical field.

  I was intrigued by the tablet PC's possible impact on the medical field but

was dismayed to find that the HWR that comes with Windows on the tablet PC could not be trained to recognized chicken scratch. It has a large library of data to compare the user's handwriting against, but it must be fairly legible to have acceptable accuracy. I wanted something that could be trained.

  Basically, I added more cells to the mouse stroke recognizer so that it can now

recognize a whole word at a time instead of just one letter. The recoganized words are accumulated into a "sentence" that can be output to the app that calls the program using the Tk send command.

  I have tried this on Linux using an Aiptek  hyperpen tablet and it works 

amazingly well once you get enough samples. It takes about 10 - 15 samples before you get consitent recognition. I have not tested it with a large number of words in it's database. It might get slow or start getting more duplicatons of workds if storing samples of thousands of words.


Alex Caldwell M.D.


 #!/usr/local/bin/wish8.4

 #
 #        Mouse-stroke character recognizer,
 #        major pieces stolen from other sources.
 #        Mike Hall, [email protected], 2000-12-23
 #

 #
 #        mouse stroke collector, from page 484 of
 #        Practical Programming in Tcl/Tk, Third Edition, 2000, Brent Welch
 #


 #  Modified by Alex Caldwell to try to allow recognizing whole words instead of
 #  characters.
 #
 #      I Mainly increased the number of cells to 25 which seems to increase the
 #   accuracy,  but it now takes more training for each word before recognition
 #   gets consistent.
 #
 #     It seems to work surprisingly well, but might  get slow with a
 #   very large collection of words in the ftrs array.
 #
 #     Allow multiple users to have their own features file
 #
 #   Collect the recognized words into "sentence" that can be output
 #   to stdout or to another program - in this case using the Tk send command.
 #
 #     Added some lines to canvas like on school composition paper to help keep your
 #   handwriting more consistent. It works well with a Cirque glidepoint mouse or an
 #   Aiptek hyperpen pointing device.
 #
 #   [email protected] 12/21/2002

 # sets up bindings on the canvas to collect mouse strokes. Could be used on other
 # canvases too.

 proc StrokeInit {w} {
    bind $w <Button-1>          {StrokeBegin        %W %x %y}
    bind $w <B1-Motion>          {Stroke        %W %x %y}
    bind $w <ButtonRelease-1> {StrokeEnd        %W %x %y}
    return
 }

 proc StrokeBegin {w x y} {
    global stroke
    catch {unset stroke}
    # stroke(N) holds the no of points
    set stroke(N) 0
    # stroke(0) holes the coordin. of first point?
    set stroke(0) [list $x $y]
    msg "1 point ..."
    return
 }

 proc Stroke {w x y} {
    global stroke

    # get last point
    set n $stroke(N)
    foreach {ox oy} $stroke($n) {break}

    # filter? abs(dx) + abs(dy) > threshold

    # install latest point
    incr n
    set stroke(N) $n
    set stroke($n) [list $x $y]
    puts "$stroke($n)"
    msg "$n points ..."

    #puts "[lsort [array get stroke]]"

    # draw latest segment
    $w create line $ox $oy $x $y -width 2 -tag segments
    return
 }