← Back to team overview

sikuli-driver team mailing list archive

[Question #241198]: how to get exact or similar match to work; need help

 

New question #241198 on Sikuli:
https://answers.launchpad.net/sikuli/+question/241198

I have read answers associated with matching but still don't know how to resolve my issue. I have to be able to compare diagrams from one build to another. So I am capturing the image of the entire diagram.

Using the same build
I run the sikiuli ide (runIDE.cmd) and then doing a find of the diagram image.
 I save the image.
I run the application and compare it to the saved image.
If I using match as in A below, it successfully compares the image
However, if I use a match as in B below, it returns null.

A. With Match processModel = screen.exists(PDScreenshot);  The image is successfully compared.

B. Match processModel = screen.exists(PDScreenshot.similar((float)0.95));  OR
Match processModel = screen.exists(PDScreenshot.exact());
The comparison fails (null is returned).

How can I get  exact or similar to work? I would like to do a similar of 95% or greater. Do I have to capture the original image with a fine granularity and if so, how do I do that?  Any help will be appreciated.  Code for image compare is below.  I am also including the stack trace.


Here is the code I am using for the image compare
public static boolean compareProcessModelRendering(String process, String screenshot) throws FindFailed {
		try {
			// Window is already opened by WebDriver
			//Create and initialize an instance of Screen object 
			logger.info("in compare procedure " );
			Debug.setDebugLevel(3);
			Screen screen = new Screen();
			//add image path
			Pattern PDScreenshot = new Pattern(screenshot);	
			//wait 10 ms for image
			screen.wait(PDScreenshot, 30);
			//match process model display image; do an exact match
			logger.info("doing match of process rendering for: " + process );
			Match processModel = screen.exists(PDScreenshot.exact());//this does not match
		//Match processModel = screen.exists(PDScreenshot);//this works
		//	Match processModel = screen.exists(PDScreenshot.similar((float)0.95));//does not match
			
			//highlight image
			processModel.highlight(3);
			if (processModel != null){
				logger.info("Process model display of " + process +" matches");
			}//end if
					
		}//end try
		catch (FindFailed e) {
			logger.info("Error in verifying process model display of " + process);
			Debug.error(e.getMessage());
			for (StackTraceElement ste: e.getStackTrace()) {
	                logger.info(ste);
				}
			return false;
		}//end catch
		
		catch (Exception ex) {
			logger.info("Unexpected error in image recognition; look at the testsuite output for more details " + process);
			Debug.error(ex.getMessage());
			for (StackTraceElement ste: ex.getStackTrace()) {
	                logger.info(ste);
				}
			return false;
		}//end catch


Stack trace from executing


INFO  ImageRecognition [compareProcessModelRendering] - in compare procedure 
[debug] Screen: initScreens: basic initialization (1 Screen(s) found)
[debug] *** monitor configuration (primary: 0) ***
[debug] Screen 0: S(0)[0,0 1600x900]
[debug] *** end monitor configuration ***
[debug] waiting for P(C:\workspaces\testws\BAMSelenium\src\test\img\processes\PEBVT_Base_Executed_Process_Images\ANDCondition.png) S: 0.7 to appear
[debug] Screen.capture: java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] ResourceLoaderBasic: SikuliX Package Build: 1.0.1 12SEP2013135849
[debug] ResourceLoaderBasic: check: we are running on arch: amd64
[debug] ResourceLoaderBasic: check: using Java at: C:/Program Files/Java/jdk1.7.0_45/jre/
[debug] ResourceLoaderBasic: check: Exists libs folder at location of jar? YES: C:/SikuliX-Java/
[debug] ResourceLoaderBasic: checkLibsDir: C:/SikuliX-Java/libs
[debug] ResourceLoaderBasic: loadLib: WinUtil
[debug] ResourceLoaderBasic: loadLib: Found: WinUtil
[debug] ResourceLoaderBasic: loadLib: Now loaded: WinUtil
[debug] ResourceLoaderBasic: checkLibsDir: Using libs at: C:\SikuliX-Java\libs
[debug] ResourceLoaderBasic: check: Using this as OCR directory (tessdata) too
[debug] ResourceLoaderBasic: loadLib: VisionProxy
[debug] ResourceLoaderBasic: loadLib: Found: VisionProxy
[debug] ResourceLoaderBasic: loadLib: Now loaded: VisionProxy
[debug] Screen.capture: java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] Screen.capture: java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] Screen.capture: java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] P(C:\workspaces\testws\BAMSelenium\src\test\img\processes\PEBVT_Base_Executed_Process_Images\ANDCondition.png) S: 0.7 has appeared.
INFO  ImageRecognition [compareProcessModelRendering] - doing match of process rendering for: ANDCondition
[debug] Screen.capture: java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] Screen.capture: java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] Screen.capture: java.awt.Rectangle[x=0,y=0,width=1600,height=900]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=0,y=0,width=1600,height=900]
INFO  ImageRecognition [compareProcessModelRendering] - Unexpected error in image recognition; look at the testsuite output for more details ANDCondition
[error] null

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.