/** * checks, wether the Image can be used with the new ImageFinder * @return true/false */ public boolean isUseable() { return isValid() || imageIsPattern; }
/** * check wether the image is valid * * @return true if image is useable */ public boolean isValid() { return image.isValid() || imagePattern; }
public boolean isFile() { if (isValid()) { URL furl = getURL(); if ("file".equals(furl.getProtocol())) { return true; } } return false; }
protected boolean backup() { if (isValid()) { File fOrg = new File(fileURL.getPath()); File fBack = new File(fOrg.getParentFile(), "_BACKUP_" + fOrg.getName()); if (FileManager.xcopy(fOrg, fBack)) { hasBackup = fBack.getPath(); log(lvl, "backup: %s created", fBack.getName()); return true; } log(-1, "backup: %s did not work", fBack.getName()); } return false; }
JPanel dialog = new JPanel(); dialog.setLayout(new BorderLayout()); if (img.isValid()) { if (!img.isText()) { Image bimage = img.get(false);
private <PSIC> String onEvent(PSIC targetThreshhold, Object observer, ObserveEvent.Type obsType) { if (observer != null && (observer.getClass().getName().contains("org.python") || observer.getClass().getName().contains("org.jruby"))) { observer = new ObserverCallBack(observer, obsType); } if (!(targetThreshhold instanceof Integer)) { Image img = Image.getImageFromTarget(targetThreshhold); Boolean response = true; if (!img.isValid() && img.hasIOException()) { response = handleImageMissing(img, false); if (response == null) { runTime.abortScripting("onEvent(" + obsType.name() + "): Abort:", "ImageMissing: " + targetThreshhold.toString()); } } } String name = Observing.add(this, (ObserverCallBack) observer, obsType, targetThreshhold); log(lvl, "%s: observer %s %s: %s with: %s", toStringShort(), obsType, (observer == null ? "" : " with callback"), name, targetThreshhold); return name; }
public boolean setImage(Image base) { reset(); if (base.isValid()) { bImage = base; this.base = Image.createMat(base.get()); isImage = true; log(3, "search in: \n%s", base.get()); } return isImage; }
/** * Finder constructor (finding within an image within the given region). * <br>internally used with a screen snapshot * * @param imageFilename a string (name, path, url) * @param region search Region within image - topleft = (0,0) * @throws java.io.IOException if imagefile not found */ public Finder(String imageFilename, Region region) throws IOException { Image img = Image.create(imageFilename); if (img.isValid()) { _findInput.setSource(Image.convertBufferedImageToMat(img.get())); _region = region; screenFinder = false; } else { log(-1, "imagefile not found:\n%s"); valid = false; } }
/** * do a find op with the given image or the given text in the Finder's image * (hasNext() and next() will reveal possible match results) * @param imageOrText image file name or text * @return null. if find setup not possible */ public String find(String imageOrText) { if (!valid) { log(-1, "not valid"); return null; } Image img = Image.create(imageOrText); if (img.isText()) { return findText(imageOrText); } if (img.isValid()) { return find(img); } return null; }
/** * do a findAll op with the given image or the given text in the Finder's image * (hasNext() and next() will reveal possible match results) * @param imageOrText iamge file name or text * @return null. if find setup not possible */ public String findAll(String imageOrText) { if (!valid) { log(-1, "not valid"); return null; } Image img = Image.create(imageOrText); _image = img; if (img.isText()) { return findAllText(imageOrText); } if (img.isValid()) { return findAll(img); } return null; }
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; }
/** * do a find op with the given pattern in the Finder's image * (hasNext() and next() will reveal possible match results) * @param img Image * @return null. if find setup not possible */ public String find(Image img) { if (!valid) { log(-1, "not valid"); return null; } if (img.isValid()) { _findInput.setTarget(img.getMatNative()); _findInput.setSimilarity(Settings.MinSimilarity); _results = Vision.find(_findInput); _cur_result_i = 0; return img.getFilename(); } else if (img.isUseable()) { return find(new Pattern(img)); } else { return null; } }
/** * do a findAll op with the given image in the Finder's image * (hasNext() and next() will reveal possible match results) * @param img Image * @return null. if find setup not possible */ public String findAll(Image img) { if (!valid) { log(-1, "not valid"); return null; } if (img.isValid()) { _findInput.setTarget(img.getMatNative()); _findInput.setSimilarity(Settings.MinSimilarity); _findInput.setFindAll(true); Debug timing = Debug.startTimer("Finder.findAll"); _results = Vision.find(_findInput); _cur_result_i = 0; timing.end(); return img.getFilename(); } else { return null; } }
String targetStr = img.getName(); Boolean response = true; if (!img.isText() && !img.isValid() && img.hasIOException()) { response = handleImageMissing(img, false); if (response == null) {
Image img = Image.getImageFromTarget(target); Boolean response = true; if (!img.isText() && !img.isValid() && img.hasIOException()) { response = handleImageMissing(img, false); if (response == null) {
String targetStr = img.getName(); Boolean response = true; if (!img.isValid() && img.hasIOException()) { response = handleImageMissing(img, false); if (response == null) {
if (img.isValid()) { log(lvl, "handleImageMissing: %scaptured: %s", (recap ? "re" : ""), img); Image.setIDEshouldReload(img);