修复 打包项目时无法运行的问题

新增 images.matchTemplate()找图返回多个位置
新增 找图示例
This commit is contained in:
hyb1996
2018-12-16 10:24:57 +08:00
parent 6f66956751
commit 72d8077142
16 changed files with 346 additions and 97 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View File

@@ -0,0 +1,11 @@
var superMario = images.read("./super_mario.jpg");
var block = images.read("./block.png");
var result = images.matchTemplate(superMario, block, {
threshold: 0.8
}).matches;
toastLog(result);
superMario.recycle();
block.recycle();

View File

@@ -0,0 +1,23 @@
var superMario = images.read("./super_mario.jpg");
var block = images.read("./block.png");
var points = images.matchTemplate(superMario, block, {
threshold: 0.8
}).points;
toastLog(points);
var canvas = new Canvas(superMario);
var paint = new Paint();
paint.setColor(colors.parseColor("#2196F3"));
points.forEach(point => {
canvas.drawRect(point.x, point.y, point.x + block.width, point.y + block.height, paint);
});
var image = canvas.toImage();
images.save(image, "/sdcard/tmp.png");
app.viewFile("/sdcard/tmp.png");
superMario.recycle();
block.recycle();
image.recycle();

View File

@@ -0,0 +1,8 @@
var superMario = images.read("./super_mario.jpg");
var mario = images.read("./mario.png");
var point = findImage(superMario, mario);
toastLog(point);
superMario.recycle();
mario.recycle();