Find an image in an other image

Asked by ruben

Is it possible to use sikuli to find an image within an image instead of using a screen region?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
ruben
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1
Revision history for this message
ruben (rubenmoritz) said :
#2

Ok that I do understand however i used to do a detection on the screen using regions like this:

region reg=new region(...);
Match found=region.find(img);

what i would like to do is:
Finder finder = new Finder(image);
Match found=finder.find(img);

However netbeans IDE gives me the suggestion that Finder.find() returns a String and not a Match what is going wrong?

Revision history for this message
RaiMan (raimund-hocke) said :
#3

I have to admit, that the docs are not very consistent, but at least this is clear:

The workflow always is:
- setup a Finder
- do a find or findAll operation
- check with hasNext(), wether anything was found at all
- get the available matches with next() if hasNext() says more available
- After a complete iteration, the finder object is empty.
- You can start a new find or findAll operation at any time.

so in your case:

Finder finder = new Finder(image);
finder.find(img); # the return value is not relevant (if null, then the image could not be loaded)
// the find operation and the collection of matches itself is an internal side-effect
if (finder.hasNext()) {
  Match found = finder.next();
} else {
  // not found
}

Revision history for this message
ruben (rubenmoritz) said :
#4

Thanks i figured it out