ms-vite-plugin 1.1.2 → 1.1.4
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/dist/build.js +6 -0
- package/dist/cli.js +91 -1
- package/dist/mcp/device-config.d.ts +55 -0
- package/dist/mcp/device-config.js +183 -0
- package/dist/mcp/docs-service.d.ts +65 -0
- package/dist/mcp/docs-service.js +168 -0
- package/dist/mcp/project.d.ts +16 -0
- package/dist/mcp/project.js +74 -0
- package/dist/mcp/tools.d.ts +18 -0
- package/dist/mcp/tools.js +825 -0
- package/dist/mcp/types.d.ts +32 -0
- package/dist/mcp/types.js +11 -0
- package/dist/mcp-server.d.ts +2 -0
- package/dist/mcp-server.js +86 -0
- package/dist/project.d.ts +89 -0
- package/dist/project.js +306 -0
- package/dist/version.d.ts +12 -0
- package/dist/version.js +63 -0
- package/docs/api/action.md +922 -0
- package/docs/api/appleocr.md +229 -0
- package/docs/api/config.md +122 -0
- package/docs/api/cryptoUtils.md +232 -0
- package/docs/api/device.md +374 -0
- package/docs/api/file.md +516 -0
- package/docs/api/global.md +617 -0
- package/docs/api/hid.md +1032 -0
- package/docs/api/hotUpdate.md +166 -0
- package/docs/api/http.md +548 -0
- package/docs/api/image.md +907 -0
- package/docs/api/ime.md +290 -0
- package/docs/api/logger.md +324 -0
- package/docs/api/media.md +248 -0
- package/docs/api/mysql.md +441 -0
- package/docs/api/netCard.md +200 -0
- package/docs/api/node.md +353 -0
- package/docs/api/paddleocr.md +246 -0
- package/docs/api/pip.md +242 -0
- package/docs/api/system.md +572 -0
- package/docs/api/thread.md +269 -0
- package/docs/api/tomatoocr.md +425 -0
- package/docs/api/tts.md +334 -0
- package/docs/api/ui.md +947 -0
- package/docs/api/utils.md +265 -0
- package/docs/api/yolo.md +310 -0
- package/docs/apicn/action.md +919 -0
- package/docs/apicn/appleocr.md +233 -0
- package/docs/apicn/config.md +120 -0
- package/docs/apicn/device.md +385 -0
- package/docs/apicn/file.md +511 -0
- package/docs/apicn/global.md +613 -0
- package/docs/apicn/hid.md +1033 -0
- package/docs/apicn/hotUpdate.md +170 -0
- package/docs/apicn/http.md +672 -0
- package/docs/apicn/image.md +924 -0
- package/docs/apicn/ime.md +290 -0
- package/docs/apicn/logger.md +332 -0
- package/docs/apicn/media.md +252 -0
- package/docs/apicn/mysql.md +445 -0
- package/docs/apicn/netCard.md +200 -0
- package/docs/apicn/node.md +362 -0
- package/docs/apicn/paddleocr.md +255 -0
- package/docs/apicn/pip.md +242 -0
- package/docs/apicn/system.md +575 -0
- package/docs/apicn/thread.md +269 -0
- package/docs/apicn/tts.md +338 -0
- package/docs/apicn/ui.md +933 -0
- package/docs/apicn/utils.md +265 -0
- package/docs/apicn/yolo.md +314 -0
- package/docs/apipython/action.md +901 -0
- package/docs/apipython/appleocr.md +226 -0
- package/docs/apipython/config.md +126 -0
- package/docs/apipython/cryptoUtils.md +246 -0
- package/docs/apipython/device.md +365 -0
- package/docs/apipython/file.md +476 -0
- package/docs/apipython/g.md +154 -0
- package/docs/apipython/hid.md +1059 -0
- package/docs/apipython/hotUpdate.md +154 -0
- package/docs/apipython/image.md +938 -0
- package/docs/apipython/ime.md +306 -0
- package/docs/apipython/logger.md +330 -0
- package/docs/apipython/media.md +221 -0
- package/docs/apipython/mysql.md +432 -0
- package/docs/apipython/netCard.md +219 -0
- package/docs/apipython/node.md +331 -0
- package/docs/apipython/overview.md +66 -0
- package/docs/apipython/paddleocr.md +211 -0
- package/docs/apipython/pip.md +231 -0
- package/docs/apipython/system.md +458 -0
- package/docs/apipython/tomatoocr.md +444 -0
- package/docs/apipython/tts.md +331 -0
- package/docs/apipython/ui.md +949 -0
- package/docs/apipython/utils.md +284 -0
- package/docs/apipython/yolo.md +281 -0
- package/package.json +8 -4
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
# TomatoOCR 模块
|
|
2
|
+
|
|
3
|
+
TomatoOCR 模块提供基于 TomatoOCR 框架的文字识别和 YOLO 目标检测功能,支持多种识别模式和配置选项。
|
|
4
|
+
|
|
5
|
+
该 ocr 为付费插件, 具体资费请联系https://www.52tomato.com, 如果购买请选择插件版-快点 JS-IOS
|
|
6
|
+
|
|
7
|
+
## 功能概览
|
|
8
|
+
|
|
9
|
+
- 文字识别:支持多语言文字识别,包括中文、英文、数字、繁体、日语、韩语等
|
|
10
|
+
- 多种输入源:支持屏幕截图、文件路径、图像 ID 等多种输入方式
|
|
11
|
+
- 灵活配置:提供丰富的参数配置选项
|
|
12
|
+
- 点击点查找:根据文字内容查找可点击的位置
|
|
13
|
+
|
|
14
|
+
## API 参考
|
|
15
|
+
|
|
16
|
+
### 初始化方法
|
|
17
|
+
|
|
18
|
+
#### TomatoInitResult
|
|
19
|
+
|
|
20
|
+
初始化结果结构。
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from typing import TypedDict, Optional
|
|
24
|
+
|
|
25
|
+
class TomatoInitResult(TypedDict):
|
|
26
|
+
deviceId: str # 设备 ID
|
|
27
|
+
expiryTime: str # 过期时间
|
|
28
|
+
message: str # 消息
|
|
29
|
+
status: str # 状态
|
|
30
|
+
versionName: str # 版本名称
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### `initializeWithConfig`
|
|
34
|
+
|
|
35
|
+
初始化 TomatoOCR 引擎并设置基本配置。
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
def initializeWithConfig(
|
|
39
|
+
mode: str,
|
|
40
|
+
licenseData: str,
|
|
41
|
+
remark: str = ""
|
|
42
|
+
) -> Optional[TomatoInitResult]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**参数:**
|
|
46
|
+
|
|
47
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
48
|
+
| ------------- | ---- | -------- | ------ | -------------------------------------------------------------------- |
|
|
49
|
+
| `mode` | str | 是 | | 运行模式,`debug`:调试模型;删除或传别的任何值为正式模式 |
|
|
50
|
+
| `licenseData` | str | 是 | | 授权码,请传入你在 TomatoOCR 官网申请的授权码,购买依赖版-IOS 后获取 |
|
|
51
|
+
| `remark` | str | 否 | | 备注信息 |
|
|
52
|
+
|
|
53
|
+
**返回值:**
|
|
54
|
+
|
|
55
|
+
- 成功时返回包含设备信息的对象,失败时返回 `None`
|
|
56
|
+
|
|
57
|
+
| 类型 | 描述 |
|
|
58
|
+
| ------------------ | -------------- |
|
|
59
|
+
| `TomatoInitResult` | 初始化结果对象 |
|
|
60
|
+
|
|
61
|
+
**示例:**
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from kuaijs import tomatoocr
|
|
65
|
+
|
|
66
|
+
# 不带备注
|
|
67
|
+
result1 = tomatoocr.initializeWithConfig(
|
|
68
|
+
"online",
|
|
69
|
+
"请传入你在 TomatoOCR 官网申请的授权码"
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# 带备注
|
|
73
|
+
result2 = tomatoocr.initializeWithConfig(
|
|
74
|
+
"online",
|
|
75
|
+
"请传入你在 TomatoOCR 官网申请的授权码",
|
|
76
|
+
"测试环境"
|
|
77
|
+
)
|
|
78
|
+
if result1:
|
|
79
|
+
print(f"设备ID: {result1.deviceId}")
|
|
80
|
+
print(f"过期时间: {result1.expiryTime}")
|
|
81
|
+
print(f"版本: {result1.versionName}")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 配置方法
|
|
85
|
+
|
|
86
|
+
#### `setHttpIntervalTime`
|
|
87
|
+
|
|
88
|
+
设置 HTTP 请求间隔时间。
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
def setHttpIntervalTime(second: float) -> None
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**参数:**
|
|
95
|
+
|
|
96
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
97
|
+
| -------- | ----- | -------- | ------ | ------------------------------------------------- |
|
|
98
|
+
| `second` | float | 是 | | 间隔秒数,设置网络请求间隔时间,非必设置。0-86400 |
|
|
99
|
+
|
|
100
|
+
**示例:**
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from kuaijs import tomatoocr
|
|
104
|
+
tomatoocr.setHttpIntervalTime(3600.0)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### `setRecType`
|
|
108
|
+
|
|
109
|
+
设置识别类型。
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
def setRecType(recType: str) -> None
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**参数:**
|
|
116
|
+
|
|
117
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
118
|
+
| --------- | ---- | -------- | ------ | -------------------------------------------------------------------------------------------------- |
|
|
119
|
+
| `recType` | str | 是 | | 识别类型,模型类型,默认 `ch-3.0`;除此之外还有 `ch-2.0`、`ch`、`cht`、`japan`、`korean`、`number` |
|
|
120
|
+
|
|
121
|
+
**示例:**
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from kuaijs import tomatoocr
|
|
125
|
+
tomatoocr.setRecType("ch-3.0")
|
|
126
|
+
tomatoocr.setRecType("ch-2.0")
|
|
127
|
+
tomatoocr.setRecType("ch")
|
|
128
|
+
tomatoocr.setRecType("cht")
|
|
129
|
+
tomatoocr.setRecType("japan")
|
|
130
|
+
tomatoocr.setRecType("korean")
|
|
131
|
+
tomatoocr.setRecType("number")
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### `setDetBoxType`
|
|
135
|
+
|
|
136
|
+
设置检测框类型。
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
def setDetBoxType(detBoxType: str) -> None
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**参数:**
|
|
143
|
+
|
|
144
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
145
|
+
| ------------ | ---- | -------- | ------ | ----------------------------------------------------------------------------------- |
|
|
146
|
+
| `detBoxType` | str | 是 | | 检测框类型,默认 `rect`:由于手机上截图文本均为矩形文本;`quad`:可准确检测倾斜文本 |
|
|
147
|
+
|
|
148
|
+
**示例:**
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from kuaijs import tomatoocr
|
|
152
|
+
tomatoocr.setDetBoxType("rect")
|
|
153
|
+
tomatoocr.setDetBoxType("quad")
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### `setDetScaleRatio`
|
|
157
|
+
|
|
158
|
+
设置输入图片缩放大小的参数,非必设置,默认为 1.0。值范围 0.1-10.0 之间,如果图太小,可能出现检测不到的情况,则尝试放大图片,如设置 2.0;如果图太大,可能出现检测不到一起的情况,则尝试缩小图片,如设置 0.5
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
def setDetScaleRatio(detScaleRatio: float) -> None
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**参数:**
|
|
165
|
+
|
|
166
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
167
|
+
| --------------- | ----- | -------- | ------ | -------------- |
|
|
168
|
+
| `detScaleRatio` | float | 是 | | 检测框缩放比例 |
|
|
169
|
+
|
|
170
|
+
**示例:**
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from kuaijs import tomatoocr
|
|
174
|
+
tomatoocr.setDetScaleRatio(0.5)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### `setDetUnclipRatio`
|
|
178
|
+
|
|
179
|
+
设置检测框展开比例。
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
def setDetUnclipRatio(detUnclipRatio: float) -> None
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**参数:**
|
|
186
|
+
|
|
187
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
188
|
+
| ---------------- | ----- | -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
189
|
+
| `detUnclipRatio` | float | 是 | 1.9 | 设置检测模型框选文本范围大小的参数,非必设置,默认为 1.9。值范围 1.6-2.5 之间,值越大框选范围越大,值越小框选范围越小;当框选到了,但识别得分较低,就可以调整该参数改善准确率。 |
|
|
190
|
+
|
|
191
|
+
**示例:**
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
from kuaijs import tomatoocr
|
|
195
|
+
tomatoocr.setDetUnclipRatio(1.9)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### `setRecScoreThreshold`
|
|
199
|
+
|
|
200
|
+
设置识别分数阈值。
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
def setRecScoreThreshold(recScoreThreshold: float) -> None
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**参数:**
|
|
207
|
+
|
|
208
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
209
|
+
| ------------------- | ----- | -------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
210
|
+
| `recScoreThreshold` | float | 是 | 0.1 | 设置识别模型过滤得分的参数,非必设置,默认 0.1。由于返回的识别结果数据太多太乱,可以通过设置该参数,过滤一些得分较低不准的数据,使得结果看起来更加简练。 |
|
|
211
|
+
|
|
212
|
+
**示例:**
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
from kuaijs import tomatoocr
|
|
216
|
+
tomatoocr.setRecScoreThreshold(0.1)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### `setReturnType`
|
|
220
|
+
|
|
221
|
+
设置返回类型。
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
def setReturnType(returnType: str) -> None
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**参数:**
|
|
228
|
+
|
|
229
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
230
|
+
| ------------ | ---- | -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
231
|
+
| `returnType` | str | 是 | json | 设置调用插件识别返回格式的参数,非必设置,默认为 `json`。`json`:包含得分、坐标和文字;`text`:纯文字;`num`:纯数字;自定义输入想要返回的文本,如 `".¥ 1234567890"`,仅返回这些内容 |
|
|
232
|
+
|
|
233
|
+
**示例:**
|
|
234
|
+
|
|
235
|
+
```python
|
|
236
|
+
from kuaijs import tomatoocr
|
|
237
|
+
tomatoocr.setReturnType("json")
|
|
238
|
+
tomatoocr.setReturnType("text")
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
#### `setBinaryThresh`
|
|
242
|
+
|
|
243
|
+
设置二值化阈值。
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
def setBinaryThresh(binaryThresh: float) -> None
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**参数:**
|
|
250
|
+
|
|
251
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
252
|
+
| -------------- | ----- | -------- | ------ | -------------------------------------------------------------------------------------------------------------------- |
|
|
253
|
+
| `binaryThresh` | float | 是 | 0 | 设置图像二值化的参数,非必设置,默认 0,不进行二值化。二值化设定 0-255,常规情况下不需要设置,可配合中调试应用使用。 |
|
|
254
|
+
|
|
255
|
+
**示例:**
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
from kuaijs import tomatoocr
|
|
259
|
+
tomatoocr.setBinaryThresh(0)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### `setRunMode`
|
|
263
|
+
|
|
264
|
+
设置运行模式。
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
def setRunMode(runMode: str) -> None
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**参数:**
|
|
271
|
+
|
|
272
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
273
|
+
| --------- | ---- | -------- | ------ | ----------------------------------------------------- |
|
|
274
|
+
| `runMode` | str | 是 | fast | 运行模式,默认 `fast`:快速模式;`accurate`:准确模式 |
|
|
275
|
+
|
|
276
|
+
**示例:**
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
from kuaijs import tomatoocr
|
|
280
|
+
tomatoocr.setRunMode("fast")
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### `setFilterColor`
|
|
284
|
+
|
|
285
|
+
设置图像滤色参数。
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
def setFilterColor(filterColor: str, backgroundColor: str) -> None
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**参数:**
|
|
292
|
+
|
|
293
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
294
|
+
| ----------------- | ---- | -------- | ------ | -------------------------------------------------------------------------------------------------- |
|
|
295
|
+
| `filterColor` | str | 是 | | 颜色过滤,通过逗号相互连,第一个是颜色值,第二个是负偏色,第三个是正偏色;不同颜色之间以 `\|` 连接 |
|
|
296
|
+
| `backgroundColor` | str | 是 | | 滤色后的背景色,传 `""` 或 `"black"` 的时候,背景是黑色,传 `"white"` 的时候,背景是白色 |
|
|
297
|
+
|
|
298
|
+
**示例:**
|
|
299
|
+
|
|
300
|
+
```python
|
|
301
|
+
from kuaijs import tomatoocr
|
|
302
|
+
tomatoocr.setFilterColor("#41917A,38,38", "black")
|
|
303
|
+
tomatoocr.setFilterColor("#41917A,38,38|#E091A8,50,50", "white")
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### OCR 识别方法
|
|
307
|
+
|
|
308
|
+
#### `ocrImage`
|
|
309
|
+
|
|
310
|
+
对图像执行 OCR 识别。
|
|
311
|
+
|
|
312
|
+
```python
|
|
313
|
+
def ocrImage(
|
|
314
|
+
input: str,
|
|
315
|
+
type: int = 3,
|
|
316
|
+
x: int = 0,
|
|
317
|
+
y: int = 0,
|
|
318
|
+
ex: int = 0,
|
|
319
|
+
ey: int = 0
|
|
320
|
+
) -> str
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
**参数:**
|
|
324
|
+
|
|
325
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
326
|
+
| ------- | ---- | -------- | ------ | --------------------------------------------------------------------------------------- |
|
|
327
|
+
| `input` | str | 是 | | 输入源(`imageId`、URL 字符串、文件路径或 `"screen"`) |
|
|
328
|
+
| `type` | int | 是 | 3 | 识别类型,默认 3:检测 + 识别;0:只检测;1:方向分类 + 识别;2:只识别;3:检测 + 识别 |
|
|
329
|
+
| `x` | int | 是 | 0 | 边界框左上角 x 坐标 |
|
|
330
|
+
| `y` | int | 是 | 0 | 边界框左上角 y 坐标 |
|
|
331
|
+
| `ex` | int | 是 | 0 | 边界框右下角 x 坐标 |
|
|
332
|
+
| `ey` | int | 是 | 0 | 边界框右下角 y 坐标 |
|
|
333
|
+
|
|
334
|
+
**返回值:**
|
|
335
|
+
|
|
336
|
+
| 类型 | 描述 |
|
|
337
|
+
| ----- | ------------------------ |
|
|
338
|
+
| `str` | OCR 识别结果 JSON 字符串 |
|
|
339
|
+
|
|
340
|
+
**示例:**
|
|
341
|
+
|
|
342
|
+
```python
|
|
343
|
+
from kuaijs import tomatoocr
|
|
344
|
+
|
|
345
|
+
# 识别屏幕
|
|
346
|
+
result1 = tomatoocr.ocrImage("screen", 3, 0, 0, 0, 0)
|
|
347
|
+
print(f"识别屏幕结果:{result1}")
|
|
348
|
+
|
|
349
|
+
# 识别文件
|
|
350
|
+
result2 = tomatoocr.ocrImage("/path/to/image.png", 3, 0, 0, 0, 0)
|
|
351
|
+
print(f"识别文件结果:{result2}")
|
|
352
|
+
|
|
353
|
+
# 识别指定屏幕区域
|
|
354
|
+
result3 = tomatoocr.ocrImage("screen", 3, 0, 100, 500, 300)
|
|
355
|
+
print(f"识别指定屏幕区域结果:{result3}")
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### 点击点查找方法
|
|
359
|
+
|
|
360
|
+
#### `findTapPoint`
|
|
361
|
+
|
|
362
|
+
查找点击点。
|
|
363
|
+
|
|
364
|
+
```python
|
|
365
|
+
def findTapPoint(data: str) -> str
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
**参数:**
|
|
369
|
+
|
|
370
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
371
|
+
| ------ | ---- | -------- | ------ | ---------- |
|
|
372
|
+
| `data` | str | 是 | | 要找的文字 |
|
|
373
|
+
|
|
374
|
+
**返回值:**
|
|
375
|
+
|
|
376
|
+
| 类型 | 描述 |
|
|
377
|
+
| ----- | ------------------------------------------ |
|
|
378
|
+
| `str` | 找“要找的文字”的中心点,未找到返回空字符串 |
|
|
379
|
+
|
|
380
|
+
**示例:**
|
|
381
|
+
|
|
382
|
+
```python
|
|
383
|
+
from kuaijs import tomatoocr
|
|
384
|
+
result = tomatoocr.findTapPoint("确定")
|
|
385
|
+
print(result)
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
#### `findTapPoints`
|
|
389
|
+
|
|
390
|
+
查找多个点击点。
|
|
391
|
+
|
|
392
|
+
```python
|
|
393
|
+
def findTapPoints(data: str) -> str
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
**参数:**
|
|
397
|
+
|
|
398
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
399
|
+
| ------ | ---- | -------- | ------ | ---------- |
|
|
400
|
+
| `data` | str | 是 | | 要找的文字 |
|
|
401
|
+
|
|
402
|
+
**返回值:**
|
|
403
|
+
|
|
404
|
+
| 类型 | 描述 |
|
|
405
|
+
| ----- | ------------------------------------------------------ |
|
|
406
|
+
| `str` | 找“要找的文字”的所有相匹配的中心点,未找到返回空字符串 |
|
|
407
|
+
|
|
408
|
+
**示例:**
|
|
409
|
+
|
|
410
|
+
```python
|
|
411
|
+
from kuaijs import tomatoocr
|
|
412
|
+
result = tomatoocr.findTapPoints("确定")
|
|
413
|
+
print(result)
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
## 完整示例
|
|
417
|
+
|
|
418
|
+
```python
|
|
419
|
+
from kuaijs import tomatoocr
|
|
420
|
+
|
|
421
|
+
# 初始化 TomatoOCR 并设置基本配置
|
|
422
|
+
init_result = tomatoocr.initializeWithConfig(
|
|
423
|
+
"online",
|
|
424
|
+
"请传入你在 TomatoOCR 官网申请的授权码",
|
|
425
|
+
"测试环境" # 可选备注
|
|
426
|
+
)
|
|
427
|
+
print("初始化结果:" + str(init_result))
|
|
428
|
+
|
|
429
|
+
# 配置其他参数
|
|
430
|
+
tomatoocr.setRecType("ch-3.0")
|
|
431
|
+
|
|
432
|
+
# 执行 OCR 识别(识别当前屏幕)
|
|
433
|
+
ocr_result = tomatoocr.ocrImage("screen", 3, 0, 0, 0, 0)
|
|
434
|
+
print("识别结果:" + ocr_result)
|
|
435
|
+
|
|
436
|
+
# 查找点击点
|
|
437
|
+
tap_result = tomatoocr.findTapPoint("登录")
|
|
438
|
+
print("点击点坐标:" + tap_result)
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## 注意事项
|
|
442
|
+
|
|
443
|
+
- 参数配置:根据实际需求调整各种阈值和配置参数
|
|
444
|
+
- 错误处理:建议对返回的 JSON 结果进行错误检查
|