Skip to content

Commit 508f441

Browse files
committedMar 8, 2019
first commit
1 parent 3d1112d commit 508f441

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
 

‎ocr/本地ocr.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* 作者: 家
3+
* 功能: 本地识别数字 (效果没的说 Σ( ° △ °|||)︴ )
4+
* 备注: 需要下载ocr插件 名字是 OPR插件试用版非常慢.apk
5+
*/
6+
7+
8+
requestScreenCapture()
9+
var OCR=plugins.load('org.autojs.plugin.ocr')
10+
log(OCR)
11+
function 识别文字(x1,y1,x2,y2){
12+
if(!x1){
13+
x1=0
14+
y1=0
15+
x2=device.width
16+
y2=device.height
17+
}
18+
var ocr = new OCR();
19+
events.on("exit", () => {
20+
ocr.end();
21+
});
22+
log("ocr screen");
23+
var img=captureScreen()
24+
var w=x2-x1
25+
var h=y2-y1
26+
var clip = images.clip(img, x1, y1, w, h);
27+
var result=ocr.ocrImage(clip)
28+
log('ocr识别结果',result)
29+
result=result.text
30+
log("ocr识别结果文本=",result)
31+
// ocr识别结果 OcrWordsResult{text='公告', success=true, words=[Word{text='公告', bounds=Rect(23, 8 - 138, 67), confidences=90.60959}], timeRequired=27}
32+
img.recycle()
33+
34+
return result
35+
}
36+
37+
38+
39+
40+
//log(ocrWidget(text("运行").findOne()));
41+
42+
function ocrWidget(w) {
43+
let img = captureScreen();
44+
let bounds = w.bounds();
45+
img = images.clip(img, bounds.left, bounds.top, bounds.width(), bounds.height());
46+
return ocr.ocrImage(img);
47+
}
48+
49+
50+
var result=识别文字()
51+
log(result)
52+
// var circle = {};
53+
// circle.识别文字 = 识别文字
54+
// module.exports = circle;

0 commit comments

Comments
 (0)
Please sign in to comment.