Open Shreeshrii opened 2 years ago
Using --psm 6
is at least for newspapers (where we also see "empty" pages) not the correct solution. In those cases using a different binarization usually helps.
You are right. --psm 6
will work only if the input is a single line image.
I am finding the issue in about 1% of images generated by tesseract unpack
from lstmf files which were generated by text2image. Shouldn't all these files have same binarization?
Here is a zip file with some images which have this problem. A few ok images are also included.
EmptyPage.zip.zip In most cases it is images with a single word/number in it in a large font size. Hope this helps in isolating the cause.
Empty page!! Empty page!!
Why is this message printed twice?
Does this also happen with --oem 0
?
Yes, it is also happening with --oem 0
.
(base) ubuntu@tesseract-ocr-1:~/TEST$ tesseract eng.Charis_SIL_Italic.exp0_27.png - --oem 0 --tessdata-dir ../tessdata
Empty page!!
Empty page!!
The problem seems to be related to dpi.
(base) ubuntu@tesseract-ocr-1:~/TEST$ tesseract eng.Charis_SIL_Italic.exp0_27.png - --dpi 600
Empty page!!
Empty page!!
(base) ubuntu@tesseract-ocr-1:~/TEST$ tesseract eng.Charis_SIL_Italic.exp0_27.png - --dpi 300
Empty page!!
Empty page!!
(base) ubuntu@tesseract-ocr-1:~/TEST$ tesseract eng.Charis_SIL_Italic.exp0_27.png - --dpi 200
6881
(base) ubuntu@tesseract-ocr-1:~/TEST$ tesseract eng.Charis_SIL_Italic.exp0_27.png - --dpi 250
Empty page!!
Empty page!!
(base) ubuntu@tesseract-ocr-1:~/TEST$ tesseract eng.Charis_SIL_Italic.exp0_27.png - --dpi 150
6881
Image is being recognized if I assign dpi 200 and 150.
I tried to display the earlier messages regarding the dpi being used, but they seem to have been suppressed now , even with --loglevel ALL
.
(base) ubuntu@tesseract-ocr-1:~/TEST$ tesseract eng.Charis_SIL_Italic.exp0_27.png - --loglevel ALL
Empty page!!
Empty page!!
In general, if you know in advance that the input is one line, then you should use --psm 7
.
The dpi in this image is in valid range (301) so tesseract will respect it and will not try to estimate it. That's why there is no warning.
Your suggestion to make Tesseract do a second try can be improved by taking into account image height and number of blobs. For example, If the image height is below 60 pixels and has less than 100 blobs, Tesseract can try psm 6 and if it also fails it can then try psm 7.
Using the API, you can give Tesseract an alternative config file and if recognition fails, Tesseract will do a second try using this config file.
In general, if you know in advance that the input is one line, then you should use --psm 7.
I am trying to look for alternative ways to evaluate the recognition by different models since lstmeval
does not give accurate results. So, I am using the single line images used for training and eval by tesstrain makefile and then using OCR results using ocrevalUAtion and ISRI tools. I could use --psm 7
for it. Would that be considered ok as a basis for evaluation?
I don't know, you can try and see...
Empty page output for complex newspaper pages is handled in issue #3021.
For certain images the default psm gives
Empty Page
as output while--psm 6
and others give the correct result.Suggest that in cases where default psm results in
Empty Page
, try recognizing image with--psm 6
automatically along with a DEBUG message.Example image:![eng Charis_SIL_Italic exp0_27](https://user-images.githubusercontent.com/5095331/144421404-d11c0595-ec1c-4204-919a-6e35969acc14.png)