/** * set a new image for this pattern * * @param fileURL image file URL * @return the Pattern itself */ public Pattern setFilename(URL fileURL) { image = Image.create(fileURL); return this; }
shouldCheckLastSeen = Settings.CheckLastSeen; if (pprobe instanceof String) { pImage = Image.create((String) pprobe); if (pImage.isValid()) { isValid = true;
/** * create a Pattern based on an image file name<br> * * @param imgpath image filename */ public Pattern(String imgpath) { image = Image.create(imgpath); }
/** * Pattern from a Java resource (Object.class.getResource) * * @param url image file URL */ public Pattern(URL url) { image = Image.create(url); }
/** * set a new image for this pattern * * @param fileName image filename * @return the Pattern itself */ public Pattern setFilename(String fileName) { image = Image.create(fileName); return this; }
/** * convenience method: get text from given image file * @param imgFile image filename * @return the text or null */ public static String text(String imgFile) { return create(imgFile).text(); } }
/** * forwarded to Image.create(filename).get() * * @return a BufferedImage from the given filename or null * @deprecated */ @Deprecated public static BufferedImage getImage(String filename) { return Image.create(filename).get(); }
/** * time optimized Region.exists, when image-size == region-size<br> * 1.1.x: just using exists(img, 0), sizes not checked * * @param img image file name * @return the match or null if not equal */ public Match compare(String img) { return compare(Image.create(img)); }
/** * create a Pattern with given image<br> * * @param img Image */ public Pattern(Image img) { image = img.create(img); image.setIsPattern(false); imagePattern = true; }
public SxImage(String filename) { super(); init(Image.create(filename).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 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 String setTargetSmartly(FindInput fin, String target) { if (isImageFile(target)) { //assume it's a file first String filename = Image.create(target).getFilename(); if (filename != null) { fin.setTarget(TARGET_TYPE.IMAGE, filename); return filename; } else { if (!repeating) { Debug.error(target + " looks like a file, but not on disk. Assume it's text."); } } } if (!Settings.OcrTextSearch) { Debug.error("Region.find(text): text search is currently switched off"); return target + "???"; } else { fin.setTarget(TARGET_TYPE.TEXT, target); if (TextRecognizer.getInstance() == null) { Debug.error("Region.find(text): text search is now switched off"); return target + "???"; } return target; } }
findingText = true; } else { img = Image.create((String) target); if (img.isValid()) { finder = doCheckLastSeenAndCreateFinder(base, img, 0.0, null);
findingText = true; } else { img = Image.create((String) ptn); if (img.isValid()) { f.findAll(img);