@Override protected List<ScreenRegion> getUnorderedMatches(ScreenRegion screenRegion) { Rectangle screenRegionBounds = screenRegion.getBounds(); if (screenRegionBounds.width < targetImage.getWidth() || screenRegionBounds.height < targetImage.getHeight()) { // if screen region is smaller than the target, no target can be found // TODO: perhaps a more fault tolerant approach is to return a smaller target with a lower // score return Lists.newArrayList(); } List<TemplateMatcher.Result> matches; BufferedImage screenImage = screenRegion.capture(); List<Rectangle> rois = screenRegion.getROIs(); if (rois.isEmpty()) { matches = TemplateMatcher.findMatchesByGrayscaleAtOriginalResolution( screenImage, targetImage, getLimit(), getMinScore()); } else { matches = TemplateMatcher.findMatchesByGrayscaleAtOriginalResolutionWithROIs( screenImage, targetImage, getLimit(), getMinScore(), rois); } return convertToScreenRegions(screenRegion, matches); }
@Override protected List<ScreenRegion> getUnorderedMatches(ScreenRegion screenRegion) { BufferedImage exampleImage = getImage(); FourCornerModel buttonModel = FourCornerModel.learnFrom(exampleImage); List<RegionMatch> matches = VisualModelFinder.searchButton(buttonModel, screenRegion.capture()); List<RegionMatch> subList = matches.subList(0, Math.min(getLimit(), matches.size())); return convertToScreenRegions(screenRegion, subList); }