← Back to team overview

sikuli-driver team mailing list archive

[Question #251545]: Match for same pattern in same reason passes then fails

 

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

Has anyone tried successive, identical pattern searches with Region.find() and had the first invocation pass and the next fail?

I am trying to use the Sikuli Java API to write JUnit tests.
Each test builds a simple JFrame GUI which contains a custom web browser component as its only content.  The content pane is sized so that the browser component is 1000x500.  The HTML in the browser does nothing but paint the background red.

A 1000x500 red rectangle is stored in a .png file and used to create a Pattern.
The first time I seek this Pattern in the Region of the application, I get an almost perfect match.
Seeking the same Pattern on the same Region again, however, throws a FindFailed exception.

I am using 64-bit Java 7 update 55 on Windows 7.
I saw this behavior first with Sikuli 1.0.1 (sikuli-ide.jar) and then again with the latest 1.1.0-Beta3 source downloaded from GitHub.

Here is the relevant code:

@Test
public void basicPatternMatch() {
   Pattern p = new Pattern("C:/Users/jcavill/AppData/Local/Temp/jeff270671578108421267.png");
   try {
      Region r = app.getRegion();  // calls Region.create(x, y, w, h)
      printRegion(r);

      Match m = r.find(p);
      printMatch(m);

      m = r.find(p);
      printMatch(m);
   } catch (FindFailed e) {
      System.err.println(e.getMessage());
      junit.org.Assert.fail("Pattern match failed: " + e.getMessage());
   }
}

Here is the console output:
-----------
Region at (300,300) is 1016 x 538
Match found at (309,331) of size 1000 x 500 with score 0.9999250173568726

can not find P(C:/Users/jcavill/AppData/Local/Temp/jeff270671578108421267.png) S: 0.9 in R[300,300 1016x538]@S(0)
-----------

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