Exporting Box Images

60 views
Skip to first unread message

Zack Cohen

unread,
Oct 30, 2015, 3:10:13 AM10/30/15
to tesseract-ocr
Hi,

I was wondering if anyone knows a way to collect image data from each box.  i.e. where tesseract guesses the character are around each character.  I would like to export each letter as its own image.  Is this possible with the given API?

Quan Nguyen

unread,
Oct 30, 2015, 6:14:29 AM10/30/15
to tesseract-ocr
You can GetComponentImages to return the coordinates of the bounding boxes.

https://code.google.com/p/tesseract-ocr/wiki/APIExample

Zack Cohen

unread,
Oct 30, 2015, 11:39:17 AM10/30/15
to tesseract-ocr
Thanks!

And then I assume I would use something like magick++ (which I am having a suprisingly hard time getting to work on mac) to crop the images

Helmut Wollmersdorfer

unread,
Oct 30, 2015, 12:21:43 PM10/30/15
to tesseract-ocr

Hi,

Am Freitag, 30. Oktober 2015 16:39:17 UTC+1 schrieb Zack Cohen:
Thanks!

You can get it just from the console API at nearly no additional runtime:

$ tesseract page_152.png page_152 -l deu-frak+deu  makebox hocr

This will output three files: page_152.txt, page_152.hocr and page_152.box.

With the data in the box-file you can cut out the areas from the image.

And then I assume I would use something like magick++ (which I am having a suprisingly hard time getting to work on mac) to crop the images

Exactly. And on a mac you should use homebrew to install magick.
 
HTH

Helmut Wollmersdorfer
Reply all
Reply to author
Forward
0 new messages