9

I'm trying to set tessedit_write_images but can't seem to do it, i can't see the tessinput.tif anywhere

i'm doing:

import tesseract

api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_TESSERACT_ONLY)
api.SetPageSegMode(tesseract.PSM_AUTO_OSD)
api.SetVariable("tessedit_write_images", "T")

but i've tried with "True", "1", and some more variations, doesn't seem to work at all.

Any help?

tiagosilva
  • 1,695
  • 17
  • 31

1 Answers1

2

tessedit_write_images is checked only once in Tesseract's source code (by TessBaseAPI::ProcessPage(), see here).

So you have two ways:

  1. Call api.GetThresholdedImage(), and the returned image is what will be saved if you set the variable and call ProcessPage.
  2. Just call api.ProcessPage(), and it will see the variable and output the tif.
ch271828n
  • 15,854
  • 5
  • 53
  • 88
cortex42
  • 234
  • 1
  • 13
  • 1
    How do I set these parameters via mac terminal? I have downloaded Tesseract and am using it via command line, so when you say "you should call such and such method" I am not sure what you mean. How do I do that? –  Jul 09 '17 at 12:26
  • The important thing is that because of this hardcoded path "tessinput.tif" the tif file will be written to your **working directory** not regarding the `outputbase` command line option. – Pavel K Sep 27 '19 at 11:12