diff --git a/autojs/src/main/assets/modules/__app__.js b/autojs/src/main/assets/modules/__app__.js index d5282755..8e38b836 100644 --- a/autojs/src/main/assets/modules/__app__.js +++ b/autojs/src/main/assets/modules/__app__.js @@ -146,7 +146,7 @@ module.exports = function (runtime, global) { if (app.fileProviderAuthority == null) { return android.net.Uri.fromFile(file); } - return androidx.core.content.FileProvider.getUriForFile(context, + return Packages["androidx"].core.content.FileProvider.getUriForFile(context, app.fileProviderAuthority, file); }; diff --git a/autojs/src/main/assets/modules/__automator__.js b/autojs/src/main/assets/modules/__automator__.js index 449013bb..31a1ba13 100644 --- a/autojs/src/main/assets/modules/__automator__.js +++ b/autojs/src/main/assets/modules/__automator__.js @@ -162,7 +162,7 @@ module.exports = function(runtime, global){ }); auto.__defineGetter__("windows", function() { - var service = auto.getService(); + var service = auto.service; return service == null ? [] : util.java.toJsArray(service.getWindows(), true); }); diff --git a/autojs/src/main/assets/modules/__images__.js b/autojs/src/main/assets/modules/__images__.js index 59f8ea93..d2a2e3db 100644 --- a/autojs/src/main/assets/modules/__images__.js +++ b/autojs/src/main/assets/modules/__images__.js @@ -192,13 +192,6 @@ module.exports = function (runtime, scope) { colors.blue(lowerBound), colors.alpha(lowerBound)); var ub = new Scalar(colors.red(upperBound), colors.green(upperBound), colors.blue(upperBound), colors.alpha(lowerBound)) - if (typeof (upperBound) == 'number') { - var color = lowerBound; - var threshold = upperBound; - - } else { - throw new TypeError('lowerBound = ' + lowerBound, + 'upperBound = ' + upperBound); - } var bi = new Mat(); Core.inRange(img.mat, lb, ub, bi); return images.matToImage(bi); @@ -228,7 +221,7 @@ module.exports = function (runtime, scope) { initIfNeeded(); var mat = new Mat(); size = newSize(size); - type = Imgproc["BORDER_" + (type || "DEFAULT")]; + type = Core["BORDER_" + (type || "DEFAULT")]; if (point == undefined) { Imgproc.blur(img.mat, mat, size); } else { @@ -251,7 +244,7 @@ module.exports = function (runtime, scope) { size = newSize(size); sigmaX = sigmaX == undefined ? 0 : sigmaX; sigmaY = sigmaY == undefined ? 0 : sigmaY; - type = Imgproc["BORDER_" + (type || "DEFAULT")]; + type = Core["BORDER_" + (type || "DEFAULT")]; Imgproc.GaussianBlur(img.mat, mat, size, sigmaX, sigmaY, type); return images.matToImage(mat); } diff --git a/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java b/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java index 14c290d1..9eb1ae6c 100644 --- a/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java +++ b/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java @@ -214,9 +214,11 @@ public class TemplateMatching { break; } outResult.add(bestMatched); - Imgproc.rectangle(tmResult, bestMatched.point, - new Point(bestMatched.point.x + template.cols(), bestMatched.point.y + template.rows()), - new Scalar(0, 255, 0), -1); + Point start = new Point(Math.max(0, bestMatched.point.x - template.width() + 1), + Math.max(0, bestMatched.point.y - template.height() + 1)); + Point end = new Point(Math.min(tmResult.width(), bestMatched.point.x + template.width()), + Math.min(tmResult.height(), bestMatched.point.y + template.height())); + Imgproc.rectangle(tmResult, start, end, new Scalar(0, 255, 0), -1); } } diff --git a/autojs/src/main/java/com/stardust/autojs/runtime/api/Images.java b/autojs/src/main/java/com/stardust/autojs/runtime/api/Images.java index a6ee6279..8c5a4e96 100644 --- a/autojs/src/main/java/com/stardust/autojs/runtime/api/Images.java +++ b/autojs/src/main/java/com/stardust/autojs/runtime/api/Images.java @@ -317,7 +317,7 @@ public class Images { if (rect != null) { src = new Mat(src, rect); } - List result = TemplateMatching.fastTemplateMatching(src, template.getMat(), TemplateMatching.MATCHING_METHOD_DEFAULT, + List result = TemplateMatching.fastTemplateMatching(src, template.getMat(), Imgproc.TM_CCOEFF_NORMED, weakThreshold, threshold, maxLevel, limit); for (TemplateMatching.Match match : result) { Point point = match.point; @@ -331,7 +331,6 @@ public class Images { if (src != image.getMat()) { OpenCVHelper.release(src); } - Collections.sort(result, (l, r) -> Double.compare(r.similarity, l.similarity)); return result; }