← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #200281]: screenshot compare in java

 

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

RaiMan posted a new comment:
@ j-the-k

Uuups, some one who knows about good old (nearly useless ;-) Vdict ;-)
you missed to put the img2 into dict:

dict = VDict()
img1 = capture()
dict[img1] = True
wait(10)
img2 = capture()
dict[img2] = True
hasChanged = dict[img2] != dict[img1]

But this will not work, since finally you compare True != True, which
always will give false.

This should work:

dict = VDict()
img1 = capture()
dict[img1] = True
wait(10)
img2 = capture()
if not dict.get(img2, 0.99): print "images differ"
else: print "images equal"

But since inside Vdict just a Finder is used on the keys of a
dictionary-like collection, you can use the Finder directly.

Supposing, both screenshots have the same size:

img1 = capture()
img2 = capture()
f = Finder(img1)
if not f.find(Pattern(img2).similar(0.99)).hasNext(): print "images differ"
else: print "images equal"

This could be used in Java nearly 1:1

BTW: VDict is no longer in the documents and not improved since Sikuli 0.9 (some substantial dictionary features are not implemented).
... and the API on the Python and Java level are totally different.

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