ms-types 0.1.22 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +20 -20
- package/types/action.d.ts +298 -298
- package/types/{appleocr.d.ts → appleOcr.d.ts} +102 -102
- package/types/config.d.ts +54 -54
- package/types/device.d.ts +105 -105
- package/types/global.d.ts +185 -181
- package/types/hid.d.ts +289 -289
- package/types/hotUpdate.d.ts +104 -104
- package/types/http.d.ts +300 -300
- package/types/ime.d.ts +99 -99
- package/types/index.d.ts +26 -26
- package/types/media.d.ts +90 -90
- package/types/mysql.d.ts +174 -174
- package/types/netCard.d.ts +77 -42
- package/types/node.d.ts +279 -279
- package/types/{paddleocr.d.ts → paddleOcr.d.ts} +73 -73
- package/types/pip.d.ts +51 -51
- package/types/system.d.ts +195 -195
- package/types/thread.d.ts +101 -101
- package/types/{tomatoocr.d.ts → tomatoOcr.d.ts} +199 -199
- package/types/tts.d.ts +91 -91
- package/types/ui.d.ts +165 -165
- package/types/yolo.d.ts +98 -98
- package/types/zh/HID/346/250/241/345/235/227.d.ts +293 -293
- package/types/zh/HTTP/346/250/241/345/235/227.d.ts +301 -301
- package/types/zh/{MySql → MySQL}/346/250/241/345/235/227.d.ts +175 -175
- package/types/zh/PaddleOCR/346/250/241/345/235/227.d.ts +74 -74
- package/types/zh/YOLO/346/250/241/345/235/227.d.ts +101 -101
- package/types/zh/index.d.ts +24 -24
- package/types/zh//345/205/250/345/261/200/346/250/241/345/235/227.d.ts +180 -179
- package/types/zh//345/212/250/344/275/234/346/250/241/345/235/227.d.ts +300 -300
- package/types/zh//345/215/241/345/257/206/346/250/241/345/235/227.d.ts +90 -55
- package/types/zh//345/252/222/344/275/223/346/250/241/345/235/227.d.ts +91 -91
- package/types/zh//345/267/245/345/205/267/346/250/241/345/235/227.d.ts +30 -30
- package/types/zh//346/202/254/346/265/256/347/252/227/346/250/241/345/235/227.d.ts +55 -55
- package/types/zh//346/226/207/345/255/227/350/275/254/350/257/255/351/237/263/346/250/241/345/235/227.d.ts +92 -92
- package/types/zh//347/203/255/346/233/264/346/226/260/346/250/241/345/235/227.d.ts +105 -105
- package/types/zh//347/263/273/347/273/237/346/250/241/345/235/227.d.ts +194 -194
- package/types/zh//347/272/277/347/250/213/346/250/241/345/235/227.d.ts +102 -102
- package/types/zh//350/212/202/347/202/271/346/250/241/345/235/227.d.ts +280 -280
- package/types/zh//350/213/271/346/236/234OCR.d.ts +104 -104
- package/types/zh//350/247/206/345/233/276/346/250/241/345/235/227.d.ts +167 -167
- package/types/zh//350/256/276/345/244/207/346/250/241/345/235/227.d.ts +106 -106
- package/types/zh//350/276/223/345/205/245/346/263/225/346/250/241/345/235/227.d.ts +100 -100
- package/types/zh//351/205/215/347/275/256/346/250/241/345/235/227.d.ts +56 -56
package/types/thread.d.ts
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 线程模块 包含线程操作、线程回调等功能
|
|
3
|
-
*/
|
|
4
|
-
declare namespace thread {
|
|
5
|
-
/**
|
|
6
|
-
* 异步执行线程代码
|
|
7
|
-
* @param threadJsFile 线程js文件路径
|
|
8
|
-
* @param callbackName 回调函数名称
|
|
9
|
-
* @param callbackFunc 回调函数
|
|
10
|
-
* @returns 线程名称
|
|
11
|
-
* @example
|
|
12
|
-
* thread.execCodeAsync("thread.js", "callback", (data) => {
|
|
13
|
-
* logi(data)
|
|
14
|
-
* return "1111"
|
|
15
|
-
* })
|
|
16
|
-
*
|
|
17
|
-
* thread.js
|
|
18
|
-
* while (!__shouldExit__) {
|
|
19
|
-
* // 通知主线程并传递数据
|
|
20
|
-
* const data = thread.invokeCallback("callback", "hello world")
|
|
21
|
-
* // 主线程返回数据
|
|
22
|
-
* logi(data)
|
|
23
|
-
* sleep(1000)
|
|
24
|
-
* }
|
|
25
|
-
*/
|
|
26
|
-
function execCodeAsync(
|
|
27
|
-
threadJsFile: string,
|
|
28
|
-
callbackName: string,
|
|
29
|
-
callbackFunc: (data?: any) => any
|
|
30
|
-
): string | null;
|
|
31
|
-
/**
|
|
32
|
-
* 调用线程回调函数
|
|
33
|
-
* @param name 回调函数名称
|
|
34
|
-
* @param data 回调数据
|
|
35
|
-
* @returns 回调返回值
|
|
36
|
-
* @example
|
|
37
|
-
* const data = thread.invokeCallback("callback", "hello world")
|
|
38
|
-
* logi(data)
|
|
39
|
-
*/
|
|
40
|
-
function invokeCallback(name: string, data?: any): any;
|
|
41
|
-
/**
|
|
42
|
-
* 创建新线程
|
|
43
|
-
* @param threadJsFile 线程js文件路径
|
|
44
|
-
* @returns 线程对象
|
|
45
|
-
* @example
|
|
46
|
-
* const newThread = thread.newThread("thread.js")
|
|
47
|
-
* newThread.addCallback("callback", (data) => {
|
|
48
|
-
* logi(data)
|
|
49
|
-
* return "1111"
|
|
50
|
-
* })
|
|
51
|
-
*/
|
|
52
|
-
function newThread(threadJsFile: string): {
|
|
53
|
-
/**
|
|
54
|
-
* 线程名称
|
|
55
|
-
*/
|
|
56
|
-
name: string;
|
|
57
|
-
/**
|
|
58
|
-
* 添加回调函数
|
|
59
|
-
* @param callbackName 回调函数名称
|
|
60
|
-
* @param callbackFunc 回调函数
|
|
61
|
-
* @returns 是否添加成功
|
|
62
|
-
*/
|
|
63
|
-
addCallback: (
|
|
64
|
-
callbackName: string,
|
|
65
|
-
callbackFunc: (data?: any) => any
|
|
66
|
-
) => boolean;
|
|
67
|
-
} | null;
|
|
68
|
-
/**
|
|
69
|
-
* 取消线程
|
|
70
|
-
* @param name 线程名称
|
|
71
|
-
* @returns 是否取消成功
|
|
72
|
-
* @example
|
|
73
|
-
* const newThread = thread.newThread("thread.js")
|
|
74
|
-
* newThread.addCallback("callback", (data) => {
|
|
75
|
-
* logi(data)
|
|
76
|
-
* return "1111"
|
|
77
|
-
* })
|
|
78
|
-
* thread.cancelThread(newThread.name)
|
|
79
|
-
*/
|
|
80
|
-
function cancelThread(name: string): boolean;
|
|
81
|
-
/**
|
|
82
|
-
* 检查线程是否已取消
|
|
83
|
-
* @param name 线程名称
|
|
84
|
-
* @returns 是否已取消
|
|
85
|
-
* @example
|
|
86
|
-
* const newThread = thread.newThread("thread.js")
|
|
87
|
-
* newThread.addCallback("callback", (data) => {
|
|
88
|
-
* logi(data)
|
|
89
|
-
* return "1111"
|
|
90
|
-
* })
|
|
91
|
-
* thread.isCancelled(newThread.name)
|
|
92
|
-
*/
|
|
93
|
-
function isCancelled(name: string): boolean;
|
|
94
|
-
/**
|
|
95
|
-
* 停止所有线程
|
|
96
|
-
* @returns 是否停止成功
|
|
97
|
-
* @example
|
|
98
|
-
* thread.stopAll()
|
|
99
|
-
*/
|
|
100
|
-
function stopAll(): boolean;
|
|
101
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 线程模块 包含线程操作、线程回调等功能
|
|
3
|
+
*/
|
|
4
|
+
declare namespace thread {
|
|
5
|
+
/**
|
|
6
|
+
* 异步执行线程代码
|
|
7
|
+
* @param threadJsFile 线程js文件路径
|
|
8
|
+
* @param callbackName 回调函数名称
|
|
9
|
+
* @param callbackFunc 回调函数
|
|
10
|
+
* @returns 线程名称
|
|
11
|
+
* @example
|
|
12
|
+
* thread.execCodeAsync("thread.js", "callback", (data) => {
|
|
13
|
+
* logi(data)
|
|
14
|
+
* return "1111"
|
|
15
|
+
* })
|
|
16
|
+
*
|
|
17
|
+
* thread.js
|
|
18
|
+
* while (!__shouldExit__) {
|
|
19
|
+
* // 通知主线程并传递数据
|
|
20
|
+
* const data = thread.invokeCallback("callback", "hello world")
|
|
21
|
+
* // 主线程返回数据
|
|
22
|
+
* logi(data)
|
|
23
|
+
* sleep(1000)
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
function execCodeAsync(
|
|
27
|
+
threadJsFile: string,
|
|
28
|
+
callbackName: string,
|
|
29
|
+
callbackFunc: (data?: any) => any
|
|
30
|
+
): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* 调用线程回调函数
|
|
33
|
+
* @param name 回调函数名称
|
|
34
|
+
* @param data 回调数据
|
|
35
|
+
* @returns 回调返回值
|
|
36
|
+
* @example
|
|
37
|
+
* const data = thread.invokeCallback("callback", "hello world")
|
|
38
|
+
* logi(data)
|
|
39
|
+
*/
|
|
40
|
+
function invokeCallback(name: string, data?: any): any;
|
|
41
|
+
/**
|
|
42
|
+
* 创建新线程
|
|
43
|
+
* @param threadJsFile 线程js文件路径
|
|
44
|
+
* @returns 线程对象
|
|
45
|
+
* @example
|
|
46
|
+
* const newThread = thread.newThread("thread.js")
|
|
47
|
+
* newThread.addCallback("callback", (data) => {
|
|
48
|
+
* logi(data)
|
|
49
|
+
* return "1111"
|
|
50
|
+
* })
|
|
51
|
+
*/
|
|
52
|
+
function newThread(threadJsFile: string): {
|
|
53
|
+
/**
|
|
54
|
+
* 线程名称
|
|
55
|
+
*/
|
|
56
|
+
name: string;
|
|
57
|
+
/**
|
|
58
|
+
* 添加回调函数
|
|
59
|
+
* @param callbackName 回调函数名称
|
|
60
|
+
* @param callbackFunc 回调函数
|
|
61
|
+
* @returns 是否添加成功
|
|
62
|
+
*/
|
|
63
|
+
addCallback: (
|
|
64
|
+
callbackName: string,
|
|
65
|
+
callbackFunc: (data?: any) => any
|
|
66
|
+
) => boolean;
|
|
67
|
+
} | null;
|
|
68
|
+
/**
|
|
69
|
+
* 取消线程
|
|
70
|
+
* @param name 线程名称
|
|
71
|
+
* @returns 是否取消成功
|
|
72
|
+
* @example
|
|
73
|
+
* const newThread = thread.newThread("thread.js")
|
|
74
|
+
* newThread.addCallback("callback", (data) => {
|
|
75
|
+
* logi(data)
|
|
76
|
+
* return "1111"
|
|
77
|
+
* })
|
|
78
|
+
* thread.cancelThread(newThread.name)
|
|
79
|
+
*/
|
|
80
|
+
function cancelThread(name: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* 检查线程是否已取消
|
|
83
|
+
* @param name 线程名称
|
|
84
|
+
* @returns 是否已取消
|
|
85
|
+
* @example
|
|
86
|
+
* const newThread = thread.newThread("thread.js")
|
|
87
|
+
* newThread.addCallback("callback", (data) => {
|
|
88
|
+
* logi(data)
|
|
89
|
+
* return "1111"
|
|
90
|
+
* })
|
|
91
|
+
* thread.isCancelled(newThread.name)
|
|
92
|
+
*/
|
|
93
|
+
function isCancelled(name: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* 停止所有线程
|
|
96
|
+
* @returns 是否停止成功
|
|
97
|
+
* @example
|
|
98
|
+
* thread.stopAll()
|
|
99
|
+
*/
|
|
100
|
+
function stopAll(): boolean;
|
|
101
|
+
}
|
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TomatoOCR 模块
|
|
3
|
-
* 提供基于 TomatoOCR 框架的文字识别和 YOLO 目标检测功能
|
|
4
|
-
*/
|
|
5
|
-
declare namespace tomatoOcr {
|
|
6
|
-
/**
|
|
7
|
-
* 初始化TomatoOCR并设置基本配置
|
|
8
|
-
* @param mode 运行模式 debug:调试模型;删除或传别的任何值为正式模式
|
|
9
|
-
* @param licenseData 授权码 请传入你在 TomatoOCR 官网申请的授权码
|
|
10
|
-
* @param remark 备注信息(可选)
|
|
11
|
-
* @returns 设置结果
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* // 不带备注
|
|
15
|
-
* const result1 = tomatoOcr.initializeWithConfig("online", "授权码");
|
|
16
|
-
* // 带备注
|
|
17
|
-
* const result2 = tomatoOcr.initializeWithConfig("online", "授权码", "测试环境");
|
|
18
|
-
* logi(result1, result2);
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
function initializeWithConfig(
|
|
22
|
-
mode: string,
|
|
23
|
-
licenseData: string,
|
|
24
|
-
remark?: string
|
|
25
|
-
): {
|
|
26
|
-
deviceId: string;
|
|
27
|
-
expiryTime: string;
|
|
28
|
-
message: string;
|
|
29
|
-
status: string;
|
|
30
|
-
versionName: string;
|
|
31
|
-
} | null;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 设置 HTTP 请求间隔时间
|
|
35
|
-
* @param second 间隔秒数 设置网络请求间隔时间,非必设置。0-86400
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* tomatoOcr.setHttpIntervalTime(3600);
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
function setHttpIntervalTime(second: number): void;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* 设置识别类型
|
|
45
|
-
* @param recType 识别类型 模型类型,默认 ch-3.0,除此之外还有 ch-2.0, ch, cht, japan, korean, number
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* // 普通中英文识别,3.0版模型
|
|
49
|
-
* tomatoOcr.setRecType("ch-3.0");
|
|
50
|
-
* // 普通中英文识别,2.0版模型
|
|
51
|
-
* tomatoOcr.setRecType("ch-2.0");
|
|
52
|
-
* // 普通中英文识别,1.0版模型
|
|
53
|
-
* tomatoOcr.setRecType("ch");
|
|
54
|
-
* // 繁体
|
|
55
|
-
* tomatoOcr.setRecType("cht");
|
|
56
|
-
* // 日语
|
|
57
|
-
* tomatoOcr.setRecType("japan");
|
|
58
|
-
* // 韩语
|
|
59
|
-
* tomatoOcr.setRecType("korean");
|
|
60
|
-
* // 数字模型
|
|
61
|
-
* tomatoOcr.setRecType("number");
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
function setRecType(recType: string): void;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 设置检测框类型
|
|
68
|
-
* @param detBoxType 检测框类型 默认"rect": 由于手机上截图文本均为矩形文本;"quad":可准确检测倾斜文本
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* // 矩形文本
|
|
72
|
-
* tomatoOcr.setDetBoxType("rect");
|
|
73
|
-
* // 倾斜文本
|
|
74
|
-
* tomatoOcr.setDetBoxType("quad");
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
function setDetBoxType(detBoxType: string): void;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* 设置检测框展开比例
|
|
81
|
-
* @param detUnclipRatio 设置检测模型框选文本范围大小的参数,非必设置,默认为1.9。值范围1.6-2.5之间,值越大框选范围越大,值越小框选范围越小;当框选到了,但识别得分较低,就可以调整该参数改善准确率。
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* tomatoOcr.setDetUnclipRatio(1.9);
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
function setDetUnclipRatio(detUnclipRatio: number): void;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 设置识别分数阈值
|
|
91
|
-
* @param recScoreThreshold 设置识别模型过滤得分的参数,非必设置,默认0.1。由于返回的识别结果数据太多太乱,可以通过设置该参数,过滤一些得分较低不准的数据,使得结果看起来更加简练。
|
|
92
|
-
* @example
|
|
93
|
-
* ```typescript
|
|
94
|
-
* tomatoOcr.setRecScoreThreshold(0.1);
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
function setRecScoreThreshold(recScoreThreshold: number): void;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* 设置返回类型
|
|
101
|
-
* @param returnType 设置调用插件识别返回格式的参数,非必设置,默认为json。默认"json": 包含得分、坐标和文字;"text":纯文字;"num":纯数字;自定义输入想要返回的文本:".¥1234567890",仅只返回这些内容
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* tomatoOcr.setReturnType("json");
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
function setReturnType(returnType: string): void;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* 设置二值化阈值
|
|
111
|
-
* @param binaryThresh 设置图像二值化的参数,非必设置,默认0,不进行二值化。 二值化设定0-255,常规情况下不需要设置,可配合中调试应用使用。
|
|
112
|
-
* @example
|
|
113
|
-
* ```typescript
|
|
114
|
-
* tomatoOcr.setBinaryThresh(0);
|
|
115
|
-
* ```
|
|
116
|
-
*/
|
|
117
|
-
function setBinaryThresh(binaryThresh: number): void;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* 设置运行模式
|
|
121
|
-
* @param runMode 运行模式
|
|
122
|
-
* @example
|
|
123
|
-
* ```typescript
|
|
124
|
-
* tomatoOcr.setRunMode("fast");
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
function setRunMode(runMode: string): void;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* 设置图像滤色参数,非必设置,默认"",对图片中的文字进行颜色过滤,可以是单色也可以为多色,配合调试工具使用,如下图:
|
|
131
|
-
* @param filterColor 颜色过滤,通过逗号相互连,第一个是颜色值,第二个是负偏色,第三个是正偏色;不同颜色之间以"|"连接
|
|
132
|
-
* @param backgroundColor 滤色后的背景色,传""或black的时候,背景是黑色,传“white”的时候,背景是白色
|
|
133
|
-
* @example
|
|
134
|
-
* ```typescript
|
|
135
|
-
* tomatoOcr.setFilterColor("#41917A,38,38", "black");
|
|
136
|
-
* tomatoOcr.setFilterColor("#41917A,38,38|#E091A8,50,50", "white");
|
|
137
|
-
* ```
|
|
138
|
-
*/
|
|
139
|
-
function setFilterColor(filterColor: string, backgroundColor: string): void;
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* 对图像执行 OCR 识别
|
|
143
|
-
* @param input 输入源(imageId、URL字符串、文件路径或"screen","screen"表示使用当前屏幕)
|
|
144
|
-
* @param type 识别类型 默认3: 检测 + 识别;0: 只检测;1: 方向分类+识别;2: 只识别;3: 检测+识别
|
|
145
|
-
* @param x 边界框左上角x坐标
|
|
146
|
-
* @param y 边界框左上角y坐标
|
|
147
|
-
* @param ex 边界框右下角x坐标
|
|
148
|
-
* @param ey 边界框右下角y坐标
|
|
149
|
-
* @returns OCR识别结果JSON字符串
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* // 识别屏幕
|
|
153
|
-
* const result1 = tomatoOcr.ocrImage("screen", 0, 0, 0, 0, 0);
|
|
154
|
-
* logi(`识别屏幕结果:${result1}`);
|
|
155
|
-
*
|
|
156
|
-
* // 识别文件
|
|
157
|
-
* const result2 = tomatoOcr.ocrImage("/path/to/image.png", 0);
|
|
158
|
-
* logi(`识别文件结果:${result2}`);
|
|
159
|
-
*
|
|
160
|
-
* // 识别指定屏幕区域
|
|
161
|
-
* const result3 = tomatoOcr.ocrImage("screen", 0);
|
|
162
|
-
* logi(`识别指定屏幕区域结果:${result3}`);
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
165
|
-
function ocrImage(
|
|
166
|
-
input: string,
|
|
167
|
-
type: number,
|
|
168
|
-
x?: number,
|
|
169
|
-
y?: number,
|
|
170
|
-
ex?: number,
|
|
171
|
-
ey?: number
|
|
172
|
-
): string;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* 查找点击点
|
|
176
|
-
* @param data 要找的文字
|
|
177
|
-
* @returns 找“要找的文字”的中心点 没有找到返回空字符串
|
|
178
|
-
* @example
|
|
179
|
-
* ```typescript
|
|
180
|
-
* const result = tomatoOcr.findTapPoint('{"text": "确定"}');
|
|
181
|
-
* const tapPoint = JSON.parse(result);
|
|
182
|
-
* logi(tapPoint);
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
function findTapPoint(data: string): string;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* 查找多个点击点
|
|
189
|
-
* @param data 要找的文字
|
|
190
|
-
* @returns 找“要找的文字”的所有相匹配的中心点 没有找到返回空字符串
|
|
191
|
-
* @example
|
|
192
|
-
* ```typescript
|
|
193
|
-
* const result = tomatoOcr.findTapPoints('{"texts": ["确定", "取消"]}');
|
|
194
|
-
* const tapPoints = JSON.parse(result);
|
|
195
|
-
* logi(tapPoints);
|
|
196
|
-
* ```
|
|
197
|
-
*/
|
|
198
|
-
function findTapPoints(data: string): string;
|
|
199
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* TomatoOCR 模块
|
|
3
|
+
* 提供基于 TomatoOCR 框架的文字识别和 YOLO 目标检测功能
|
|
4
|
+
*/
|
|
5
|
+
declare namespace tomatoOcr {
|
|
6
|
+
/**
|
|
7
|
+
* 初始化TomatoOCR并设置基本配置
|
|
8
|
+
* @param mode 运行模式 debug:调试模型;删除或传别的任何值为正式模式
|
|
9
|
+
* @param licenseData 授权码 请传入你在 TomatoOCR 官网申请的授权码
|
|
10
|
+
* @param remark 备注信息(可选)
|
|
11
|
+
* @returns 设置结果
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // 不带备注
|
|
15
|
+
* const result1 = tomatoOcr.initializeWithConfig("online", "授权码");
|
|
16
|
+
* // 带备注
|
|
17
|
+
* const result2 = tomatoOcr.initializeWithConfig("online", "授权码", "测试环境");
|
|
18
|
+
* logi(result1, result2);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function initializeWithConfig(
|
|
22
|
+
mode: string,
|
|
23
|
+
licenseData: string,
|
|
24
|
+
remark?: string
|
|
25
|
+
): {
|
|
26
|
+
deviceId: string;
|
|
27
|
+
expiryTime: string;
|
|
28
|
+
message: string;
|
|
29
|
+
status: string;
|
|
30
|
+
versionName: string;
|
|
31
|
+
} | null;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 设置 HTTP 请求间隔时间
|
|
35
|
+
* @param second 间隔秒数 设置网络请求间隔时间,非必设置。0-86400
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* tomatoOcr.setHttpIntervalTime(3600);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
function setHttpIntervalTime(second: number): void;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 设置识别类型
|
|
45
|
+
* @param recType 识别类型 模型类型,默认 ch-3.0,除此之外还有 ch-2.0, ch, cht, japan, korean, number
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // 普通中英文识别,3.0版模型
|
|
49
|
+
* tomatoOcr.setRecType("ch-3.0");
|
|
50
|
+
* // 普通中英文识别,2.0版模型
|
|
51
|
+
* tomatoOcr.setRecType("ch-2.0");
|
|
52
|
+
* // 普通中英文识别,1.0版模型
|
|
53
|
+
* tomatoOcr.setRecType("ch");
|
|
54
|
+
* // 繁体
|
|
55
|
+
* tomatoOcr.setRecType("cht");
|
|
56
|
+
* // 日语
|
|
57
|
+
* tomatoOcr.setRecType("japan");
|
|
58
|
+
* // 韩语
|
|
59
|
+
* tomatoOcr.setRecType("korean");
|
|
60
|
+
* // 数字模型
|
|
61
|
+
* tomatoOcr.setRecType("number");
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
function setRecType(recType: string): void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 设置检测框类型
|
|
68
|
+
* @param detBoxType 检测框类型 默认"rect": 由于手机上截图文本均为矩形文本;"quad":可准确检测倾斜文本
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* // 矩形文本
|
|
72
|
+
* tomatoOcr.setDetBoxType("rect");
|
|
73
|
+
* // 倾斜文本
|
|
74
|
+
* tomatoOcr.setDetBoxType("quad");
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
function setDetBoxType(detBoxType: string): void;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 设置检测框展开比例
|
|
81
|
+
* @param detUnclipRatio 设置检测模型框选文本范围大小的参数,非必设置,默认为1.9。值范围1.6-2.5之间,值越大框选范围越大,值越小框选范围越小;当框选到了,但识别得分较低,就可以调整该参数改善准确率。
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* tomatoOcr.setDetUnclipRatio(1.9);
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
function setDetUnclipRatio(detUnclipRatio: number): void;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 设置识别分数阈值
|
|
91
|
+
* @param recScoreThreshold 设置识别模型过滤得分的参数,非必设置,默认0.1。由于返回的识别结果数据太多太乱,可以通过设置该参数,过滤一些得分较低不准的数据,使得结果看起来更加简练。
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* tomatoOcr.setRecScoreThreshold(0.1);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
function setRecScoreThreshold(recScoreThreshold: number): void;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 设置返回类型
|
|
101
|
+
* @param returnType 设置调用插件识别返回格式的参数,非必设置,默认为json。默认"json": 包含得分、坐标和文字;"text":纯文字;"num":纯数字;自定义输入想要返回的文本:".¥1234567890",仅只返回这些内容
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* tomatoOcr.setReturnType("json");
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
function setReturnType(returnType: string): void;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 设置二值化阈值
|
|
111
|
+
* @param binaryThresh 设置图像二值化的参数,非必设置,默认0,不进行二值化。 二值化设定0-255,常规情况下不需要设置,可配合中调试应用使用。
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* tomatoOcr.setBinaryThresh(0);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
function setBinaryThresh(binaryThresh: number): void;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 设置运行模式
|
|
121
|
+
* @param runMode 运行模式
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* tomatoOcr.setRunMode("fast");
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
function setRunMode(runMode: string): void;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 设置图像滤色参数,非必设置,默认"",对图片中的文字进行颜色过滤,可以是单色也可以为多色,配合调试工具使用,如下图:
|
|
131
|
+
* @param filterColor 颜色过滤,通过逗号相互连,第一个是颜色值,第二个是负偏色,第三个是正偏色;不同颜色之间以"|"连接
|
|
132
|
+
* @param backgroundColor 滤色后的背景色,传""或black的时候,背景是黑色,传“white”的时候,背景是白色
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* tomatoOcr.setFilterColor("#41917A,38,38", "black");
|
|
136
|
+
* tomatoOcr.setFilterColor("#41917A,38,38|#E091A8,50,50", "white");
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
function setFilterColor(filterColor: string, backgroundColor: string): void;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 对图像执行 OCR 识别
|
|
143
|
+
* @param input 输入源(imageId、URL字符串、文件路径或"screen","screen"表示使用当前屏幕)
|
|
144
|
+
* @param type 识别类型 默认3: 检测 + 识别;0: 只检测;1: 方向分类+识别;2: 只识别;3: 检测+识别
|
|
145
|
+
* @param x 边界框左上角x坐标
|
|
146
|
+
* @param y 边界框左上角y坐标
|
|
147
|
+
* @param ex 边界框右下角x坐标
|
|
148
|
+
* @param ey 边界框右下角y坐标
|
|
149
|
+
* @returns OCR识别结果JSON字符串
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* // 识别屏幕
|
|
153
|
+
* const result1 = tomatoOcr.ocrImage("screen", 0, 0, 0, 0, 0);
|
|
154
|
+
* logi(`识别屏幕结果:${result1}`);
|
|
155
|
+
*
|
|
156
|
+
* // 识别文件
|
|
157
|
+
* const result2 = tomatoOcr.ocrImage("/path/to/image.png", 0);
|
|
158
|
+
* logi(`识别文件结果:${result2}`);
|
|
159
|
+
*
|
|
160
|
+
* // 识别指定屏幕区域
|
|
161
|
+
* const result3 = tomatoOcr.ocrImage("screen", 0);
|
|
162
|
+
* logi(`识别指定屏幕区域结果:${result3}`);
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
function ocrImage(
|
|
166
|
+
input: string,
|
|
167
|
+
type: number,
|
|
168
|
+
x?: number,
|
|
169
|
+
y?: number,
|
|
170
|
+
ex?: number,
|
|
171
|
+
ey?: number
|
|
172
|
+
): string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 查找点击点
|
|
176
|
+
* @param data 要找的文字
|
|
177
|
+
* @returns 找“要找的文字”的中心点 没有找到返回空字符串
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const result = tomatoOcr.findTapPoint('{"text": "确定"}');
|
|
181
|
+
* const tapPoint = JSON.parse(result);
|
|
182
|
+
* logi(tapPoint);
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
function findTapPoint(data: string): string;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* 查找多个点击点
|
|
189
|
+
* @param data 要找的文字
|
|
190
|
+
* @returns 找“要找的文字”的所有相匹配的中心点 没有找到返回空字符串
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* const result = tomatoOcr.findTapPoints('{"texts": ["确定", "取消"]}');
|
|
194
|
+
* const tapPoints = JSON.parse(result);
|
|
195
|
+
* logi(tapPoints);
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
function findTapPoints(data: string): string;
|
|
199
|
+
}
|