public boolean isAlreadyTracking(Pattern pattern, Region match) { try { boolean sameMatch = this.match == match; boolean sameBufferedImage = this.pattern.getBImage() == pattern.getBImage(); boolean sameFilename = (this.pattern.getFilename() != null && (this.pattern.getFilename().compareTo(pattern.getFilename()) == 0)); return sameMatch || sameBufferedImage || sameFilename; } catch (Exception e) { return false; } }
/** * 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 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; } }