Image find failure in centralised image sikuli file

Asked by bgbig

I have designed couple of sikuli scripts as per the flow of test case.

However, there are images which are common to these designed sikuli scripts.

I created one 'image_directory' folder inside my sikuli project to store all those images and call these depending on my test case scripts.I have renamed images for sake of readability.

But what I observe is ,when a image which is common to say two test scripts..the image find failure occurs in the second script.

Although I have made sincere efforts to take optimised images,still i see image find failures at most of these places.

I'm not quite sure to use a python dictionary to store image in the key,value pair fashion.

Is it feasible to use a python dictionary to eliminate image find failure events.?

Thanks

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Eugene S (shragovich) said :
#1

Hi,

That sounds strange and shouldn't be a problem. I use the same shared images repository for all my Sikuli scripts and it works as expected.

Have you defined your images folder correctly? You have to include this setting in every script. For example:
bundlePath = "C:\\SikuliX\\Tests\\patterns"
setBundlePath(bundlePath)

Eugene

Revision history for this message
bgbig (bgbig) said :
#2

Thanks for the quick reply Eugene

Well, I use relative path to the image directory say for example ,If i have to invoke a click function is use something like this :

click(path+'\\ImageDirectory\\click_operatingSystem.png')

where path =os.environ['Sikuli_Scripts']

I have defined environment variable for 'Sikuli_Scripts'

but when i try to utilise the same image for some other sikuli script file like

doubleClick(path+'\\ImageDirectory\\click_operatingSystem.png')

I witness imagefind failure ..however optimised the image be.Can't figure out why

Revision history for this message
Eugene S (shragovich) said :
#3

Once you set the images repository as I showed in my example you won't have to use the path each time. You will be able to use the image file name directly. I would recommend to use this approach as it cleans the code and make it more error proof, even if that's not the core of your specific issue.

Would you try that and see how it goes?
So, for example, you have a file named "pattern.png" in your "C:\SikuliX\Tests\patterns" folder, do something like that:

bundlePath = "C:\\SikuliX\\Tests\\patterns"
setBundlePath(bundlePath)

find("pattern.img").highlight(1)

Revision history for this message
bgbig (bgbig) said :
#4

Hey Eugene,

This approach seem to work fine.
There's however the issue still I'm seeing with an image that I have i in the shared repository .

There's an 'ok_button' which I need to click at two different windows.On first window ,the click on OK button is successful.

However utilising the same OK button at different window results in script failure within the same script.

I'm afraid if I dont get to utilise common images,then the whole purpose of having a shared repository would not be feasible.

There would be a lot of redundancy. I have like 40-50 scripts coming ,with average 80- 90 lines per script.

Can you suggest any other way to get this trough?

Revision history for this message
Eugene S (shragovich) said :
#5

If you have the same image working and then not working for you, that probably means that the images are somehow different. To make sure, take a screen snapshot and zoom into the images as much as you can. Have a closer look at both images. I expect them to be different as this approach should work fine.

Please try that and update.

Revision history for this message
bgbig (bgbig) said :
#6

Ok so I figured out the problem .these two images are slightly different.

There are two Ok buttons in the application.

One is a bit smaller in font size as compared with the other.

however,this is not a visible difference ,I increased the image similarity as well upto 90.

I figured sikuli should be able to oversee this difference easily.

Now I need to take two different snapshot for performing the same operation :(

If there's a forum or anything like that, i can send out the screenshots as well .Pls let me know if that is required and help solve my problem.

Thanks

Revision history for this message
Eugene S (shragovich) said :
#7

Unfortunately, there is no alternative to keeping different versions of patterns, as far as I'm aware.
And you don't want to bring the similarity parameter below 0.9 as it may result in other problems.

Just consider these as 2 different images. I believe there are not many of such pairs that almost similar.

Can you help with this problem?

Provide an answer of your own, or ask bgbig for more information if necessary.

To post a message you must log in.