Search code examples
javaocrtesseractsuppress-warningstess4j

Suppress Warning on Console when using Tess4j for OCRing


Help in Suppress Warning- "Warning. Invalid resolution 1 dpi. Using 70 instead." when using Tess4j for OCRing

Hi All, I would like to suppress the warning thrown out in Console when using Tess4j for OCRing. Please help.

Tesseract uses Leptonica for some image processing internally and Leptonica thows this on console.

TIA


Solution

  • A Workaround: Not from Leptonica(lept4j) but from Tesseract(tess4j) way. Setting the Resolution if the resolution of the image if it is less than 70.

        TessAPI1.TessBaseAPISetImage2(handle, pix);
        //To remove the warning message "Warning. Invalid resolution 1 dpi. Using 70 instead." Setting the resolution
        int  res = TessAPI1.TessBaseAPIGetSourceYResolution(handle);
        if (res < 70) 
            TessAPI1.TessBaseAPISetSourceResolution(handle, 70);