Need some help with Recognizer and Character classes from wagomu

45 views
Skip to first unread message

Fed Mest

unread,
Dec 18, 2015, 9:54:30 AM12/18/15
to Tegaki Handwriting Recognition Project
Hello everybody,
Could anyone help me understand how to use the Character class in the wagomu API? If I understand correctly, I set up kanji recognition like this

    Recognizer r;
    r.open("/home/fedmest/Documents/wagomu/handwriting-ja.model");

Then I create a Character class (c) and set it up with the points of its vector

    Character c(25, 8);
    c.set_value(1, 20.0);
    c.set_value(2, 21.0);
    c.set_value(3, 22.0);
    c.set_value(4, 23.0);

And finally process it with the recognizer and use the Results object that is returned

    Results *res = r.recognize(&c, 10);
    for (unsigned int i = 0, len = res->get_size(); i < len; ++i) {
        std::cout << i << ": " << res->get_unicode(i) << ", " << res->get_distance(i);
    }

If that is correct, what I am unsure about is what values should be set into the Character instance. I assume it's the coordinates of the points plotted by the handwriting applications, but could anyone give me more details as to how the points should be input - is it a series of x followed by y coordinates, followed by the next point and so on? Is there any order that should be followed? How do we separated stroke points from one another, or is it not necessary to indicate what points belong to what stroke? Also, what is the size of the vector (the one that can be max 4, but usually 2)? What does that indicate?

I'm grateful in advance for any help you can give...

Fed

Mathieu Blondel

unread,
Dec 19, 2015, 8:27:24 PM12/19/15
to tegaki-hwr
Hi,

Unfortunately, the Python and C++ code are not completely independent.
If you want to use wagomu from C++, there are a few things you're going to need to do on your own.

The values fed to the recognizer are called features. You need to pass 4 values per point. Where does a stroke start is ignored (the array is flattened).

The methods which constructs the features is here:
https://github.com/tegaki/tegaki/blob/master/tegaki-engines/tegaki-wagomu/tegakiwagomu.py#L181

And you can see how it's called here:
https://github.com/tegaki/tegaki/blob/master/tegaki-engines/tegaki-wagomu/tegakiwagomu.py#L236

The character is normalized, downsampled then converted to features. Normalization and downsampling are optional but improve accuracy. For features I am using this function:
https://github.com/tegaki/tegaki/blob/master/tegaki-engines/tegaki-wagomu/tegakiwagomu.py#L51

Basically this takes the difference between points. I am padding with two zeros, since there must be 4 values per point.
Instead of the differences, you may also use the (x,y) coordinates directly as features.  Say your coordinates are (x1,y1), (x2,y2),...,etc. Then, you should set the character as follows:
 
c.set_value(1, x1);
c.set_value(2, y1);
c.set_value(3, 0);
c.set_value(4, 0);
c.set_value(5, x2);
c.set_value(6, y2);
c.set_value(7, 0);
c.set_value(8, 0);
...

HTH,
Mathieu


--
You received this message because you are subscribed to the Google Groups "Tegaki Handwriting Recognition Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tegaki-hwr+...@googlegroups.com.
To post to this group, send email to tegak...@googlegroups.com.
Visit this group at https://groups.google.com/group/tegaki-hwr.
For more options, visit https://groups.google.com/d/optout.

Fed Mest

unread,
Dec 20, 2015, 7:22:27 AM12/20/15
to Tegaki Handwriting Recognition Project, mat...@mblondel.org
Thanks Mathieu,

that's exactly the kind of information I was after. I will go through the links you have indicated and if you don't mind I might ask you a question or two about the code, should I have any doubts...

Regards,

Fed
Reply all
Reply to author
Forward
0 new messages