← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #242881]: How to differentiate 2 similar images based on color???

 

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

RaiMan proposed the following answer:
lets say you have 2 buttons (btn1 and btn2) then the following workflow
will lead to the right Pattern setup:

#take the 2 btn shots:
imgBtn1 = "<shot of btn1>
imgBtn2 = "<shot of btn2>
print "btn1 in around btn1", selectRegion().find(imgBtn1) # select a region around btn1
print "btn1 in around btn2", selectRegion().find(imgBtn1) # select a region around btn2
print "btn2 in around btn1", selectRegion().find(imgBtn2) # select a region around btn1
print "btn2 in around btn2", selectRegion().find(imgBtn2) # select a region around btn2

take care, that the selected regions are larger than the buttons on all
sides.

This will give you the similarity scores of all 4 possible situations.
Now you can decide about the threshold similarity to use with the pattern.

click(Pattern(imgBtn1).similar(0.95)) # 0.95 is an example

Generally it is always a possibility with version 1.0.1+ (RC3 has a bug here) to try with
click(Pattern(imgBtn1).exact())
but this approach needs "optimal" image shots: as little background as possible, concentrate on the key visual aspects of the image (for buttons this usually is a shot, that contains not more than the button's frame).

And even more general: Use the IDE's Preview, to find out the similarity
threshold.

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