JS + Canvas and the base implementation of the Viola-Jones face recognition method .
With some kind of manuscript? I think you will get really bad results .
You need to first determine the global horizontal slope . (Once you get the slope , you can get the row height at the same time .)
Create a 100% horizontal mesh runner, for example:
0000000000... 1111111111... 0000000000...
where 0 checks for light and 1 for dark areas . Let it execute the data of your image selection from top to bottom and to all inclinations (i.e. + -15deg max).
A positive match is when your grid (stripes) returns a threshold contrast density corresponding to its raster value. If the runner does not return any match, increase its size and let it start again.
You need to consider errors, so you need to keep all possible positive matches. After you are done with all sizes and inclinations, you simply select the one that led to more matches.

You will now have a general horizontal slope and line height .
Now you need to determine the vertical slope of the letter . At the same time, you can get empty space .
The same technique. You can run the vertical runner one at a time (you know the line height)
0101010 0101010 0101010 0101010 0101010
starting from 0 on the left to the right. Does not match? change degree. Let it run again.
Get a run that collects more matches. You have a penchant for writing.
let him run through the same line of text and collect all the information about the selection between the dark areas.

source share