Add files via upload

This commit is contained in:
LYS
2023-06-03 09:39:17 +08:00
committed by GitHub
parent 620cfa1317
commit 61845d8d50

View File

@@ -160,7 +160,7 @@ module.exports = function (scriptRuntime, scope) {
throw TypeError(`Argument size for images.medianBlur must be either a number or an array with SAME two number elements`);
}
}
let ksize = Array.isArray(size) ? [ size ][0] : size;
let ksize = Array.isArray(size) ? [size][0] : size;
let mat = new Mat();
Imgproc.medianBlur(img.mat, mat, ksize);
img.shoot();
@@ -240,7 +240,7 @@ module.exports = function (scriptRuntime, scope) {
this.results = [];
for (let i = 0; i < cir.rows(); i++) {
for (let j = 0; j < cir.cols(); j++) {
let [ x, y, radius ] = cir.get(i, j);
let [x, y, radius] = cir.get(i, j);
this.results.push({ x, y, radius });
}
}
@@ -304,13 +304,13 @@ module.exports = function (scriptRuntime, scope) {
},
findColorInRegion(img, color, x, y, width, height, threshold) {
return this.findColor(img, color, {
region: [ x, y, width, height ],
region: [x, y, width, height],
threshold: threshold,
});
},
findColorEquals(img, color, x, y, width, height) {
return this.findColor(img, color, {
region: [ x, y, width, height ],
region: [x, y, width, height],
threshold: 0,
});
},
@@ -323,21 +323,31 @@ module.exports = function (scriptRuntime, scope) {
'region' in opt ? _.buildRegion(img, opt.region) : null);
return _.toPointArray(o);
},
findMultiColors(img, firstColor, paths, options) {
findMultiColors(img, firstColor, paths, options) {
_.initIfNeeded();
let list = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE, paths.length * 3);
for (let i = 0; i < paths.length; i += 1) {
let [ x, y, color ] = paths[i];
let [x, y, color] = paths[i];
list[i * 3] = x;
list[i * 3 + 1] = y;
list[i * 3 + 2] = colors.toInt(color);
}
let opt = options || {};
return rtImages.colorFinder.findMultiColors(img,
colors.toInt(firstColor),
_.parseThreshold(opt),
'region' in opt ? _.buildRegion(img, opt.region) : null,
list);
let findAll = opt.All || false;
if (findAll) {
return Array.from(rtImages.colorFinder.findAllMultiColors(img,
colors.toInt(firstColor),
_.parseThreshold(opt),
'region' in opt ? _.buildRegion(img, opt.region) : null,
list));
} else {
return rtImages.colorFinder.findMultiColors(img,
colors.toInt(firstColor),
_.parseThreshold(opt),
'region' in opt ? _.buildRegion(img, opt.region) : null,
list);
}
},
findImage(img, template, options) {
_.initIfNeeded();
@@ -350,7 +360,7 @@ module.exports = function (scriptRuntime, scope) {
},
findImageInRegion(img, template, x, y, width, height, threshold) {
return this.findImage(img, template, {
region: [ x, y, width, height ],
region: [x, y, width, height],
threshold: threshold,
});
},
@@ -663,7 +673,7 @@ module.exports = function (scriptRuntime, scope) {
if (size.length === 1) {
width = height = size[0];
} else {
[ width, height ] = size;
[width, height] = size;
}
}
return new Size(width, height);
@@ -683,7 +693,7 @@ module.exports = function (scriptRuntime, scope) {
* @returns {org.opencv.core.Point}
*/
parsePoint(point) {
let [ x, y ] = point;
let [x, y] = point;
return new Point(x, y);
},
parseQuality(q) {
@@ -771,10 +781,10 @@ module.exports = function (scriptRuntime, scope) {
* @returns {org.opencv.core.Rect}
*/
buildRegion(img, region) {
let [ x, y, w, h ] = region instanceof org.opencv.core.Rect
? [ region.x, region.y, region.width, region.height ]
let [x, y, w, h] = region instanceof org.opencv.core.Rect
? [region.x, region.y, region.width, region.height]
: region instanceof android.graphics.Rect
? [ region.left, region.top, region.width(), region.height() ]
? [region.left, region.top, region.width(), region.height()]
: Array.isArray(region) ? region : [];
x = _.parseNumber(x, 0);