Image recognition does not work on remote machine

Ranorex Studio, Spy, Recorder, and Driver.
ElSticky
Posts: 34
Joined: Tue Sep 17, 2013 1:45 pm

Image recognition does not work on remote machine

Post by ElSticky » Thu Dec 12, 2013 1:39 pm

Hi,

I'm experiencing some problems with running my tests on another machine. My tests work perfectly on my own machine. Since there is a control which isn't recognized in a good way by Ranorex I'm using image recognition for this one. I'm not having any issues with this on my own machine but when I try to run the test on our test server it has problems with the image recognition.

It says 'image not found in element'. I don't get why it does not find the image because it works perfect here...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Image recognition does not work on remote machine

Post by Support Team » Fri Dec 13, 2013 11:50 am

Hi Nicholas,

Thank you for your email.
Please make sure that the test machine runs the same screen resolution and color depth. You can also try to decrease the similarity-attribute as shown below in order to increase the range of the image recognition.

public void ImageBasedRecognition()
{

//Defines our repository item which should be found
var item = repo.Explorer.Item;
//Defines the Screenshot of our repository item
Bitmap bmp = (Bitmap)item.Image;
//Right Click the repo item
item.Click(System.Windows.Forms.MouseButtons.Right, bmp);
// You can also search for images that are slightly different to the
// loaded image by specifying the minimum Similarity for a match (95% = 0.95).
item.Click(new Location(bmp, new Imaging.FindOptions(0.95)));
// OR Set the default Similarity value for all following image operation
Imaging.FindOptions.Default.Similarity = 0.95;
item.Click(bmp);

Report.Success("Image found and clicked successfully");
}

The same applies to a recording action. Change the property of the mouse click action as shown below.
image1.jpg
Please let me know, if that solves your issue.

Regards,
Robert
You do not have the required permissions to view the files attached to this post.

ElSticky
Posts: 34
Joined: Tue Sep 17, 2013 1:45 pm

Re: Image recognition does not work on remote machine

Post by ElSticky » Mon Dec 16, 2013 1:13 pm

This was useful for image recording but I'm still having problems when using images for validation. Are there other things to check besides the color depth and screen resolution? Changing the similarity for image validation doesn't seem to be an option (it already missed a change when using 0.99 similarity)

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Image recognition does not work on remote machine

Post by Support Team » Tue Dec 17, 2013 4:46 pm

Hi Nicholas,

Some pictures have a pretty high similarity. So if you compare the pictures even with a very high similarity factor (e.g. 0,99) there might be no failure within the Ranorex Report. Unfortunately there is no other option available as to set a higher similarity factor in order to get a proper result.
Just slightly lower the similarity factor. Which is sometimes a factor of a few digits after the comma.
To find out the exact difference-factor of two picture, please use the Ranorex.Image.Compare()-function.
E.g. :
//Load images
Bitmap bmp1 =  Ranorex.Imaging.Load(@"C:\test.png");
Bitmap bmp2 =  Ranorex.Imaging.Load(@"C:\test1.png");
//Save the difference-factor between two images into double diff
double diff = 1 - Ranorex.Imaging.Compare(bmp1,bmp2);
//Output
Ranorex.Report.Info("difference: " + diff.ToString());
For better understanding of similarity:
Defines (as percentage) how similar the compared images need to be in order to pass the check. The color differences for each pixel is calculated and the mean squared differences are summed up.
Example: Imagine that we compare 10x10 pixel color images. If all pixels have the same color except for one pixel being white (RGB 255,255,255) in picture A and black (RGB 0,0,0) in picture B, then the similarity is 99%.

If all pixels have the same color except for one pixel being black in pic A and one being gray (RGB 128,128,128, i.e. 50% color difference) in pic B, then the similarity is 99,75% (because of the squared error).
Simply speaking, a similarity of 99% is already a quite low similarity if you compare large images and want to find small differences.

Regards,
Robert

Japise
Posts: 5
Joined: Wed Jan 15, 2014 4:13 pm

Re: Image recognition does not work on remote machine

Post by Japise » Tue Feb 04, 2014 2:44 pm

You may try to turn of the ClearType setting in windows if the image you are capturing is containing text, caused some issues for me.