nguyenq / tess4j

Java JNA wrapper for Tesseract OCR API
Apache License 2.0
1.58k stars 372 forks source link

"createDocumentsWithResults(...)" fails when "filename" is null #234

Closed Mararsh closed 2 years ago

Mararsh commented 2 years ago

My codes fail to do OCR after upgrade tess4j from v6.4.4 to v6.5.3.

The problem is caused by parameter "filename" of following method: public OCRResult createDocumentsWithResults(BufferedImage bi, String filename, String outputbase, List<ITesseract.RenderedFormat> formats, int pageIteratorLevel) throws TesseractException

Null works for "filename" in v6.4.4 while null does not work in v6.5.3. I am not sure whether this parameter is useful when BufferedImage is the source image.

My workaround is fill value of "filename" as value of "outputbase".

nguyenq commented 2 years ago

The library does not have those versions, so we're unsure of what you are referring to.

The code for that method has not changed. filename inside Tesseract is passed to SetInputName method and is needed only for training and loading a UNLV zone file, according Tesseract documentation. It's also used in tess4j to set the title of the output document when TessResultRendererBeginDocument is called, which seems to be where the exception has occurred.

Mararsh commented 2 years ago

Sorry. I wrote wrong versions. Should be: upgrade from 4.4.0 to 5.3.0