Tesseract - How to extract text from the image for the input coordinates?

7.1k views Asked by At

I need to input image and coordinates. The text present in the input coordinate must be read as output. How to do this using node-tesseract?

2

There are 2 answers

2
Pang Ho Ming On

You need to look into the .hocr file returned from Tesseract(You can google hocr for more info first). The .hocr includes all the bounding box of the text(x, y, width, height, language etc.). Then calculate all boxes locate inside the coordinates you get from input.

Reference: http://gamemath.com/2011/09/detecting-whether-two-boxes-overlap/

Update:

I did some researches for you. Here you are the "best" (most stars) github repo in Javascript you can find on Github

https://github.com/search?utf8=✓&q=tesseract+language%3Ajavascript

and the best one is tesseract.js with over 10000 stars and still having commits recently

https://github.com/naptha/tesseract.js

enter image description here

the part I highlighted is .hocr (tesseract.js named it html)

0
SPlatten On

I know this is an old thread, however I had the same requirement, couldn't find a solution so I've modified the module and posted onto Git:

https://github.com/desmondmorris/node-tesseract/issues/46