[HowTo] get text from an image file

Asked by Ivan on 2019-10-07

After writing some simple tool for reading some data from the screen (create regions based on given coordinates and get some data, including text using OCR) I'm struggling to write some tests.

I've created some screenshots using coordinates that I used for creating regions.
Is there a way I can read text from the image file (someimage.png) the same way I can do it with regions (regions.text())?

So my goal is get text from bunch of image files on my filesystem.

I haven't found that information in docs. If it's already there, could you please share a link? I'm using java. Thanks in advance.

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2019-10-11
Last query:
2019-10-11
Last reply:
2019-10-11
Best RaiMan (raimund-hocke) said : #1

what you are looking for is in class Image:

Image img = Image.create("someImg.png")
text = img.text()

or even
text = Image.text("someImg.png")

Ivan (rozhkov92) said : #3

Thanks RaiMan, that solved my question.