Page 1 of 1

Ranorex image validation

Posted: Mon Jan 14, 2013 2:46 pm
by Lightning
Hi,

Sorry first post so apologies if I am posting in the wrong area, I have searched the forums and could not find an answer to my question so again apologies if i've missed a previous answer to this question.

Just a small query, I am able to easily validate an image within my AUT but as part of a further test I have used the functionality within to export a copy of this image as a .tif file (this is the only file format available in the AUT).

Opening this file and validating it with Ranorex is proving difficult, with the default windows photo viewer every time the image opens and closes it is identified as a different element by the Ranorex spy, I have tried using paint dot net instead but the Ranorex recorder will not allow validation on the image it doesn't seem capable of reading it correctly with an error of "Validation failed. The element might no longer be available". I was just wondering is there a particular application for viewing image files that people would recommend for use with Ranorex? cheers

Re: Ranorex image validation

Posted: Mon Jan 14, 2013 4:44 pm
by Support Team
Hello,

You could use file-based image validation in order to achieve this.
This dynamic approach allows bitmap images (e.g. bmp, jpeg, tif, png) to validate.

Please take a look at the enclosed example (please use Internet Explorer).
More examples can be found in our User Guide.
Please let me know if you need further information.

Regards,
Markus (T)

Re: Ranorex image validation

Posted: Tue Feb 12, 2013 10:48 am
by mdgairaud
Hello,

Recently I have to use the image comparison and I use this simple method (it's a stripped version from the one I use):

Code: Select all

[...]
CompressedImage miImage = ElementWithTheImage.CaptureCompressedImage();

if (Compare(miImage, 0.99))
{
	Console.WriteLine("match found!!");
	//do something: Click, MoveTo, ...
}
[...]


private bool Compare(Bitmap miImage, double simmilarity)
{
	double result;

	Bitmap bmp = Ranorex.Imaging.Load(imageToCompare); //from file
	result = Ranorex.Imaging.Compare(miImage, bmp);

	Console.WriteLine("Comparison result : " + result);

	if (result > simmilarity)
	{
		return true;
	}
	
	return false;
}

It's very simple:
1. capture in memory the image of the element (I think it's captured in bmp)
2. compare it against one bmp in disk with a tolerance of at least 0.99 (99%)
3. if the comparison result gives a result of 0.99 or better it returns true



hope it helps. :D


regards,
Mateo.