25

What would you recommend for recognizing all characters from a screenshot? The screenshot is perfectly clear (only black text on a white background), also I can choose any standard font for the text (installed on Windows). I have tried some OCR ways (Tesseract and such), but it made mistakes in recognizing some characters (that baffled me, as the text is without slightest noise, and the fonts were some most common ones - Courier New, Fixedsys etc.), and I need it to be 100% accurate. Is there some library available for this specific purpose, some pattern recognition or something? or should I get the screenshot with some monospaced font, and iterate through the image moving to the right +font_size pixels and then comparing captured thing to in-memory representation of letters and number of same font in the same size? What would be the best approach to this problem? Thank you very much in advance.

UPDATE: I've finally managed to get 100% accuracy by training Tesseract with monospaced font (Courier New) in exact size that I'm screenshotting. Hope that helps someone in the future :)

Zoran Jankov
  • 236
  • 2
  • 5
  • 18
Tomek
  • 251
  • 1
  • 3
  • 4

5 Answers5

15

Since this is the first result on Google for tesseract recognize screenshot, let me do bit of necromancy and add a much simpler solution.

Tesseract expects images at around 300 dpi or more and standard dpi for Windows is 96. Which means you need to rescale the image to 300%. After that, the results improve dramatically.

100%
1x scale
Result: Whal would you recommend for recognizing all characters from a screensnor 7

200%
2x scale
Result: What would you recommend for recognizing all chamcters from a screenth ?

300%
3x scale
Result: What would you recommend for recognizing all characters from a screenshot ?

Anything above 300% works just as well.

blade
  • 12,057
  • 7
  • 37
  • 38
  • 2
    I was surprised just how well this worked. Most of the screenshots that I was grabbing were indeed low res, and when blowing them up to 300 *ppi* in Photoshop, or ensuring that the dimensions were much larger (around 4000px on the smallest dimension) accuracy shot up. Kudos. Another trick I used was to limit the character whitelist to common letters (`tessedit_char_whitelist 0123456789-.()qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM`) – Joshua Aug 20 '16 at 18:38
  • here's an [answer](https://stackoverflow.com/a/2983295/3380951) on how to use `tessedit_char_whitelist` – XoXo Aug 28 '18 at 11:48
  • some other tricks for image preprocessing: https://www.howtoforge.com/tutorial/tesseract-ocr-installation-and-usage-on-ubuntu-16-04/ – XoXo Aug 28 '18 at 12:02
  • May I ask you to have a look at a Tesseract related question here : https://stackoverflow.com/questions/66946835/improving-accuracy-in-python-tesseract-ocr ? – Istiaque Ahmed Apr 05 '21 at 17:10
1

I would be surprised if OCR would give so bad results on such a good quality input. Probably what you want to do is choose a font that has sharp edges, no anti-aliasing, bigger font size would also help.

Also, if acceptable, try the OCR font given in this SO question:

This should give you the best possible results - if this doesn't go 100%, then I don't know what will...

Don't know what you tried beside Tesseract, but if you did not, it might be worth trying some others. These seem to be updated recently (Tesseract was updated a year ago):

There are some online versions, too, such as:

that you can use to test a sample document. From this link:

it seems that you might need to go commercial to get what you want.

Hope this helps.

Community
  • 1
  • 1
icyrock.com
  • 27,952
  • 4
  • 66
  • 85
  • For anyone reading this, I got really good results (basically 100%, if you don't consider the = messed up by ≡) using GOCR to recognize a block of text written in [FreeMono](https://www.fontspace.com/gnu-freefont/freemono), font size 12 and image saved at 300dpi. – araraonline Jan 24 '20 at 00:08
1

I know you already solved your problem, but in case this helps someone else: Two issues I found when dealing with screenshots is that OCR engines are sensitive to the following: (1) resolution incorrectly set in image file headers, and (2) transparency issues (what looks like white background is actually marked transparent). For some reason these problems tend to occur often in screenshot images.

Also, aside from Tesseract, another possibility is to try the API at http://www.wisetrend.com/wisetrend_ocr_cloud.shtml based on the ABBYY OCR engine. (The advantage is that there's nothing to install/configure/etc to try it to make sure it will work on your images - just make an HTTP POST). Disclaimer: WiseTrend is my company's customer.

Eugene Osovetsky
  • 6,443
  • 2
  • 38
  • 59
  • 2
    The link is dead. I tried the Abby engine. Abby is very expensive. And the results are BAD! – Elmue Sep 25 '17 at 20:05
  • May I ask you to have a look at a Tesseract related question here : https://stackoverflow.com/questions/66946835/improving-accuracy-in-python-tesseract-ocr ? – Istiaque Ahmed Apr 05 '21 at 17:11
0

Do you have the option to change text anti-aliasing on the OS level? Playing around with those settings (or even trying to turn it off) might give you better result with existing OCRs too.

dain
  • 6,475
  • 1
  • 38
  • 47
  • I have turned off font smoothing in Windows. As I said the text in screenshot is perfectly sharp in black&white. Tesseract was something like 98% accurate, but I really need 100% here. – Tomek Nov 17 '10 at 21:42
  • @Tomek I am working on a task with Tesseract. I also need 100% accuracy. But so far not. – smwikipedia May 12 '15 at 13:53
0

You can use Abby Fine Reader 12.0 for text extraction from PDF's and or Screenshot Images and directly save them into your desired file format.

See through: Abby Fine Reader 15 - Free Trial

Deepak J
  • 184
  • 1
  • 7