[HowTo] get text from an image file

Asked by Ivan

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:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
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")

Revision history for this message
Ivan (rozhkov92) said :
#3

Thanks RaiMan, that solved my question.