Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract text from screen in python

Tags:

python

screen

Is there a library etc for extracting text from a png bitmap screen shot?

It is for a automizer and would (for example) be able to read buttons etc. I've checked Tesseract, but it seems to be made for pictures, not computer screen fonts.

like image 604
Vilhelm Avatar asked Nov 04 '22 11:11

Vilhelm


1 Answers

If you're dealing with a small amount of possible matches (i.e.: you want to recognize two or three different buttons), the simplest way is to isolate those in a previous screenshot, save them to individual files, and then use some form of template matching, which is quite easy in opencv.

If, however, you need to actually perform recognition of the button text, you're going to need a OCR engine. Tesseract is a good candidate, if you can get it trained for your font (it's a lengthy process). As you mention, you'll need to do this if you're dealing with a small font, which tesseract is not originally trained to recognize. If you can't, there's a couple other engines usable in python around, like Ocropus

like image 116
loopbackbee Avatar answered Nov 09 '22 08:11

loopbackbee