← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #268160]: Failed to find image pattern using Finder

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
just made some tests with latest nightly:

print "***** starting testFinder"
Debug.off()
bs = App("Safari")
bs.focus(); wait(1)
img = capture(selectRegion()) # the base image

def compare(base, target):
  f = Finder(base)
  f.find(target)
  if f.hasNext():
    print "** found", f.next()
  else:
    print "** notFound"

print "*** should be found (same image)"
compare(img, img)

print "*** should be found (contained image)"
icon = capture(selectRegion()) # capture an image inside the base image
compare(img, icon)

print "*** should not be found (different image, same size)"
mIcon = find(icon)
icon2 = capture(mIcon.right(100).right(mIcon.w)) # capture an image with same size
compare(icon, icon2)

print "*** should not be found (same image, different size)"
mIcon = find(icon)
icon2 = capture(mIcon.grow(10)) # make image larger than base
compare(icon, icon2)

produces the following output:
***** starting testFinder
*** should be found (same image)
** found M[0,0 718x198]@S(S(0)[0,0 1920x1200]) S:1,00 C:359,99 [-1 msec]
*** should be found (contained image)
** found M[27,16 92x97]@S(S(0)[0,0 1920x1200]) S:1,00 C:73,64 [-1 msec]
*** should not be found (different image, same size)
** notFound
*** should not be found (same image, different size)
** notFound

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