ocrhandwritingdigital-handwritting

How to convert image of handwriting into pen coordinates?


I have a image with binary values (black and white) at each pixel. I want to convert this into an ordered list of pen coordinates (X,Y) which traces the path of the pen. I want to do this so that I can use an API which only takes pen coordinates as an input.

Is there any library or straightforward way to do this? Thanks!


Solution

  • This question https://graphicdesign.stackexchange.com/questions/25165/how-can-i-convert-a-jpg-signature-into-strokes describes using a vector graphic convertor to do this. It suggests first converting the pixels to binary values, and then using the autotrace tool.

    autotrace -centerline -color-count 2 -output-file output.svg -output-format SVG input.png 
    

    I'm not sure what the best way to get SVG files into (X,Y) coordinates is, you can do a rough job by parsing the XML directly.

    Another approach could be to look through the submissions in the Kaggle competition for this same problem: https://www.kaggle.com/c/icdar2013-stroke-recovery-from-offline-data . I haven't looked into these myself, though I imagine they'd result in better performance.