← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #227960]: How to make sikuli detect motions within a specific region?

 

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

    Status: Answered => Open

Frank Feng is still having a problem:
Hi RaiMan,

Thanks for the help. What I'm trying to do it open an video using a
certain player and then keep checking if the pixels within that region
kept changing , then I can assume the video was playing. So I'm
wondering if the onChange function can return a status of the current
region it's observing, if nothing changed at all, then I know something
went wrong, say I observe for a certain period of time, and I'm pretty
sure that the video is much longer than that. If the onChange function
gave me a status saying 'nothing changed', then I can raise an exception
from there. I noticed the event.changes will return a match object, so
Can I check if this object is None, then I stop observing and throw an
exception. Here are some codes that I can think of:


def changed(event):
    print "Something changed in ", event.region
    print event.changes
    for ch in event.changes:
        if ch is None:
            event.region.stopObserver()
            raise Exception('the video stops playing')

def main():
    r = GetAppRegion(app_name) #some function that returns an app region
    print r
    if r is None:
        raise Exception('No App region captured')#just double check
    r.onChange(50,changed)

    while True:
        r.observe(Sikuli.FOREVER)
        if r.exists(Sikuli.Pattern(img).similar(0.9),0): #want to check at the end of the video, but it never detects the pics, dont' no why
            print "end of video"
            break
    print "****************************"
    print "test done!!!!!!!!!!!!!!!!!!!" #never gets to this line since the observer cannot be stopped properly?
    print "****************************"


Thanks again!

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.