forked from clearw5/Auto.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
新增 images.matchTemplate()找图返回多个位置 新增 找图示例
- Loading branch information
hyb1996
committed
Dec 16, 2018
1 parent
6f66956
commit 72d8077
Showing
16 changed files
with
346 additions
and
97 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.