protected int[] addImageFacts(Image img, Rectangle r, double score) { int[] facts = new int[5]; facts[0] = r.x; facts[1] = r.y; facts[2] = r.width; facts[3] = r.height; facts[4] = (int) (score*100); images.put(img.getName(), facts); return facts; }
/** * check whether image is available for Finder.find()<br> * This is for backward compatibility<br> * The new ImageFinder uses isUsable() * * @return true if lodable from file or is an in memory image */ public boolean isValid() { return fileURL != null || getName().contains(isBImg); }
@Override public String toString() { String ret = "P(" + image.getName() + (isValid() ? "" : " -- not valid!") + ")"; ret += " S: " + similarity; if (offset.x != 0 || offset.y != 0) { ret += " T: " + offset.x + "," + offset.y; } return ret; } }
protected static void set(Image img) { URL fURL = null; File imgFile = new File(img.getName()); if (imgFile.isAbsolute()) { if (imgFile.exists()) { fURL = FileManager.makeURL(img.getName()); } } else { fURL = imageNames.get(img.getName()); if (fURL == null) { fURL = ImagePath.find(img.getName()); } } if (fURL != null) { img.init(img.getName(), fURL, true); } }
public static String createdefault(Region reg, Image img) { String msg = ""; if (img.isText()) { msg = String.format("%s as text", img.getName()); } else if (img.getSize().width < 0 && img.getSize().height < 0) { msg = String.format("%s not loaded", img.getName()); } else { msg = String.format("%s in %s", img, reg); } return msg; }
private static Image createImageValidate(Image img, boolean verbose) { if (img == null) { log(-1, "Image not valid, creating empty Image"); return new Image("", null); } if (!img.isValid()) { if (Settings.OcrTextSearch) { img.setIsText(true); if (Settings.isValidImageFilename(img.getName())) { img.setIsText(false); } } else { if (verbose) { log(-1, "Image not valid, but TextSearch is switched off!"); } } } return img; }
/** * waits until target vanishes or timeout (in seconds) is passed * * @param <PSI> Pattern, String or Image * @param target Pattern, String or Image * @param timeout time in seconds * @return true if target vanishes, false otherwise and if imagefile is missing. */ public <PSI> boolean waitVanish(PSI target, double timeout) { RepeatableVanish rv = new RepeatableVanish(target); Image img = rv._image; String targetStr = img.getName(); Boolean response = true; if (!img.isValid() && img.hasIOException()) { response = handleImageMissing(img, false); } if (null != response && response) { log(lvl, "waiting for " + targetStr + " to vanish within %.1f secs", timeout); if (rv.repeat(timeout)) { log(lvl, "%s vanished", targetStr); return true; } log(lvl, "%s did not vanish before timeout", targetStr); return false; } return false; }
String targetStr = img.getName(); while (null != response && response) { log(lvl, "find: waiting 0 secs for %s to appear in %s", targetStr, this.toStringShort());
String targetStr = img.getName(); while (null != response && response) { log(lvl, "exists: waiting %.1f secs for %s to appear in %s", timeout, targetStr, this.toStringShort());
RepeatableFind rf = new RepeatableFind(target, null); Image img = rf._image; String targetStr = img.getName(); Boolean response = true; if (!img.isText() && !img.isValid() && img.hasIOException()) {
RepeatableFindAll rf = new RepeatableFindAll(target, null); Image img = rf._image; String targetStr = img.getName(); Boolean response = true; if (!img.isValid() && img.hasIOException()) {
private Boolean handleImageMissing(Image img, boolean recap) { log(lvl, "handleImageMissing: %s", img.getName()); ObserveEvent evt = null; FindFailedResponse response = findFailedResponse; getRobotForRegion().delay(500); ScreenImage simg = getScreen().userCapture( (recap ? "recapture " : "capture missing ") + img.getName()); if (simg != null) { String path = ImagePath.getBundlePath();