Page 1 of 1

Update repository images within tests ?

Posted: Tue Apr 22, 2014 2:13 pm
by StephenMag
Hey there,

One of our software packages is imaging based software, in that it allows us to take acquisitions from our cameras and analysis it etc

Im trying to create a test that ensures that while the Camera is in "Video mode" the image is constantly updating. In theory how I would like to do this test is to run for 2 or 3 minutes while in video mode, and every 5-10 seconds to take a screenshot and compare it to the previous one. Is it possible to use Ranorex's image based testing in this way ? Or are there any plans to implement such a feature ? It would be something that would help our testing team greatly.

Thanks

Stephen

Re: Update repository images within tests ?

Posted: Thu Apr 24, 2014 8:46 am
by mzperix
Hi Stephen,

I am not sure about using the image based validation in Ranorex studio is able to do what you need, but you can do this in code with the help of Imaging class: http://www.ranorex.com/Documentation/Ra ... maging.htm

You can make screenshots of elements, and also compare them.

Regards,
Zoltan

Re: Update repository images within tests ?

Posted: Thu Apr 24, 2014 1:49 pm
by dhh
I've done something similar using this usercode:

Code: Select all

using System.Drawing;

public void IsClipPlaying()
        {
        	   	
			//Graphical confirmation of Video Playing
															
				//Capture a bitmap
					Thread.Sleep(50); //give the clip a chance to load
					Bitmap imgA = Imaging.CaptureImage(repo.xxx.VideoWindow); //take a screenshot
					Report.Screenshot(repo.xxx.VideoWindow); 
					
					double Similarity = 1; // set the Similarity to 1 which means images are identical
				
				//if they are the same (indicating there is possible problem with the recording)
					int RetryCount = 0;
					while (Similarity > 0.998) //while frames look the same (problematic) attempt retries (screen comparisons)
					{
						if (RetryCount == 99)
						{					
							break; //quit this while loop after 100 (0-99) match attempts
						}
						
						Report.Info("Comparing screenshots" + ",retry: " + RetryCount.ToString());	
						
						Thread.Sleep(25); //wait before taking another screenshot
						Bitmap imgRetry = Imaging.CaptureImage(repo.xxx.VideoWindow);
						
						Similarity = 1;
						Similarity = Imaging.Compare(imgA,imgRetry);
						RetryCount = RetryCount + 1;						
					}
					//show the last video grab
					Report.Screenshot(repo.xxx.VideoWindow);
					
					//Validate that the images were different
					Validate.IsTrue(Similarity < 0.998,"Does Video show movement?",false);						
			}           
    }

Re: Update repository images within tests ?

Posted: Thu Apr 24, 2014 4:37 pm
by StephenMag
Yeah, I figured it out using the Imaging class, was exactly what I needed.

Thanks