openpaperwork / pyocr

A Python wrapper for Tesseract and Cuneiform -- Moved to Gnome's Gitlab
https://gitlab.gnome.org/World/OpenPaperwork/pyocr
930 stars 152 forks source link

Tesseract segmentation mode with custom zone? #59

Closed K-Niu closed 7 years ago

K-Niu commented 7 years ago

Hi, I have been using builders.WordBoxBuilder to get the positions of some words of interest in an image.

Is there functionality to run Tesseract in segmentation mode with inputted zones of interest?

I took a look at your builders.TextBuilder code and saw that I could change the tesseract_layout parameter in the constructor to change segmentation modes. However, some of the modes need an .uzn file that must share the name of the image being processed by Tesseract. The problem is, I can't get the name of the image file because you write to a random temp file in your tesseract.image_to_string code.

Just wondering if there was a straightforward way currently.

Thanks.

jflesch commented 7 years ago

Is there functionality to run Tesseract in segmentation mode with inputted zones of interest?

Currently, no.

I'm just wondering, if you already know the zones of interest, wouldn't it be easier to simply cut the image in many smaller ones (Pillow can do that easily) and run Tesseract on each of the smaller images ?

K-Niu commented 7 years ago

I'll try that, thanks for the suggestion.

jflesch commented 7 years ago

Unless someone has a specific use case where Pillow can't cut it, I'm closing this ticket.