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?
Gain hands-on experience using Tesseract to OCR an image. Learn how to import the pytesseract package into your Python scripts. Use OpenCV to load an input image from disk. Pass the image into the Tesseract OCR engine via the pytesseract library.
The --oem argument, or OCR Engine Mode, controls the type of algorithm used by Tesseract. The --psm controls the automatic Page Segmentation Mode used by Tesseract.
Tesseract attempts to apply automatic page segmentation methods, but due to the fact that there is no actual “page” of text, the default --psm 3 fails and returns an empty string. We can resolve the matter by treating the input image as a single character via --psm 10 : $ tesseract number.png stdout --psm 10 2.
tessedit_write_images
is checked only once in Tesseract's source code (by TessBaseAPI::ProcessPage()
, see here).
So you have two ways:
api.GetThresholdedImage()
, and the returned image is what will be saved if you set the variable and call ProcessPage
.api.ProcessPage()
, and it will see the variable and output the tif. If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With