naptha / tesseract.js

Pure Javascript OCR for more than 100 Languages 📖🎉🖥
http://tesseract.projectnaptha.com/
Apache License 2.0
34.09k stars 2.15k forks source link

Font attributes incorrect even when font is properly identified (`is_italic`, `is_serif`, etc.) #907

Open Balearica opened 3 months ago

Balearica commented 3 months ago

The blocks output format includes various font attributes on the word level, including is_italic and is_serif. These do not appear to be functioning properly, and seem to always return false, even when using the Legacy model and when font identification worked correctly.

For example, when running recognition with the Legacy engine on the image below, the font is correctly recognized as an italic/serif font (Times_New_Roman_Italic). However, despite this, the is_italic and is_serif attributes are both false. italic_example_1

If this is an issue with Tesseract.js/Tesseract.js-core we should fix. If it is an issue on the Tesseract side, where the information is always incorrect, these should be removed from our output to avoid confusion (in the next major version).

Note that this is distinct from general accuracy issues with Tesseract font recognition, or the fact that it only runs on Legacy, which are outside of the scope of this repo. This issue is specific to cases where Tesseract correctly identifies the font but is still returning the wrong font attributes.

Balearica commented 2 months ago

Given that the amount of information retrieved for blocks was found to inflate runtime (see #916), I am now planning to simply remove these properties in v6.

Even if this feature worked correctly (in that it accurately reported what Tesseract finds), it would still only be useful in extremely niche circumstances, if ever. Tesseract LSTM (the default) does not perform font detection at all, and Tesseract Legacy performs poorly with font identification, so this information would either be missing or inaccurate even if this bug was fixed.