Can ColorImageTarget be used with Sikuli IDE?

Asked by andrew plummer

Hi I was just trying out Sikuli and I needed to match some icons based on the colour, e.g. the icon looks the same but when its green it's active and when red it's inactive (green is valid selection, red is invalid)

I saw the Sikuli API has ColorImageTarget available to use, but my programming ability is pretty limited so the Sikuli IDE has been very helpful for me.

Is there any way to get access to ColorImageTarget and still use Jython? I did have a quick go at setting up Eclipse but it feels a bit beyond my skill level at the moment.

Also as some general feedback, I find the SikuliIDE really easy to use and intuitive. The only hitch I ran into was the OnChange observe event seems to be logged as a bug at the moment. And not being able to match based on color. Other than that this is a really awesome automation tool, even for begginers like me. Cheers

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

What version of SikuliX are you using currently?

--- I saw the Sikuli API has ColorImageTarget available
I guess you are talking about Sikuli Java API at
http://code.google.com/p/sikuli-api

This is to some extent feature compatible, but at the API level and generally a different system/environment.

You have to decide: SikuliX (http://www.sikuli.org/download.html) --OR-- Sikuli Java API (seems not to be developed further though)

Revision history for this message
andrew plummer (andrewplummer) said :
#2

Oh right, it is a different thing. Yes I was confused that Sikuli API and SikuliX were the same thing. I guess I should stick with SikuliX because it has better documentation. I also like the SikuliIDE because it makes scripting very easy for beginners.

I think you are probably aware that an option for similarity based on color is a common suggestion, so +1 to that. And I'm also looking forward to your bug fix for OnChange in next release :) https://bugs.launchpad.net/sikuli/+bug/1212706

I am a software tester and only have very basic programming experience, so far sikuli has been really good and I can see a lot of potential for running some common test cases.

Thanks for the prompt reply RaiMan

Revision history for this message
andrew plummer (andrewplummer) said :
#3

Thanks RaiMan, that solved my question.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

This is currently solvable with SikuliX rather easy too:

lets say, you have the two shots:
button_selected
button_unselected

or
button_color1
button_color2

usually it is needed, to restrict to the region somehow, where you expect the button to appear.

reg = <somehow evaluated region>
if (reg.exists(button_color1):
    if (reg.exists(Pattern(button_color1).exact())):
        print "it is color1"
    else
        print "it is color2"

... so the principal approach is:
- first find the image with a normal similarity >0.7, which might be either of the 2 button versions
- then check with similarity exact, which one it is really.

In many cases, depending on how many similar visuals might be found,this might even work without restricting to a region:
if (exists(button_color1):
    if (getLastMatch().exists(Pattern(button_color1).exact())):
        print "it is color1"
    else
        print "it is color2"

If we find a first match, we check the match region only for the real button.

It should be checked, which version of the button should be used for the first search.