← Back to team overview

sikuli-driver team mailing list archive

[Question #675303]: Sikuli - Image Scaling and Comparison Issue

 

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

Hi RaiMan,

Firstly, really appreciate your work and dedication.

I am new to Sikuli. I have had numerous problems in working with Sikuli but I was able to fix most issues by referring to threads on this forum.

I have a problem that I am unable to fix now and need your expert advise.

I am developing a project using Sikuli and Java at work. I work at Dell. We need to basically install and test drivers for new Dell machines and I am automating this procedure.

for any file during installation, we have a sequential set of buttons - Install -> Next (can appear multiple times during UI) -> Finish -> Close, in this same order. We have taken the images of these buttons and passed it to an array and it will compare each screenshot within the said region and perform the click.

The script works fine when I use it on the developing system. However, when I make a runnable Jar and test it on another machine, it does not find the image. After much research, it seems to be due to scaling issue - the resolution on each machine would or might be different and sikuli does not find that image. If I take a screenshot on the testing system with current resolution it works fine. We need to generalize this to work on any machine with any resolution.

I have tried with and without pattern search, with 50-90% similarity as well, it still does not work.

I have changed the resolution of the screen and tested with the generic screenshots and it still does not work.

I have also tried using Maven project and it still is the same issue, works on dev system, does not find image on testing system.

Tools used - Eclipse Photon, Sikuli x V1.1 - 1.4 (tried each version), Java 8+, JRE 1.8 and above

If you are testing a driver to install or reproduce this below issue and code - you can use this link and download the driver.

https://www.dell.com/support/home/us/en/04/drivers/driversdetails?driverid=h8m3c 

*********************************************
Code as below:
********************************************

public static void main(String[] args) throws FileNotFoundException, IOException, InterruptedException, FindFailed {
		// TODO Auto-generated method stub
		
		String installtest = "C:\\1234567\\TEST.EXE";
		String dupls = "C:\\1234567\\genimages\\D6.PNG";
		
		Screen sc = new Screen();
		
		ArrayList<Image> myArr = new ArrayList<Image>();          
        File dir=new File("C:\\1234567\\genimages\\");
        int fileCount=dir.list().length;
        System.out.println("File Count:"+fileCount);
        File[] flist = dir.listFiles();
        
        List <String> onelist = new ArrayList<String>();
        
        for (int i = 0; i < fileCount; i++) 
        {
                       String fin=flist[i].toString();
                       onelist.add(fin);
                       myArr.add(ImageIO.read(new FileInputStream(("C:\\1234567\\genimages\\D"+i+".PNG"))));
                       System.out.println(fin);
        }
        System.out.println("size of myArr: "+myArr.size());
        
        System.out.println("One List Array: "+onelist);
       
        ProcessBuilder pb = new ProcessBuilder(installtest);
		pb.start();
		System.out.println("Initiating File Installation");
		Thread.sleep(3000); 
		
		Region appRegion;
		
		Loop:
			  while(true)
			  {

				  Thread.sleep(5000);
				  appRegion = App.focusedWindow();
				  
				 int i=0;
		        for(String s: onelist)
		        
		        {
		        	Pattern p = new Pattern(s).similar(0.7f);
		        		        	
		        	System.out.println("Checking Image: s["+ i +"]");
		        	if(appRegion.exists(p) != null)
		        	
		        	{
		        		System.out.println("Image Found at Location: s["+ i +"]");
		        		sc.click(p);
		        		Thread.sleep(2000);
		        		System.out.println("Removed Element from Array: "+s);
		        		onelist.remove(i);
		        		break;
		        	}
		        	
		        	else
		        	{
		        		System.out.println("Moving to next image: s["+ ++i +"]");//do nothing
		        	}
		        }
	
	System.out.println("Updated One List Array: "+onelist);    
	
		   if(appRegion.exists(dupls) != null)
		   {
			   System.out.println("Close Image Found");
			   sc.click(dupls);
			   Thread.sleep(3000);
			   break Loop;
		   }
		   
		   else
		   {
			   continue;
		   }
		        
		        
			 }
		        		
		  
	System.out.println("End of Script");	

	}



-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.