2

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

user578219
  • 597
  • 2
  • 9
  • 32
  • Try https://stackoverflow.com/questions/26894575/intercepting-console-output-which-originated-from-tess4j – nguyenq Nov 13 '17 at 19:54
  • 1
    Thanks. That doesn't suppress this warning, since this is from Leptonica which is used by tesseract. It suppresses other tesseract warnings – user578219 Nov 14 '17 at 02:37

1 Answers1

3

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);
user578219
  • 597
  • 2
  • 9
  • 32