hasnext() returns true, but unable to find the next match in the finder object

Asked by Srikanth Sayyam on 2018-10-15


I am running the below code in Eclipse(Java) and I have added all the required sikuli jar files.

I am comparing two images and while doing that, hasnext() method returns true and is going inside the loop. But the line Match m = f1.next(); fails/returns null.

How is it possible for next() to return null when hasnext() actually returns true?

Please help me here to resolve this issue.

PS: I am new to sikuli

Pattern pa1 = new Pattern("/Users/sayyam.srikanth/Desktop/bigImage.PNG");
Pattern pa2 = new Pattern("/Users/sayyam.srikanth/Desktop/smallImage.PNG");

    Finder f1=new Finder(pa1.getImage());

          Match m=f1.next();
           System.out.println("Match found with "+(m.getScore() * 100) +"%");


          System.out.println("No Match Found");

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

SikuliX version?

Srikanth Sayyam (sri4raaz) said : #2

Hi RaiMan,

I have added the below Jar files to my library

sikulixlibswin -1.1.1.jar

Thank you,

RaiMan (raimund-hocke) said : #3

--- sikuli-api-1.1.0.jar
... is another project - not sure wether it collides with SikuliX

--- sikulixapi.jar
... should be a fat jar created with setup (1.1.3 ??)

--- sikulixlibswin -1.1.1.jar
... only needed for setup and should not be in a dev library

... only needed for setup and should not be in a dev library

hence only a correctly setup sikulixapi.jar should be in your library.

--- your problem
tested your code with 1.1.3: works as it should

Srikanth Sayyam (sri4raaz) said : #4

Hi RaiMan,

Thank you for the reply.

I am actually new to this and a bit confused.

If I download a sikulixsetup-1.1.3.jar file and run it, Will it take care of everything? Or do I need to do something else?

PS: I have valid Java installation and will add sikulixapi.jar file in my dev library post installation.

RaiMan (raimund-hocke) said : #5

setup option 2 should create a valid sikulixapi.jar on Windows/Mac. On Linux besides Ubuntu there might be needed more.

Check the setup log for errors afterwards.

Can you help with this problem?

Provide an answer of your own, or ask Srikanth Sayyam for more information if necessary.

To post a message you must log in.