mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-24 21:33:16 +08:00
修复 matchTemplate函数返回的结果相等或接近的问题
修复 app.getUriForFile()等报错的问题
This commit is contained in:
parent
f65ab0fc57
commit
d05b65ba51
@ -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);
|
||||
};
|
||||
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -317,7 +317,7 @@ public class Images {
|
||||
if (rect != null) {
|
||||
src = new Mat(src, rect);
|
||||
}
|
||||
List<TemplateMatching.Match> result = TemplateMatching.fastTemplateMatching(src, template.getMat(), TemplateMatching.MATCHING_METHOD_DEFAULT,
|
||||
List<TemplateMatching.Match> 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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user