get Region contents

Asked by Eugene S

Hi,

I have to detect a certain alphanumeric string on the screen. However, the built-in OCR feature is too buggy to provide usable results. Hence I have though of a workaround..

I have realized that since I first have to type the alphanumeric string I am trying to detect later, I can just capture whatever I have typed and then use this as a usual image pattern to find on the screen.
My problem here is capturing the region to use it later as a pattern. I have tried using the "capture" function which should return a path of the image where the region was saved, however when I search at a returned path, I can't find the image there.

Is that a bug?
Is there any other way to save region contents?

Thanks!
Eugene

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

img = capture(some_region)

now image is a file in temp storage
# show filename
print img

print some_region.find(img)

should give you a score 1.0 match

... or you might make a pattern if needed:
pat = Pattern(img).similar(.95).targetOffset(x, y)

the above temp images are deleted when the Java process ends (close of IDE or end of scriptrun on command line)

Revision history for this message
Eugene S (shragovich) said :
#2

Thanks RaiMan, that solved my question.