Transferring Sikuli scripts to another machine

    Since Sikuli is fully relying on the visual contents of the screen, even the slightest visual changes can cause it to fail. I will list some of the possibilities that can cause the scripts to fail after transferring them as well as ways to fix the script.

ClearType 

Problem

ClearType is Microsoft's implementation of subpixel rendering technology in rendering text in a font system. ClearType attempts to improve the appearance of text on certain types of computer display screens by sacrificing color fidelity for additional intensity variation.
    Just to give some idea of how enabling ClearType looks like please have a look at the below images:

ClearType is off

Regular text - ClearType is OFF

Firefox Desktop Icon - ClearType is OFF

ClearType is on

Regular text - ClearType is ON
Firefox Desktop Icon - ClearType is ON
    As you can see, there are some subtle visual differences. You might enlarge these screenshots to be able to see the differences better however what is important to understand here, is that you definitely won't get the same similarity score when matching these objects.

Solution

Disable ClearType

    The obvious solution is to just switch the ClearType functionality. This can be done easily by just clicking the check box in the "ClearType Text Tuner window shown below.


Reduce the similarity score

    I will start with saying that generally this is not recommended as it lowers the reliability of Sikuli pattern detection but I will explain this option anyway for the sake of completeness and for those edge scenarios where it might be the only way out.
   
    I have already explained how similarity score works in Debugging Sikuli Scripts ("Match Objects " paragraph). With going too deep into details, similarity score defines a threshold above which the objects are treated as similar. For example let's take the two Firefox Icons from the ClearType section and try to find one of them using the other as a pattern, so if we run a quick test and try to find all Firefox icons:

@Test  
   public void similarityTest() throws FindFailed {  
     String FFClearTypeOff = "ClearTypeFFIconOff.png";  
     Screen s = new Screen(1);  
     Iterator<Match> results = s.findAll(FFClearTypeOff);  
     while (results.hasNext()) {  
       Match currentMatch = results.next();  
       currentMatch.highlight(1);  
     }  
   }  

we will get the following results:
highlight M[-596,356 63x79]@S(S(0)[0,0 1680x1050]) S:1.00 C:-565,395
highlight M[-1268,343 63x79]@S(S(0)[0,0 1680x1050]) S:0.84 C:-1237,382

    What I want you to to pay attention to is the S parameter (Similarity score), which in one case is 1.00 and the other one is 0.84. Which means that the first match is a perfect match and the second one matches only by 84%. The implication of this is that if our similarity score threshold was above 0.84, we wouldn't get the second result at all.

How to set the similarity score:

Java

Settings.MinSimilarity = 0.83;  

Python

MinSimilarity = 0.83  

Smooth screen fonts edges

Problem

    Another issue that you might need to take care of is the "Smooth edges of screen fonts" option available in Performance Options -> Visual Effects menu. The issue here, in regards to visual pattern detection, is quite similar to that of ClearType described before. Below you can see how that looks zoomed in.

Smooth font edges on


Smooth edges ON zoom in 

Smooth font edges off

Smooth edges OFF zoom in 

Solution

    Exactly as in the previous case, the most straightdorward and solution is switch it off and the second (less recommended) option is reduce the similarity score (as already described above).

To switch that functionality off, go to Performance options -> Smooth edges of screen fonts:


and uncheck the "Smooth edges of screen fonts" option. The setting will be applied immediately but sometimes you'll have to just drag you mouse over the text to trigger the change.

Conclusion

    As you might have noticed, both cases described here, are not real issues that prevent Sikuli from working properly. The problem arises when these settings are inconsistent between the machines you are running Sikuli on.

Comments