← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #676840]: Inconsistent behaviour of SIkuli code run

 

Question #676840 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/676840

ONG YI CHONG posted a new comment:
The handler is still not getting executed completely. I have changed my code to this 
def handler(self,event):
        print "Starting Handler",i
        global i
        r = event.getRegion() # get the observing region for this event
        #for ch in event.getChanges():
        #    ch.highlight() # highlight all changes
        #    wait(0.1)
        #for ch in event.getChanges():
        #   ch.highlight() # turn off the highlights
        base_path = "/Users/ongyichong/SikuliX/Scripts/"
        self.hasChanged = True # screenPage has changed
        #path = capture(r,"/Users/ongyichong/SikuliX/Scripts",str(i))
        #i += 1
        wait(2)   # ensure UI elements transition fully before taking screen shot
        found = False
        j = 0
        similar_screenShot = None
        for screenShot in self.screenshot_list:
            print("j :" + str(j))
            print "zzz"
            match = r.exists(screenShot.image_path)
            if (match):
                similar_screenShot = screenShot
                print("match") # each screenshot object stores a path to the image
                found = True                   
                break
            else: 
                print("ignore")
        j += 1
        print("yes:")
        print(found)
        if (similar_screenShot is None):
            print("whY")
            path = capture(r,"/Users/ongyichong/SikuliX/Scripts",str(i))
            self.changedScreenshot = ScreenPage(path,Region(self.start_pixel_region))      # new screen page so pixel region should be a new one
            self.screenshot_list.insert(0,self.changedScreenshot)        # append screenShot to screenshot list
            i += 1
            print(str(i))
        else: # similar screenshot
            self.changedScreenshot = similar_screenShot
        print "Ending handler",i

Sorry its kinda messy but basically my screenShot is an object now.
Handler code still doesnt run to full completion sometimes as well
still.

[debug] Region: observe: starting in R[30,98 259x431]@S(0) for 0.5 seconds
[debug] Observer: resetting observe states for R[30,98 259x431]@S(0)
[debug] Observing: add observer: now running 1 observer(s)
[debug] Observer: update result: Patterns: false
[debug] Observer: update result: Changes: true

[debug] Observer: update result: Patterns: false
[debug] Finder2: makeMat: INT_RGB (259x431)
[debug] Image: BufferedImage: (259, 431)
[debug] Finder2: makeMat: INT_RGB (259x431)
[debug] Observer: changes: 18 in: R[30,98 259x431]@S(0) E:Y, T:3.0
[debug] Observer: running call back
Starting Handler 1
j :0
zzz
[debug] Image: reused: /Users/ongyichong/SikuliX/Scripts/0.png (file:/Users/ongyichong/SikuliX/Scripts/0.png)
[debug] Region: exists: waiting 3.0 secs for /Users/ongyichong/SikuliX/Scripts/0.png to appear in R[30,98 259x431]@S(0)
[debug] Finder2: makeMat: INT_RGB (259x431)
[debug] Finder2: makeMat: 3BYTE_BGR (263x429)
[debug] Finder2: doFind: start (stdDev: 277.3886 mean: 504.141340)
[debug] Observer: update result: Changes: true
[debug] Region: observe: stopped due to timeout in R[30,98 259x431]@S(0) for 0.5 seconds

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