/** * do a text find with the given text in the Finder's image * (hasNext() and next() will reveal possible match results) * @param text text * @return null. if find setup not possible */ public String findText(String text) { if (!valid) { log(-1, "not valid"); return null; } _findInput.setTarget(TARGET_TYPE.TEXT, text); _results = Vision.find(_findInput); _cur_result_i = 0; return text; } //</editor-fold>
/** * Finder constructor for special use from an Image * * @param img Image */ public Finder(Image img) { log(lvl, "Image: %s", img); _findInput.setSource(Image.convertBufferedImageToMat(img.get())); }
/** * 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 text in the Finder's image * (hasNext() and next() will reveal possible match results) * @param text text * @return null. if find setup not possible */ public String findAllText(String text) { if (!valid) { log(-1, "not valid"); return null; } _findInput.setTarget(TARGET_TYPE.TEXT, text); _findInput.setFindAll(true); Debug timing = Debug.startTimer("Finder.findAllText"); _results = Vision.find(_findInput); _cur_result_i = 0; timing.end(); return text; } //</editor-fold>
/** * 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; }
/** * do a find op with the given pattern in the Finder's image * (hasNext() and next() will reveal possible match results) * @param aPtn Pattern * @return null. if find setup not possible */ public String find(Pattern aPtn) { if (!valid) { log(-1, "not valid"); return null; } if (aPtn.isValid()) { _pattern = aPtn; _findInput.setTarget(aPtn.getImage().getMatNative()); _findInput.setSimilarity(aPtn.getSimilar()); _results = Vision.find(_findInput); _cur_result_i = 0; return aPtn.getFilename(); } 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; } }
/** * 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 find op with the given pattern in the Finder's image * (hasNext() and next() will reveal possible match results) * @param aPtn Pattern * @return null. if find setup not possible */ public String findAll(Pattern aPtn) { if (!valid) { log(-1, "not valid"); return null; } if (aPtn.isValid()) { _image = aPtn.getImage(); _pattern = aPtn; _findInput.setTarget(aPtn.getImage().getMatNative()); _findInput.setSimilarity(aPtn.getSimilar()); _findInput.setFindAll(true); Debug timing = Debug.startTimer("Finder.findAll"); _results = Vision.find(_findInput); _cur_result_i = 0; timing.end(); return aPtn.getFilename(); } else { return null; } }