just to save works and use another computer to code
This commit is contained in:
@@ -85,10 +85,11 @@ module.exports = function(__runtime__, scope){
|
||||
options = options || {};
|
||||
var threshold = options.threshold || 0.9;
|
||||
var maxLevel = options.level || -1;
|
||||
var weakThreshold = options.weakThreshold || 0.7;
|
||||
if(options.region){
|
||||
return rtImages.findImage(img, template, threshold, buildRegion(options, img), maxLevel);
|
||||
return rtImages.findImage(img, template, weakThreshold, threshold, buildRegion(options, img), maxLevel);
|
||||
}else{
|
||||
return rtImages.findImage(img, template, threshold, null, maxLevel);
|
||||
return rtImages.findImage(img, template, weakThreshold, threshold, null, maxLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,10 @@ public class TemplateMatching {
|
||||
private static final String LOG_TAG = "TemplateMatching";
|
||||
|
||||
public static final int MAX_LEVEL_AUTO = -1;
|
||||
public static final int MATCHING_METHOD_DEFAULT = Imgproc.TM_CCOEFF_NORMED;
|
||||
|
||||
public static Point fastTemplateMatching(Mat img, Mat template, float threshold) {
|
||||
return fastTemplateMatching(img, template, Imgproc.TM_CCOEFF_NORMED, 0.75f, threshold, MAX_LEVEL_AUTO);
|
||||
return fastTemplateMatching(img, template, MATCHING_METHOD_DEFAULT, 0.75f, threshold, MAX_LEVEL_AUTO);
|
||||
}
|
||||
|
||||
public static Point fastTemplateMatching(Mat img, Mat template, int matchMethod, float weakThreshold, float strictThreshold, int maxLevel) {
|
||||
|
||||
@@ -51,6 +51,8 @@ public class Images {
|
||||
private ScreenCapturer mScreenCapturer;
|
||||
private Context mContext;
|
||||
private Display mDisplay;
|
||||
private Image mPreCapture;
|
||||
private ImageWrapper mPreCaptureImage;
|
||||
|
||||
@ScriptVariable
|
||||
public final ColorFinder colorFinder;
|
||||
@@ -102,7 +104,13 @@ public class Images {
|
||||
if (mScreenCapturer == null) {
|
||||
throw new SecurityException("No screen capture permission");
|
||||
}
|
||||
return ImageWrapper.ofImage(mScreenCapturer.capture());
|
||||
Image capture = mScreenCapturer.capture();
|
||||
if (capture == mPreCapture) {
|
||||
return mPreCaptureImage;
|
||||
}
|
||||
mPreCapture = capture;
|
||||
mPreCaptureImage = ImageWrapper.ofImage(capture);
|
||||
return mPreCaptureImage;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@@ -195,15 +203,16 @@ public class Images {
|
||||
}
|
||||
|
||||
public Point findImage(ImageWrapper image, ImageWrapper template, float threshold, Rect rect) {
|
||||
return findImage(image, template, threshold, rect, TemplateMatching.MAX_LEVEL_AUTO);
|
||||
return findImage(image, template, 0.7f, threshold, rect, TemplateMatching.MAX_LEVEL_AUTO);
|
||||
}
|
||||
|
||||
public Point findImage(ImageWrapper image, ImageWrapper template, float threshold, Rect rect, int maxLevel) {
|
||||
public Point findImage(ImageWrapper image, ImageWrapper template, float weakThreshold, float threshold, Rect rect, int maxLevel) {
|
||||
Mat src = image.getMat();
|
||||
if (rect != null) {
|
||||
src = new Mat(src, rect);
|
||||
}
|
||||
org.opencv.core.Point point = TemplateMatching.fastTemplateMatching(src, template.getMat(), threshold);
|
||||
org.opencv.core.Point point = TemplateMatching.fastTemplateMatching(src, template.getMat(), TemplateMatching.MATCHING_METHOD_DEFAULT,
|
||||
weakThreshold, threshold, maxLevel);
|
||||
if (point != null && rect != null) {
|
||||
point.x += rect.x;
|
||||
point.y += rect.y;
|
||||
|
||||
Reference in New Issue
Block a user