← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #225999]: Precision issues with observe()

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
The change observer is rather critical, particularly with a high scan
rate and depending on the size of the scanned region (yours is rather
large).

For exact behavior I would prefer the following approach:

refImg = capture(dataRegion)
click(refCapture)
start = time.time()
while True:
    lap = time.time()
    if not dataRegion.exists(refImg, 0): continue
    stop = time.time()
    break
print "total:", stop-start, "   last search:", stop-lap

- refImg contains the region content before the click
- start is the time immediately after the click
- we use a loop, to wait for the region to change
- we use exists(img, 0), which does only one search and returns with None (not found) or the match
- currently exists(img, 0) has a minimum latency of the time given by the WaitScanRate (standard 0.333 seconds)
- using Settings.WaitScanRate = 1000 brings this to the minimum of 1 millisecond (less currently not possible)

So in the moment, the regions image can no longer be found in the region
with a similarity of >0.7, the search loop stops.

Using
    if not dataRegion.exists(Pattern(refImg).similar(0.99), 0): continue
will lead to the fact, that the change of "a few pixels" will stop the search.

the time of the last search (should be below 0.5 secs in this case)
might be subtracted from the total, since the "has changed" state is
detected, by taking a screenshot first (which already contains the
change - rather fast) and then compare the image (most part of search
time)

The smaller you can make your dataRegion, the more exact your results
will be.

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