forked from kkevsekk1/AutoX
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wilinz
committed
Aug 22, 2022
1 parent
a703977
commit 1ab2345
Showing
4 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
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,32 @@ | ||
//此例子仅作为演示,无法运行,因为tessdata目录下没有训练数据, | ||
//如需运行,可前往github下载完整例子:https://github.com/wilinz/autoxjs-tessocr | ||
//导包 | ||
importClass(com.googlecode.tesseract.android.TessBaseAPI) | ||
//新建OCR实例 | ||
var tessocr = new TessBaseAPI() | ||
//请求截图权限 | ||
requestScreenCapture(false); | ||
//3秒后开始 | ||
toastLog("3秒后截图") | ||
sleep(3000) | ||
toastLog("开始截图") | ||
//截图 | ||
var img = captureScreen(); | ||
//tessdata目录所在的文件夹,目录下放置训练数据 | ||
//训练数据下载地址:https://github.com/tesseract-ocr/tessdata/tree/4.0.0 | ||
var dataPath = files.path("./") | ||
//初始化tessocr | ||
//第二个参数是初始化的语言,是数据文件去掉扩展名后的文件名,多个语言用+连接 | ||
//训练数据文件夹必须命名为tessdata | ||
//训练数据下载时是什么名字就是什么名字,不能改 | ||
var ok = tessocr.init(dataPath, "eng+chi_sim") | ||
if (ok) { | ||
toastLog("初始化成功: " + tessocr.getInitLanguagesAsString()) | ||
} else { | ||
toastLog("初始化失败") | ||
} | ||
//设置图片 | ||
tessocr.setImage(img.getBitmap()) | ||
//打印文本结果 | ||
toastLog(tessocr.getUTF8Text()) | ||
//如需获取位置等其他结果请看文档 |
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,53 @@ | ||
{ | ||
"abis": [ | ||
"arm64-v8a", | ||
"armeabi-v7a", | ||
"x86", | ||
"x86_64" | ||
], | ||
"assets": [ | ||
], | ||
"buildDir": "build", | ||
"build": { | ||
"build_id": null, | ||
"build_number": 0, | ||
"build_time": 0 | ||
}, | ||
"useFeatures": [], | ||
"icon": null, | ||
"ignoredDirs": [ | ||
"build" | ||
], | ||
"launchConfig": { | ||
"displaySplash": false, | ||
"hideLauncher": false, | ||
"hideLogs": false, | ||
"stableMode": false, | ||
"volumeUpcontrol": false, | ||
"permissions": [], | ||
"serviceDesc": "使脚本自动操作(点击、长按、滑动等)所需,若关闭则只能执行不涉及自动操作的脚本。", | ||
"splashIcon": null, | ||
"splashText": "Powered by TessOCR" | ||
}, | ||
"libs": [ | ||
"libtesseract.so", | ||
"libpng.so", | ||
"libleptonica.so", | ||
"libjpeg.so", | ||
"libjackpal-androidterm5.so", | ||
"libjackpal-termexec2.so" | ||
], | ||
"main": "main.js", | ||
"name": "TessOCR", | ||
"outputPath": null, | ||
"packageName": "com.script.tessocr", | ||
"projectDirectory": null, | ||
"scripts": {}, | ||
"signingConfig": { | ||
"alias": null, | ||
"keystore": null | ||
}, | ||
"sourcePath": null, | ||
"versionCode": 1, | ||
"versionName": "1.0.0" | ||
} |
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