X-1.0rc3: pattern.exact() fails even when a perfect match exists --- workaround

Bug #877450 reported by Jordan Beland
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
SikuliX
Fix Released
Critical
RaiMan

Bug Description

***** workaround

use Pattern.similar(0.99)

--------------------------------------

I am currently using the java Sikuli to verify generated images on the screen, and I need to verify that they are a 100% match (for regression testing). I was using the following code the verify:

Pattern exactMatch = new pattern(pathToMasterImage).exact();
boolean result = screen.exists(exactMatch, someTimeout) != null;

however, on some images, this would fail. I captured screenshots on the failure and compare the pixels and they were an exact match. I also called a search for the same image immediately after using .similar() and gave it a minimum of a 0% match, which returned a match object with a score of 1.0, so there did exist a 100% match on the screen, but the search for the pattern with a .exact() setting seemed to still fail.

Currently running the java portion of sikuli Sikuli-X-1.0rc3 (r905) 32 bit on a win64 system (running 32bit java though) and windows7. Repro for this bug is difficult, but I ran it over a series of images, and roughly 1 in 6 seemed to fail, albeit it was different images that failed (on the same set of images) every time I ran it.

Tags: fkt-pattern
Revision history for this message
RaiMan (raimund-hocke) wrote :

this is a known problem.

use Pattern().similar(0.99) instead.

RaiMan (raimund-hocke)
summary: - pattern.exact() fails even when a perfect match exists
+ X-1.0rc3: pattern.exact() fails even when a perfect match exists ---
+ workaround
description: updated
Revision history for this message
Divdavem (divdavem) wrote :

// Here is a simple Java class for which I always get the issue:

import org.sikuli.script.FindFailed;
import org.sikuli.script.Match;
import org.sikuli.script.Pattern;
import org.sikuli.script.Region;
import org.sikuli.script.Screen;
import org.sikuli.script.ScreenImage;
import org.sikuli.script.UnionScreen;

public class Main {
 public static void main(String[] args) {
  Screen s = new UnionScreen();
  Region r = Region.create(0, 0, 300, 300);
  ScreenImage image = s.capture(r);
  Pattern pattern = new Pattern(image.getImage()).exact();
  // I also have the issue with:
  // Pattern pattern = new Pattern(image.getImage()).similar(0.99F);
  // However, the pattern is found when not specifying any similarity:
  // Pattern pattern = new Pattern(image.getImage());
  try {
   Match result = r.find(pattern);
   System.out
     .println("Capture found with score: " + result.getScore());
  } catch (FindFailed e) {
   System.out
     .println("Issue: the screen capture itself was not found on the screen!");
  }

 }
}

Revision history for this message
Divdavem (divdavem) wrote :

(I am using Sikuli X-1.0rc3 (r905) on Windows XP SP3 (32bits))

Revision history for this message
RaiMan (raimund-hocke) wrote :

--1. use Screen()
UnionScreen() is for internal use only (API not guaranteed!)

use
Screen s = new Screen();

--2. Pattern(bufferedImage)
this does not work in the form Pattern().similar(), since in r905 the contained image is not copied to the new Pattern.
Download the later build r93x and try again (but instead of exact() (it is buggy) use similar(0.99))

RaiMan (raimund-hocke)
Changed in sikuli:
status: New → Fix Committed
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → x1.0
RaiMan (raimund-hocke)
tags: added: fkt-pattern
RaiMan (raimund-hocke)
Changed in sikuli:
importance: Undecided → Critical
RaiMan (raimund-hocke)
Changed in sikuli:
status: Fix Committed → Fix Released
Revision history for this message
Paul Chambre (pchambredh) wrote :

Is this fix effective for exists() or only for wait()/find()?

I'm running SikuliX 1.1.3, and seeing behavior where wait() with an exact() Pattern matches, but exists() fails for the same exact() Pattern. exists() with a similarity of .99, though, does find the match.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.