← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #169664]: picture cross refencing: find an image in many others

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- sys.argv contains the values that are given to the script call from command line 
(see: http://sikuli.org/docx/faq/010-command-line.html)
this does not work in the IDE

But this does not help much in your situation: you would have to call
this script from command line for every couple of images, which costs
you about 3-5 seconds startup time each.

--- same images
if you have an image and use:

f = Finder("some-image.png")
f.find("some-image.png")
m = f.next()

then m will always be a match of similarity 1.0 (identical)

--- my quick and dirty solution again

# to get the find code out of way
def compareImage(probe, base):
    found = False
    f = Finder(base)
    f.find(probe)
    if f.hasNext(): found =True
    f.destroy()
    return found

import os
dir = "absolute-path-to-your-folder-containing-the-images"
files = os.listdir(dir)
probe = "cool.png"
for f in files:
    image = os.path.join(dir, f)
    if compareImage(probe, image): break
    image = "none of them"
print "found in", image

So you should have at least a try first with this workflow, before
making things more sophisticated.

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