ms-vite-plugin 1.4.16 → 1.4.18
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/cli.js +6 -301
- package/dist/mcp/doc-tools.js +1 -119
- package/dist/mcp/docs-service.d.ts +1 -27
- package/dist/mcp/docs-service.js +0 -65
- package/dist/mcp/httpapi-docs-service.d.ts +4 -37
- package/dist/mcp/httpapi-docs-service.js +6 -83
- package/dist/mcp/httpapi-tools.d.ts +1 -1
- package/dist/mcp/httpapi-tools.js +7 -157
- package/dist/mcp/tool-utils.d.ts +0 -13
- package/dist/mcp/tool-utils.js +0 -21
- package/dist/mcp/types.d.ts +0 -13
- package/docs/AGENTS.md +24 -32
- package/docs/SKILL.md +26 -37
- package/docs/api/appleocr.md +46 -164
- package/docs/api/image.md +16 -84
- package/docs/api/media.md +6 -7
- package/docs/api/paddleocr.md +77 -123
- package/docs/api/yolo.md +52 -96
- package/docs/apicn/appleocr.md +47 -169
- package/docs/apicn/image.md +15 -81
- package/docs/apicn/media.md +6 -7
- package/docs/apicn/paddleocr.md +77 -130
- package/docs/apicn/yolo.md +52 -101
- package/docs/apipython/appleocr.md +45 -155
- package/docs/apipython/image.md +17 -77
- package/docs/apipython/media.md +7 -8
- package/docs/apipython/paddleocr.md +78 -104
- package/docs/apipython/yolo.md +36 -85
- package/docs/mcp-agent-description.md +32 -58
- package/package.json +1 -1
|
@@ -61,84 +61,37 @@ class OCRResult(TypedDict):
|
|
|
61
61
|
|
|
62
62
|
### 文字识别
|
|
63
63
|
|
|
64
|
-
####
|
|
64
|
+
#### `recognizeAbs` - 执行 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。
|
|
67
67
|
|
|
68
68
|
```python
|
|
69
|
-
def
|
|
69
|
+
def recognizeAbs(
|
|
70
70
|
input: str,
|
|
71
71
|
x: int = 0,
|
|
72
72
|
y: int = 0,
|
|
73
73
|
ex: int = 0,
|
|
74
74
|
ey: int = 0,
|
|
75
|
-
languages: Optional[List[str]] =
|
|
75
|
+
languages: Optional[List[str]] = None
|
|
76
76
|
) -> List[OCRResult]
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
**参数:**
|
|
80
80
|
|
|
81
|
-
| 参数名 | 类型
|
|
82
|
-
| ----------- |
|
|
83
|
-
| `input` | str
|
|
84
|
-
| `x` | int
|
|
85
|
-
| `y` | int
|
|
86
|
-
| `ex` | int
|
|
87
|
-
| `ey` | int
|
|
88
|
-
| `languages` | List[str] | 否 |
|
|
81
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
82
|
+
| ----------- | ------------------- | -------- | ----------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
83
|
+
| `input` | str | 是 | | 输入源,支持 `"screen"`、图片文件路径、URL 字符串或 imageId |
|
|
84
|
+
| `x` | int | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
|
|
85
|
+
| `y` | int | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
|
|
86
|
+
| `ex` | int | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
|
|
87
|
+
| `ey` | int | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
|
|
88
|
+
| `languages` | Optional[List[str]] | 否 | None | 识别语言数组;传 None 时使用 `["zh-Hans", "en-US"]` |
|
|
89
89
|
|
|
90
90
|
**返回值:**
|
|
91
91
|
|
|
92
|
-
| 类型 | 描述
|
|
93
|
-
| ----------------- |
|
|
94
|
-
| `List[OCRResult]` |
|
|
95
|
-
|
|
96
|
-
**使用示例:**
|
|
97
|
-
|
|
98
|
-
```python
|
|
99
|
-
from kuaijs import appleocr
|
|
100
|
-
|
|
101
|
-
# 识别整个屏幕
|
|
102
|
-
full_screen_results = appleocr.recognize("screen", 0, 0, 0, 0)
|
|
103
|
-
print(f"识别到 {len(full_screen_results)} 个文本区域")
|
|
104
|
-
for i, result in enumerate(full_screen_results):
|
|
105
|
-
print(f"文本 {i + 1}: {result.text} (置信度: {result.confidence})")
|
|
106
|
-
print(f"位置: ({result.x}, {result.y}) - ({result.ex}, {result.ey})")
|
|
107
|
-
print(f"中心点: ({result.centerX}, {result.centerY})")
|
|
108
|
-
|
|
109
|
-
# 识别屏幕指定区域
|
|
110
|
-
region_results = appleocr.recognize("screen", 100, 100, 500, 300)
|
|
111
|
-
print(f"指定区域识别结果: {region_results}")
|
|
112
|
-
|
|
113
|
-
# 识别图片文件
|
|
114
|
-
image_results = appleocr.recognize("/path/to/image.png", 0, 0, 800, 600)
|
|
115
|
-
if image_results:
|
|
116
|
-
print("图片文字识别成功")
|
|
117
|
-
for result in image_results:
|
|
118
|
-
print(f"识别文字: {result.text}")
|
|
119
|
-
print(f"区域: {result.width}x{result.height}")
|
|
120
|
-
else:
|
|
121
|
-
print("图片中未识别到文字")
|
|
122
|
-
|
|
123
|
-
# 指定识别语言
|
|
124
|
-
chinese_results = appleocr.recognize("screen", 0, 0, 1920, 1080, ["zh-Hans", "en-US"])
|
|
125
|
-
print(f"中英文识别结果: {chinese_results}")
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
#### `recognizeAbs` - 执行 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标
|
|
129
|
-
|
|
130
|
-
参数与 `recognize` 相同。传入裁剪区域时,返回坐标可直接用于全屏点击。
|
|
131
|
-
|
|
132
|
-
```python
|
|
133
|
-
def recognizeAbs(
|
|
134
|
-
input: str,
|
|
135
|
-
x: int = 0,
|
|
136
|
-
y: int = 0,
|
|
137
|
-
ex: int = 0,
|
|
138
|
-
ey: int = 0,
|
|
139
|
-
languages: Optional[List[str]] = None
|
|
140
|
-
) -> List[OCRResult]
|
|
141
|
-
```
|
|
92
|
+
| 类型 | 描述 |
|
|
93
|
+
| ----------------- | ------------------------------------------------ |
|
|
94
|
+
| `List[OCRResult]` | 识别结果数组,坐标为原图或全屏绝对坐标 |
|
|
142
95
|
|
|
143
96
|
**示例:**
|
|
144
97
|
|
|
@@ -152,14 +105,14 @@ if abs_results:
|
|
|
152
105
|
|
|
153
106
|
### 数字识别
|
|
154
107
|
|
|
155
|
-
####
|
|
108
|
+
#### `recognizeNumbersAbs` - 执行数字 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标
|
|
156
109
|
|
|
157
|
-
|
|
110
|
+
传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。
|
|
158
111
|
|
|
159
112
|
**支持字符**: 0-9 数字、逗号(,)、小数点(.)、加号(+)、减号(-)
|
|
160
113
|
|
|
161
114
|
```python
|
|
162
|
-
def
|
|
115
|
+
def recognizeNumbersAbs(
|
|
163
116
|
input: str,
|
|
164
117
|
x: int = 0,
|
|
165
118
|
y: int = 0,
|
|
@@ -170,48 +123,19 @@ def recognizeNumbers(
|
|
|
170
123
|
|
|
171
124
|
**参数:**
|
|
172
125
|
|
|
173
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述
|
|
174
|
-
| ------- | ---- | -------- | ------ |
|
|
175
|
-
| `input` | str | 是 |
|
|
176
|
-
| `x` | int | 否 | 0 |
|
|
177
|
-
| `y` | int | 否 | 0 |
|
|
178
|
-
| `ex` | int | 否 | 0 |
|
|
179
|
-
| `ey` | int | 否 | 0 |
|
|
126
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
127
|
+
| ------- | ---- | -------- | ------ | --------------------------------------------------- |
|
|
128
|
+
| `input` | str | 是 | | 输入源,支持 `"screen"`、图片文件路径、URL 字符串或 imageId |
|
|
129
|
+
| `x` | int | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
|
|
130
|
+
| `y` | int | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
|
|
131
|
+
| `ex` | int | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
|
|
132
|
+
| `ey` | int | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
|
|
180
133
|
|
|
181
134
|
**返回值:**
|
|
182
135
|
|
|
183
|
-
| 类型 | 描述
|
|
184
|
-
| ----------------- |
|
|
185
|
-
| `List[OCRResult]` |
|
|
186
|
-
|
|
187
|
-
**使用示例:**
|
|
188
|
-
|
|
189
|
-
```python
|
|
190
|
-
from kuaijs import appleocr
|
|
191
|
-
|
|
192
|
-
# 识别屏幕中的数字
|
|
193
|
-
number_results = appleocr.recognizeNumbers("screen", 100, 100, 500, 300)
|
|
194
|
-
print(f"识别到 {len(number_results)} 个数字区域")
|
|
195
|
-
|
|
196
|
-
for i, result in enumerate(number_results):
|
|
197
|
-
print(f"数字 {i + 1}: {result.text}")
|
|
198
|
-
print(f"置信度: {result.confidence}")
|
|
199
|
-
print(f"位置: ({result.centerX}, {result.centerY})")
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
#### `recognizeNumbersAbs` - 执行数字 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标
|
|
203
|
-
|
|
204
|
-
参数与 `recognizeNumbers` 相同。传入裁剪区域时,返回坐标可直接用于全屏点击。
|
|
205
|
-
|
|
206
|
-
```python
|
|
207
|
-
def recognizeNumbersAbs(
|
|
208
|
-
input: str,
|
|
209
|
-
x: int = 0,
|
|
210
|
-
y: int = 0,
|
|
211
|
-
ex: int = 0,
|
|
212
|
-
ey: int = 0
|
|
213
|
-
) -> List[OCRResult]
|
|
214
|
-
```
|
|
136
|
+
| 类型 | 描述 |
|
|
137
|
+
| ----------------- | ---------------------------------------------------------- |
|
|
138
|
+
| `List[OCRResult]` | 数字识别结果数组,坐标为原图或全屏绝对坐标 |
|
|
215
139
|
|
|
216
140
|
**示例:**
|
|
217
141
|
|
|
@@ -225,75 +149,41 @@ if abs_number_results:
|
|
|
225
149
|
|
|
226
150
|
### 文本查找
|
|
227
151
|
|
|
228
|
-
####
|
|
152
|
+
#### `findTextAbs` - 查找目标子串,并将子串结果坐标映射为原图/全屏绝对坐标
|
|
229
153
|
|
|
230
|
-
|
|
154
|
+
传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。
|
|
231
155
|
|
|
232
156
|
```python
|
|
233
|
-
def
|
|
157
|
+
def findTextAbs(
|
|
234
158
|
input: str,
|
|
235
159
|
texts: List[str],
|
|
236
160
|
x: int = 0,
|
|
237
161
|
y: int = 0,
|
|
238
162
|
ex: int = 0,
|
|
239
163
|
ey: int = 0,
|
|
240
|
-
languages: Optional[List[str]] =
|
|
164
|
+
languages: Optional[List[str]] = None,
|
|
241
165
|
exactMatch: bool = False
|
|
242
166
|
) -> List[OCRResult]
|
|
243
167
|
```
|
|
244
168
|
|
|
245
169
|
**参数:**
|
|
246
170
|
|
|
247
|
-
| 参数名
|
|
248
|
-
|
|
|
249
|
-
| `input`
|
|
250
|
-
| `texts`
|
|
251
|
-
| `x`
|
|
252
|
-
| `y`
|
|
253
|
-
| `ex`
|
|
254
|
-
| `ey`
|
|
255
|
-
| `languages`
|
|
256
|
-
| `exactMatch` | bool
|
|
171
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
172
|
+
| ------------ | ------------------- | -------- | ------ | --------------------------------------------------------------------------------------------- |
|
|
173
|
+
| `input` | str | 是 | | 输入源,支持 `"screen"`、图片文件路径、URL 字符串或 imageId |
|
|
174
|
+
| `texts` | List[str] | 是 | | 要查找的目标文本数组,可匹配识别结果中的子串 |
|
|
175
|
+
| `x` | int | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
|
|
176
|
+
| `y` | int | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
|
|
177
|
+
| `ex` | int | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
|
|
178
|
+
| `ey` | int | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
|
|
179
|
+
| `languages` | Optional[List[str]] | 否 | None | 识别语言数组;传 None 时使用 `["zh-Hans", "en-US"]` |
|
|
180
|
+
| `exactMatch` | bool | 否 | False | 是否完整匹配;`False` 表示包含匹配,`True` 要求整条 OCR 识别结果文本等于目标文本 |
|
|
257
181
|
|
|
258
182
|
**返回值:**
|
|
259
183
|
|
|
260
|
-
| 类型 | 描述
|
|
261
|
-
| ----------------- |
|
|
262
|
-
| `List[OCRResult]` |
|
|
263
|
-
|
|
264
|
-
**使用示例:**
|
|
265
|
-
|
|
266
|
-
```python
|
|
267
|
-
from kuaijs import appleocr
|
|
268
|
-
|
|
269
|
-
# 在“开始执行”中查找“开始”,返回“开始”子串区域
|
|
270
|
-
text_results = appleocr.findText("screen", ["开始"], 0, 0, 100, 100)
|
|
271
|
-
# 启用完整匹配时,只有整条 OCR 识别结果文本等于“开始”才返回结果
|
|
272
|
-
exact_results = appleocr.findText("screen", ["开始"], 0, 0, 100, 100, None, True)
|
|
273
|
-
print(f"识别到 {len(text_results)} 个文本区域")
|
|
274
|
-
|
|
275
|
-
for i, result in enumerate(text_results):
|
|
276
|
-
print(f"文本 {i + 1}: {result.text} (置信度: {result.confidence})")
|
|
277
|
-
print(f"位置: ({result.x}, {result.y}) - ({result.ex}, {result.ey})")
|
|
278
|
-
print(f"中心点: ({result.centerX}, {result.centerY})")
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
#### `findTextAbs` - 查找目标子串,并将子串结果坐标映射为原图/全屏绝对坐标
|
|
282
|
-
|
|
283
|
-
参数与 `findText` 相同。传入裁剪区域时,返回坐标可直接用于全屏点击。
|
|
284
|
-
|
|
285
|
-
```python
|
|
286
|
-
def findTextAbs(
|
|
287
|
-
input: str,
|
|
288
|
-
texts: List[str],
|
|
289
|
-
x: int = 0,
|
|
290
|
-
y: int = 0,
|
|
291
|
-
ex: int = 0,
|
|
292
|
-
ey: int = 0,
|
|
293
|
-
languages: Optional[List[str]] = None,
|
|
294
|
-
exactMatch: bool = False
|
|
295
|
-
) -> List[OCRResult]
|
|
296
|
-
```
|
|
184
|
+
| 类型 | 描述 |
|
|
185
|
+
| ----------------- | ---------------------------------------------------------- |
|
|
186
|
+
| `List[OCRResult]` | 命中子串的识别结果数组,坐标为原图或全屏绝对坐标 |
|
|
297
187
|
|
|
298
188
|
**示例:**
|
|
299
189
|
|
package/docs/apipython/image.md
CHANGED
|
@@ -40,7 +40,7 @@ def captureScreen(x: Optional[int] = 0, y: Optional[int] = 0, ex: Optional[int]
|
|
|
40
40
|
**示例:**
|
|
41
41
|
|
|
42
42
|
```python
|
|
43
|
-
#
|
|
43
|
+
# 全屏截图
|
|
44
44
|
imageId = image.captureScreen()
|
|
45
45
|
# 获取手机文档目录
|
|
46
46
|
dir = file.getInternalDir("documents")
|
|
@@ -63,66 +63,6 @@ else:
|
|
|
63
63
|
print("截图失败")
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
### captureFullScreen - 截取设备全屏。
|
|
67
|
-
|
|
68
|
-
```python
|
|
69
|
-
def captureFullScreen() -> Optional[str]
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
**返回值:**
|
|
73
|
-
|
|
74
|
-
| 类型 | 描述 |
|
|
75
|
-
| ------------- | -------------------------------- |
|
|
76
|
-
| `str \| None` | 截图的图片 ID,失败时返回 `None` |
|
|
77
|
-
|
|
78
|
-
**示例:**
|
|
79
|
-
|
|
80
|
-
```python
|
|
81
|
-
from kuaijs import image, file
|
|
82
|
-
|
|
83
|
-
imageId = image.captureFullScreen()
|
|
84
|
-
# 获取手机文档目录
|
|
85
|
-
dir_path = file.getInternalDir("documents")
|
|
86
|
-
if imageId:
|
|
87
|
-
print("截图成功")
|
|
88
|
-
image.saveTo(imageId, f"{dir_path}/screenshot.jpg")
|
|
89
|
-
image.release(imageId) # 记得释放内存
|
|
90
|
-
else:
|
|
91
|
-
print("截图失败")
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### captureRect - 截取设备指定区域。
|
|
95
|
-
|
|
96
|
-
```python
|
|
97
|
-
def captureRect(x: int, y: int, ex: int, ey: int) -> Optional[str]
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**参数:**
|
|
101
|
-
|
|
102
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
103
|
-
| ----------- | ---- | -------- | ------ | -------------- |
|
|
104
|
-
| `x,y,ex,ey` | int | 是 | <br /> | 左上与右下坐标 |
|
|
105
|
-
|
|
106
|
-
**返回值:**
|
|
107
|
-
|
|
108
|
-
| 类型 | 描述 |
|
|
109
|
-
| ------------- | -------------------------------- |
|
|
110
|
-
| `str \| None` | 截图的图片 ID,失败时返回 `None` |
|
|
111
|
-
|
|
112
|
-
**示例:**
|
|
113
|
-
|
|
114
|
-
```python
|
|
115
|
-
from kuaijs import image
|
|
116
|
-
|
|
117
|
-
imageId = image.captureRect(100, 100, 200, 200)
|
|
118
|
-
if imageId:
|
|
119
|
-
print("截图成功")
|
|
120
|
-
image.saveTo(imageId, "rect.jpg")
|
|
121
|
-
image.release(imageId)
|
|
122
|
-
else:
|
|
123
|
-
print("截图失败")
|
|
124
|
-
```
|
|
125
|
-
|
|
126
66
|
### readImage - 从文件路径或imageId读取图片。
|
|
127
67
|
|
|
128
68
|
```python
|
|
@@ -179,7 +119,7 @@ def saveTo(id: str, path: str) -> bool
|
|
|
179
119
|
```python
|
|
180
120
|
from kuaijs import image, file
|
|
181
121
|
|
|
182
|
-
imageId = image.
|
|
122
|
+
imageId = image.captureScreen()
|
|
183
123
|
# 获取手机文档目录
|
|
184
124
|
dir_path = file.getInternalDir("documents")
|
|
185
125
|
if imageId:
|
|
@@ -230,7 +170,7 @@ def isRelease(id: str) -> bool
|
|
|
230
170
|
```python
|
|
231
171
|
from kuaijs import image
|
|
232
172
|
|
|
233
|
-
imageId = image.
|
|
173
|
+
imageId = image.captureScreen()
|
|
234
174
|
if imageId:
|
|
235
175
|
print(f"释放前: {image.isRelease(imageId)}") # False
|
|
236
176
|
image.release(imageId)
|
|
@@ -268,7 +208,7 @@ def getSize(id: str) -> Optional[Size]
|
|
|
268
208
|
```python
|
|
269
209
|
from kuaijs import image
|
|
270
210
|
|
|
271
|
-
imageId = image.
|
|
211
|
+
imageId = image.captureScreen()
|
|
272
212
|
if imageId:
|
|
273
213
|
size = image.getSize(imageId)
|
|
274
214
|
if size:
|
|
@@ -300,7 +240,7 @@ def pixel(id: str, x: int, y: int) -> int
|
|
|
300
240
|
```python
|
|
301
241
|
from kuaijs import image
|
|
302
242
|
|
|
303
|
-
imageId = image.
|
|
243
|
+
imageId = image.captureScreen()
|
|
304
244
|
if imageId:
|
|
305
245
|
color = image.pixel(imageId, 100, 100)
|
|
306
246
|
colorHex = image.argb(color)
|
|
@@ -356,7 +296,7 @@ def findColor(id: str, color: str, threshold: float, x: int, y: int, ex: int, ey
|
|
|
356
296
|
```python
|
|
357
297
|
from kuaijs import image, action
|
|
358
298
|
|
|
359
|
-
imageId = image.
|
|
299
|
+
imageId = image.captureScreen()
|
|
360
300
|
if imageId:
|
|
361
301
|
# 查找蓝色按钮
|
|
362
302
|
points = image.findColor(
|
|
@@ -408,7 +348,7 @@ def findMultiColor(id: str, firstColor: str, threshold: float, points: str, x: i
|
|
|
408
348
|
```python
|
|
409
349
|
from kuaijs import image, action
|
|
410
350
|
|
|
411
|
-
imageId = image.
|
|
351
|
+
imageId = image.captureScreen()
|
|
412
352
|
if imageId:
|
|
413
353
|
# 查找特定的颜色组合(如按钮的特征颜色)
|
|
414
354
|
points = image.findMultiColor(
|
|
@@ -460,7 +400,7 @@ def countColor(id: str, colors: str, threshold: float, x: int, y: int, ex: int,
|
|
|
460
400
|
```python
|
|
461
401
|
from kuaijs import image
|
|
462
402
|
|
|
463
|
-
imageId = image.
|
|
403
|
+
imageId = image.captureScreen()
|
|
464
404
|
if imageId:
|
|
465
405
|
count = image.countColor(
|
|
466
406
|
imageId,
|
|
@@ -501,7 +441,7 @@ def cmpColor(id: str, points: str, threshold: float) -> bool
|
|
|
501
441
|
```python
|
|
502
442
|
from kuaijs import image
|
|
503
443
|
|
|
504
|
-
imageId = image.
|
|
444
|
+
imageId = image.captureScreen()
|
|
505
445
|
if imageId:
|
|
506
446
|
# 检查特定区域是否为预期颜色
|
|
507
447
|
isMatch = image.cmpColor(
|
|
@@ -599,7 +539,7 @@ def clip(id: str, x: int, y: int, ex: int, ey: int) -> Optional[str]
|
|
|
599
539
|
```python
|
|
600
540
|
from kuaijs import image, device, file
|
|
601
541
|
|
|
602
|
-
imageId = image.
|
|
542
|
+
imageId = image.captureScreen()
|
|
603
543
|
# 获取手机文档目录
|
|
604
544
|
dir_path = file.getInternalDir("documents")
|
|
605
545
|
if imageId:
|
|
@@ -672,7 +612,7 @@ def gray(id: str) -> Optional[str]
|
|
|
672
612
|
```python
|
|
673
613
|
from kuaijs import image, file
|
|
674
614
|
|
|
675
|
-
imageId = image.
|
|
615
|
+
imageId = image.captureScreen()
|
|
676
616
|
# 获取手机文档目录
|
|
677
617
|
dir_path = file.getInternalDir("documents")
|
|
678
618
|
if imageId:
|
|
@@ -707,7 +647,7 @@ def binaryzation(id: str, threshold: float) -> Optional[str]
|
|
|
707
647
|
```python
|
|
708
648
|
from kuaijs import image, file
|
|
709
649
|
|
|
710
|
-
imageId = image.
|
|
650
|
+
imageId = image.captureScreen()
|
|
711
651
|
# 获取手机文档目录
|
|
712
652
|
dir_path = file.getInternalDir("documents")
|
|
713
653
|
if imageId:
|
|
@@ -741,7 +681,7 @@ from kuaijs import image, file
|
|
|
741
681
|
# 获取手机文档目录
|
|
742
682
|
dir_path = file.getInternalDir("documents")
|
|
743
683
|
|
|
744
|
-
imageId = image.
|
|
684
|
+
imageId = image.captureScreen()
|
|
745
685
|
if imageId:
|
|
746
686
|
image.drawRect(imageId, 100, 100, 200, 200, "#FF0000", 2)
|
|
747
687
|
image.saveTo(imageId, f"{dir_path}/test.jpg")
|
|
@@ -771,7 +711,7 @@ def scanCode(id: str) -> Optional[str]
|
|
|
771
711
|
```python
|
|
772
712
|
from kuaijs import image
|
|
773
713
|
|
|
774
|
-
imageId = image.
|
|
714
|
+
imageId = image.captureScreen()
|
|
775
715
|
if imageId:
|
|
776
716
|
result = image.scanCode(imageId)
|
|
777
717
|
if result:
|
|
@@ -841,7 +781,7 @@ def toBase64Format(id: str, format: str, q: int) -> str
|
|
|
841
781
|
```python
|
|
842
782
|
from kuaijs import image
|
|
843
783
|
|
|
844
|
-
imageId = image.
|
|
784
|
+
imageId = image.captureScreen()
|
|
845
785
|
if imageId:
|
|
846
786
|
base64 = image.toBase64Format(imageId, "jpg", 90)
|
|
847
787
|
print(f"Base64 数据: {base64[:100]}...")
|
|
@@ -932,7 +872,7 @@ def imageIdToMat(imageId: str) -> any
|
|
|
932
872
|
from kuaijs import image
|
|
933
873
|
import cv2
|
|
934
874
|
|
|
935
|
-
img_id = image.
|
|
875
|
+
img_id = image.captureScreen()
|
|
936
876
|
if img_id:
|
|
937
877
|
mat = image.imageIdToMat(img_id)
|
|
938
878
|
if mat is not None:
|
|
@@ -968,7 +908,7 @@ def getBitmap(imageId: str) -> any:
|
|
|
968
908
|
```python
|
|
969
909
|
from kuaijs import image
|
|
970
910
|
|
|
971
|
-
imageId = image.
|
|
911
|
+
imageId = image.captureScreen()
|
|
972
912
|
if imageId:
|
|
973
913
|
bitmap = image.getBitmap(imageId)
|
|
974
914
|
print(f"Bitmap 对象: {bitmap}")
|
package/docs/apipython/media.md
CHANGED
|
@@ -35,7 +35,7 @@ def saveImageToAlbum(imageId: str) -> bool
|
|
|
35
35
|
from kuaijs import media, image
|
|
36
36
|
|
|
37
37
|
# 保存截图到相册
|
|
38
|
-
img = image.
|
|
38
|
+
img = image.captureScreen()
|
|
39
39
|
if img:
|
|
40
40
|
saved = media.saveImageToAlbum(img)
|
|
41
41
|
print("图片已保存到相册" if saved else "保存失败")
|
|
@@ -191,18 +191,17 @@ stopped = media.stopMp3()
|
|
|
191
191
|
print("音乐已停止" if stopped else "停止失败或没有正在播放的音乐")
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
#### playMp3WaitEnd - 同步播放 MP3
|
|
194
|
+
#### playMp3WaitEnd - 同步播放 MP3 音频文件(播放一次并等待结束)。
|
|
195
195
|
|
|
196
196
|
```python
|
|
197
|
-
def playMp3WaitEnd(path: str
|
|
197
|
+
def playMp3WaitEnd(path: str) -> bool
|
|
198
198
|
```
|
|
199
199
|
|
|
200
200
|
**参数:**
|
|
201
201
|
|
|
202
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述
|
|
203
|
-
| ------ | ---- | -------- | ------ |
|
|
204
|
-
| `path` | str | 是 | | MP3 文件路径
|
|
205
|
-
| `loop` | bool | 是 | | 是否循环播放 注意:循环播放会阻塞线程,慎用,不要在主线程设置为 True |
|
|
202
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
203
|
+
| ------ | ---- | -------- | ------ | ------------ |
|
|
204
|
+
| `path` | str | 是 | | MP3 文件路径 |
|
|
206
205
|
|
|
207
206
|
**返回值:**
|
|
208
207
|
|
|
@@ -216,6 +215,6 @@ def playMp3WaitEnd(path: str, loop: bool) -> bool
|
|
|
216
215
|
from kuaijs import media
|
|
217
216
|
|
|
218
217
|
print("开始播放音频...")
|
|
219
|
-
played = media.playMp3WaitEnd("/var/mobile/Media/notification.mp3"
|
|
218
|
+
played = media.playMp3WaitEnd("/var/mobile/Media/notification.mp3")
|
|
220
219
|
print("音频播放完成" if played else "播放失败")
|
|
221
220
|
```
|