how do i get a region based of image file?

Asked by fawwaziqbal

I couldnt find a way to get region from a image file, since i want to .findText on the image

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said (last edit ):
#1

SikuliX performs actions on the visible screen. If that image is shown on the screen, then you can use Sikulix to act on its region.
If you have an image not visible on the screen, but stored only on disk, and want to search for text in it, then Sikulix is not the right tool for that. You can use OCR programs like tesseract to do that directly. They usually work directly on image files.

(In SIkuliX the following sequence of steps should theoretically work: Start an image viewer program, load the image file such that it is shown on screen, use SikuliX to do findText on the image.)

Or did I misunderstand your question?

Revision history for this message
RaiMan (raimund-hocke) said (last edit ):
#2

Use SikuliX 2.0.5 and this should work (scripting):

img = Image.create(".../someImg.png") # load the base image

# optionally create sub images
imgReg = img.getSub(Region(x, y, w, h)) # x, y relative to 0 (top-left)

# read text content
imgReg.text() # will read the text as with screen regions

More info about the text OCR features in the docs.

Can you help with this problem?

Provide an answer of your own, or ask fawwaziqbal for more information if necessary.

To post a message you must log in.