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

    Status: Needs information => Answered

RaiMan proposed the following answer:
I just made a test with the latest 1.1.3 nightly (on Mac ;-)

Settings.UserLogs = True 
Settings.UserLogTime = True

def handler(evt):
  Debug.user("in handler: black appeared")

Debug.user("starting")

basePath = 
"/Users/raimundhocke/IdeaProjects/SikuliX114/API/src/main/resources/ImagesAPI"
setBundlePath(basePath)

App.focus("safari"); wait(2.0); reg = App.focusedWindow();

black = "black_128"
match = reg.exists(black, 10)
if (match): Debug.user("black exists")

match = reg.exists("sikulix2", 10)
if (match): Debug.user("image exists")

reg.onAppear(black, handler)
Debug.user("start observing")
reg.observe(10)

The script shows, that the approach principally works.

My workflow:
- to simulate your video-area-gets-black scenario: the browser window shows an 
animated gif, that shows an image for 5 secs and then the image area as black 
for 5 secs
- we first wait for the black image
- then we wait for the image, to assure, that the observe starts with seeing 
the image
- the we start observe

this is the output:
[user (09/08/2018, 13:50:12)] starting
[log] App.focus:  [0:safari]
[user (09/08/2018, 13:50:15)] black exists
[user (09/08/2018, 13:50:15)] image exists
[user (09/08/2018, 13:50:15)] start observing
[user (09/08/2018, 13:50:18)] in handler: black appeared

It does not matter, wether observing in foreground or in background.

Problems you might be facing:
- the video image might be  too black" and generates false positives - try with 
Pattern().exact()
- timing problems: you should separate the definitions of the observation 
(onAppear) and the start of the observations, to have more control

Be sure to use version 1.1.3 nightly - it has some fixes for
observation.

Be sure to have read the docs: there are some interesting features, that might 
be helpful in your situation
https://sikulix-2014.readthedocs.io/en/latest/region.html#observing-visual-events-in-a-region

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

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to