← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #700416]: Using OCR text() on a match from Screen.capture()

 

Question #700416 on SikuliX changed:
https://answers.launchpad.net/sikuli/+question/700416

    Status: Open => Answered

RaiMan proposed the following answer:
This worked for me with 2.0.5:

img = "img.png"
reg = Region(0,0,300, 300)
capturedImage = SCREEN.capture(reg) #comment1
f = Finder(capturedImage)
f.findAll(img)
while f.hasNext():
    temp = f.next()
    print "match:", temp
print Image(capturedImage).getSub(temp).text() #comment2

comment1:
this returns the ScreenImage inMemory (does not save to file)
so it can be easily used later to search in

comment 2:
temp is a match in an image, so the match coord are relative to the top left corner of the image - hence (0,0)
so getSub cuts out the pixel area represented by match temp.
The text features work the same as for Region with class Image

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for SikuliX.