ms-vite-plugin 1.1.2 → 1.1.3

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.
Files changed (94) hide show
  1. package/dist/build.js +6 -0
  2. package/dist/cli.js +91 -1
  3. package/dist/mcp/device-config.d.ts +55 -0
  4. package/dist/mcp/device-config.js +183 -0
  5. package/dist/mcp/docs-service.d.ts +65 -0
  6. package/dist/mcp/docs-service.js +168 -0
  7. package/dist/mcp/project.d.ts +16 -0
  8. package/dist/mcp/project.js +74 -0
  9. package/dist/mcp/tools.d.ts +18 -0
  10. package/dist/mcp/tools.js +825 -0
  11. package/dist/mcp/types.d.ts +32 -0
  12. package/dist/mcp/types.js +11 -0
  13. package/dist/mcp-server.d.ts +2 -0
  14. package/dist/mcp-server.js +86 -0
  15. package/dist/project.d.ts +89 -0
  16. package/dist/project.js +306 -0
  17. package/dist/version.d.ts +12 -0
  18. package/dist/version.js +63 -0
  19. package/docs/api/action.md +922 -0
  20. package/docs/api/appleocr.md +229 -0
  21. package/docs/api/config.md +122 -0
  22. package/docs/api/cryptoUtils.md +232 -0
  23. package/docs/api/device.md +374 -0
  24. package/docs/api/file.md +516 -0
  25. package/docs/api/global.md +617 -0
  26. package/docs/api/hid.md +1032 -0
  27. package/docs/api/hotUpdate.md +166 -0
  28. package/docs/api/http.md +548 -0
  29. package/docs/api/image.md +907 -0
  30. package/docs/api/ime.md +290 -0
  31. package/docs/api/logger.md +324 -0
  32. package/docs/api/media.md +248 -0
  33. package/docs/api/mysql.md +441 -0
  34. package/docs/api/netCard.md +200 -0
  35. package/docs/api/node.md +353 -0
  36. package/docs/api/paddleocr.md +246 -0
  37. package/docs/api/pip.md +242 -0
  38. package/docs/api/system.md +572 -0
  39. package/docs/api/thread.md +269 -0
  40. package/docs/api/tomatoocr.md +425 -0
  41. package/docs/api/tts.md +334 -0
  42. package/docs/api/ui.md +947 -0
  43. package/docs/api/utils.md +265 -0
  44. package/docs/api/yolo.md +310 -0
  45. package/docs/apicn/action.md +919 -0
  46. package/docs/apicn/appleocr.md +233 -0
  47. package/docs/apicn/config.md +120 -0
  48. package/docs/apicn/device.md +385 -0
  49. package/docs/apicn/file.md +511 -0
  50. package/docs/apicn/global.md +613 -0
  51. package/docs/apicn/hid.md +1033 -0
  52. package/docs/apicn/hotUpdate.md +170 -0
  53. package/docs/apicn/http.md +672 -0
  54. package/docs/apicn/image.md +924 -0
  55. package/docs/apicn/ime.md +290 -0
  56. package/docs/apicn/logger.md +332 -0
  57. package/docs/apicn/media.md +252 -0
  58. package/docs/apicn/mysql.md +445 -0
  59. package/docs/apicn/netCard.md +200 -0
  60. package/docs/apicn/node.md +362 -0
  61. package/docs/apicn/paddleocr.md +255 -0
  62. package/docs/apicn/pip.md +242 -0
  63. package/docs/apicn/system.md +575 -0
  64. package/docs/apicn/thread.md +269 -0
  65. package/docs/apicn/tts.md +338 -0
  66. package/docs/apicn/ui.md +933 -0
  67. package/docs/apicn/utils.md +265 -0
  68. package/docs/apicn/yolo.md +314 -0
  69. package/docs/apipython/action.md +901 -0
  70. package/docs/apipython/appleocr.md +226 -0
  71. package/docs/apipython/config.md +126 -0
  72. package/docs/apipython/cryptoUtils.md +246 -0
  73. package/docs/apipython/device.md +365 -0
  74. package/docs/apipython/file.md +476 -0
  75. package/docs/apipython/g.md +154 -0
  76. package/docs/apipython/hid.md +1059 -0
  77. package/docs/apipython/hotUpdate.md +154 -0
  78. package/docs/apipython/image.md +938 -0
  79. package/docs/apipython/ime.md +306 -0
  80. package/docs/apipython/logger.md +330 -0
  81. package/docs/apipython/media.md +221 -0
  82. package/docs/apipython/mysql.md +432 -0
  83. package/docs/apipython/netCard.md +219 -0
  84. package/docs/apipython/node.md +331 -0
  85. package/docs/apipython/overview.md +66 -0
  86. package/docs/apipython/paddleocr.md +211 -0
  87. package/docs/apipython/pip.md +231 -0
  88. package/docs/apipython/system.md +458 -0
  89. package/docs/apipython/tomatoocr.md +444 -0
  90. package/docs/apipython/tts.md +331 -0
  91. package/docs/apipython/ui.md +949 -0
  92. package/docs/apipython/utils.md +284 -0
  93. package/docs/apipython/yolo.md +281 -0
  94. package/package.json +8 -4
@@ -0,0 +1,265 @@
1
+ # 工具模块 (Utils)
2
+
3
+ 工具模块提供了一系列实用的工具函数,包括时间格式化、资源文件读取、随机数生成、应用前台切换等常用功能。
4
+
5
+ ## 功能概览
6
+
7
+ - **时间处理**: 时间格式化功能
8
+ - **随机数生成**: 生成指定范围的随机数
9
+ - **应用控制**: 将应用切换到前台
10
+ - **编码转换**: 字符串编码与解码工具
11
+
12
+ ## API 参考
13
+
14
+ ### 时间处理
15
+
16
+ #### timeFormat - 格式化当前时间为指定格式的字符串。
17
+
18
+ ```typescript
19
+ function timeFormat(format: string): string;
20
+ ```
21
+
22
+ **参数:**
23
+
24
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
25
+ | -------- | ------ | -------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
26
+ | `format` | string | 是 | | 时间格式化字符串 <br> `yyyy` - 四位年份 <br> `MM` - 两位月份<br> `dd` - 两位日期<br> `hh` - 两位小时(24 小时制)<br> `mm` - 两位分钟<br> `ss` - 两位秒数 |
27
+
28
+ **返回值:**
29
+
30
+ | 类型 | 描述 |
31
+ | -------- | -------------------- |
32
+ | `string` | 格式化后的时间字符串 |
33
+
34
+ **示例:**
35
+
36
+ ```javascript
37
+ // 标准日期时间格式
38
+ const dateTime = utils.timeFormat("yyyy-MM-dd hh:mm:ss");
39
+ logi(dateTime); // 输出: 2024-01-15 14:30:25
40
+
41
+ // 仅日期格式
42
+ const date = utils.timeFormat("yyyy-MM-dd");
43
+ logi(date); // 输出: 2024-01-15
44
+
45
+ // 仅时间格式
46
+ const time = utils.timeFormat("hh:mm:ss");
47
+ logi(time); // 输出: 14:30:25
48
+
49
+ // 自定义分隔符
50
+ const customFormat = utils.timeFormat("yyyy/MM/dd hh:mm");
51
+ logi(customFormat); // 输出: 2024/01/15 14:30
52
+
53
+ // 紧凑格式
54
+ const compact = utils.timeFormat("yyyyMMddhhmmss");
55
+ logi(compact); // 输出: 20240115143025
56
+ ```
57
+
58
+ ### 随机数生成
59
+
60
+ #### random - 生成指定范围内的随机整数。
61
+
62
+ ```typescript
63
+ function random(min: number, max: number): number;
64
+ ```
65
+
66
+ **参数:**
67
+
68
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
69
+ | ------ | ------ | -------- | ------ | -------------- |
70
+ | `min` | number | 是 | | 最小值(包含) |
71
+ | `max` | number | 是 | | 最大值(包含) |
72
+
73
+ **返回值:**
74
+
75
+ | 类型 | 描述 |
76
+ | -------- | -------------------- |
77
+ | `number` | 指定范围内的随机整数 |
78
+
79
+ **示例:**
80
+
81
+ ```javascript
82
+ // 生成1-10之间的随机数
83
+ const randomNum = utils.random(1, 10);
84
+ logi(`随机数: ${randomNum}`);
85
+
86
+ // 生成0-100之间的随机数
87
+ const percentage = utils.random(0, 100);
88
+ logi(`随机百分比: ${percentage}`);
89
+
90
+ // 生成随机延迟时间(毫秒)
91
+ const delay = utils.random(1000, 5000);
92
+ logi(`随机延迟: ${delay} 毫秒`);
93
+ sleep(delay);
94
+
95
+ // 生成随机索引
96
+ const array = ["apple", "banana", "orange", "grape"];
97
+ const randomIndex = utils.random(0, array.length - 1);
98
+ logi(`随机选择: ${array[randomIndex]}`);
99
+ ```
100
+
101
+ #### randomUUID - 生成随机 UUID。
102
+
103
+ ```typescript
104
+ function randomUUID(): string;
105
+ ```
106
+
107
+ **返回值:**
108
+
109
+ | 类型 | 描述 |
110
+ | -------- | ---------------- |
111
+ | `string` | 随机 UUID 字符串 |
112
+
113
+ **示例:**
114
+
115
+ ```javascript
116
+ const uuid = utils.randomUUID();
117
+ logi(uuid);
118
+ ```
119
+
120
+ ### 应用控制
121
+
122
+ #### takeMeToFront - 将快点 JS 应用切换到前台显示。
123
+
124
+ **注意事项**
125
+
126
+ - 此模块仅支持 快点 Agent 模式使用
127
+
128
+ ```typescript
129
+ function takeMeToFront(): boolean;
130
+ ```
131
+
132
+ **示例:**
133
+
134
+ ```javascript
135
+ // 将应用切换到前台
136
+ utils.takeMeToFront();
137
+ logi("应用已切换到前台");
138
+ ```
139
+
140
+ ### 编码转换
141
+
142
+ #### hexString - 字符串转 Hex 字符串。
143
+
144
+ ```typescript
145
+ function hexString(source: string): string;
146
+ ```
147
+
148
+ **参数:**
149
+
150
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
151
+ | -------- | ------ | -------- | ------ | -------- |
152
+ | `source` | string | 是 | | 源字符串 |
153
+
154
+ **返回值:**
155
+
156
+ | 类型 | 描述 |
157
+ | -------- | ---------- |
158
+ | `string` | Hex 字符串 |
159
+
160
+ **示例:**
161
+
162
+ ```javascript
163
+ const hex = utils.hexString("hello");
164
+ logi(hex);
165
+ ```
166
+
167
+ #### base64Encoded - 字符串转 Base64。
168
+
169
+ ```typescript
170
+ function base64Encoded(source: string): string;
171
+ ```
172
+
173
+ **参数:**
174
+
175
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
176
+ | -------- | ------ | -------- | ------ | -------- |
177
+ | `source` | string | 是 | | 源字符串 |
178
+
179
+ **返回值:**
180
+
181
+ | 类型 | 描述 |
182
+ | -------- | ------------- |
183
+ | `string` | Base64 字符串 |
184
+
185
+ **示例:**
186
+
187
+ ```javascript
188
+ const b64 = utils.base64Encoded("hello");
189
+ logi(b64);
190
+ ```
191
+
192
+ #### base64Decoded - Base64 转字符串。
193
+
194
+ ```typescript
195
+ function base64Decoded(source: string): string;
196
+ ```
197
+
198
+ **参数:**
199
+
200
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
201
+ | -------- | ------ | -------- | ------ | ------------- |
202
+ | `source` | string | 是 | | Base64 字符串 |
203
+
204
+ **返回值:**
205
+
206
+ | 类型 | 描述 |
207
+ | -------- | -------------- |
208
+ | `string` | 解码后的字符串 |
209
+
210
+ **示例:**
211
+
212
+ ```javascript
213
+ const str = utils.base64Decoded("aGVsbG8=");
214
+ logi(str);
215
+ ```
216
+
217
+ #### hexStringBase64Encoded - 16 进制字符串转 Base64。
218
+
219
+ ```typescript
220
+ function hexStringBase64Encoded(hexString: string): string;
221
+ ```
222
+
223
+ **参数:**
224
+
225
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
226
+ | ----------- | ------ | -------- | ------ | ------------- |
227
+ | `hexString` | string | 是 | | 16 进制字符串 |
228
+
229
+ **返回值:**
230
+
231
+ | 类型 | 描述 |
232
+ | -------- | ------------- |
233
+ | `string` | Base64 字符串 |
234
+
235
+ **示例:**
236
+
237
+ ```javascript
238
+ const b64 = utils.hexStringBase64Encoded("68656c6c6f");
239
+ logi(b64);
240
+ ```
241
+
242
+ #### hexStringBase64Decoded - Base64 转 16 进制字符串。
243
+
244
+ ```typescript
245
+ function hexStringBase64Decoded(base64HexString: string): string;
246
+ ```
247
+
248
+ **参数:**
249
+
250
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
251
+ | ----------------- | ------ | -------- | ------ | ------------- |
252
+ | `base64HexString` | string | 是 | | Base64 字符串 |
253
+
254
+ **返回值:**
255
+
256
+ | 类型 | 描述 |
257
+ | -------- | ------------- |
258
+ | `string` | 16 进制字符串 |
259
+
260
+ **示例:**
261
+
262
+ ```javascript
263
+ const hex = utils.hexStringBase64Decoded("aGVsbG8=");
264
+ logi(hex);
265
+ ```
@@ -0,0 +1,310 @@
1
+ # YOLO 目标检测模块 (YOLO)
2
+
3
+ YOLO 模块基于 YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能的实时目标检测功能,支持多种输入源和自定义模型,可用于物体识别、位置定位等应用场景。
4
+
5
+ ## 数据标注
6
+
7
+ 查看 [快点 Label](../label/dataAnnotation.md) 了解如何进行数据标注
8
+
9
+ ## 功能概览
10
+
11
+ - **模型管理**: YOLOV8/YOLOV11/YOLOV26 模型加载和资源管理
12
+ - **目标检测**: 实时物体检测和位置识别
13
+ - **多源输入**: 支持屏幕截图、图片文件、URL 等多种输入源
14
+ - **结果处理**: 完整的检测结果信息和坐标数据
15
+ - **资源控制**: 完整的模型生命周期管理
16
+
17
+ ## 测试结果
18
+
19
+ | 设备型号 | 模型类型 | 检测耗时 |
20
+ | ---------- | ---------------- | --------- |
21
+ | iPhoneX | yolov8n(80 类别) | 70-100ms |
22
+ | iPhoneX | yolov8s(80 类别) | 160-200ms |
23
+ | iPhone SE3 | yolov8n(80 类别) | 30-50ms |
24
+ | iPhone SE3 | yolov8s(80 类别) | 70-100ms |
25
+
26
+ ## 数据结构
27
+
28
+ ### YoloResult
29
+
30
+ YOLO 检测结果接口,包含检测到的物体的完整信息。
31
+
32
+ ```typescript
33
+ interface YoloResult {
34
+ x: number; // 检测框的左上角x坐标
35
+ y: number; // 检测框的左上角y坐标
36
+ ex: number; // 检测框的右下角x坐标
37
+ ey: number; // 检测框的右下角y坐标
38
+ centerX: number; // 检测框的中心点x坐标
39
+ centerY: number; // 检测框的中心点y坐标
40
+ width: number; // 检测框的宽度
41
+ height: number; // 检测框的高度
42
+ confidence: number; // 检测框的置信度 (0-1)
43
+ classId: number; // 检测框的类别ID
44
+ }
45
+ ```
46
+
47
+ **字段说明:**
48
+
49
+ | 字段名 | 类型 | 描述 |
50
+ | ------------------ | ------ | ------------------------------------------ |
51
+ | `x, y` | number | 检测框左上角坐标 |
52
+ | `ex, ey` | number | 检测框右下角坐标 |
53
+ | `centerX, centerY` | number | 检测框中心点坐标 |
54
+ | `width, height` | number | 检测框尺寸 |
55
+ | `confidence` | number | 检测置信度,范围 0-1,值越高表示检测越可靠 |
56
+ | `classId` | number | 物体类别 ID,对应训练模型的类别标签 |
57
+
58
+ ## API 参考
59
+
60
+ ### 模型管理
61
+
62
+ #### load - 加载 YOLO 模型(支持版本 8/11/26)
63
+
64
+ 加载模型是使用目标检测功能的前提。
65
+
66
+ ```typescript
67
+ function load(
68
+ paramPath: string,
69
+ binPath: string,
70
+ nc: number,
71
+ version?: number
72
+ ): string | null;
73
+ ```
74
+
75
+ **参数:**
76
+
77
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
78
+ | ----------- | ------ | -------- | ------ | ------------------------------------------- |
79
+ | `paramPath` | string | 是 | | NCNN 模型的 param 文件绝对路径 |
80
+ | `binPath` | string | 是 | | NCNN 模型的 bin 文件绝对路径 |
81
+ | `nc` | number | 是 | | 模型的标签数量,可在标签集 data.yaml 中查看 |
82
+ | `version` | number | 否 | 11 | YOLO 模型版本号(仅支持 8/11/26) |
83
+
84
+ **返回值:**
85
+
86
+ | 类型 | 描述 |
87
+ | ---------------- | ----------------------------------------- |
88
+ | `string \| null` | 加载成功返回模型 ID 字符串,失败返回 null |
89
+
90
+ **示例:**
91
+
92
+ ```javascript
93
+ // 加载 YOLOv8 模型
94
+ const modelId = yolo.load(
95
+ "yolov8n_ncnn_model/model.ncnn.param",
96
+ "yolov8n_ncnn_model/model.ncnn.bin",
97
+ 80,
98
+ 8
99
+ );
100
+ ```
101
+
102
+ #### loadV11 - 加载 YOLOv11 模型(兼容 yolov8 模型),这是使用目标检测功能的前提。
103
+
104
+ ```typescript
105
+ function loadV11(paramPath: string, binPath: string, nc: number): string | null;
106
+ ```
107
+
108
+ **参数:**
109
+
110
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
111
+ | ----------- | ------ | -------- | ------ | ------------------------------------------- |
112
+ | `paramPath` | string | 是 | | NCNN 模型的 param 文件绝对路径 |
113
+ | `binPath` | string | 是 | | NCNN 模型的 bin 文件绝对路径 |
114
+ | `nc` | number | 是 | | 模型的标签数量,可在标签集 data.yaml 中查看 |
115
+
116
+ **返回值:**
117
+
118
+ | 类型 | 描述 |
119
+ | ---------------- | ----------------------------------------- |
120
+ | `string \| null` | 加载成功返回模型 ID 字符串,失败返回 null |
121
+
122
+ **示例:**
123
+
124
+ ```javascript
125
+ // 加载 YOLOv11 模型
126
+ // 模型放在res目录
127
+ const modelId = yolo.loadV11(
128
+ "yolo11n_ncnn_model/model.ncnn.param",
129
+ "yolo11n_ncnn_model/model.ncnn.bin",
130
+ 80 // COCO 数据集有 80 个类别
131
+ );
132
+
133
+ if (modelId) {
134
+ logi(`模型加载成功,ID: ${modelId}`);
135
+ } else {
136
+ logi("模型加载失败,请检查文件路径和格式");
137
+ }
138
+ ```
139
+
140
+ ### 目标检测
141
+
142
+ #### detect - 执行目标检测,识别图像中的物体并返回检测结果。
143
+
144
+ ```typescript
145
+ function detect(
146
+ modelId: string,
147
+ img: string,
148
+ targetSize?: number,
149
+ threshold?: number,
150
+ nmsThreshold?: number
151
+ ): YoloResult[];
152
+ ```
153
+
154
+ **参数:**
155
+
156
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
157
+ | ------------ | ------ | -------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
158
+ | `modelId` | string | 是 | | 模型 ID(通过 loadV11 获取) |
159
+ | `img` | string | 是 | | 图像输入源:<br>- `"screen"` - 使用当前屏幕截图<br>- `string` - 图片文件路径或 HTTP 图片地址<br>- `imageId` - 图片 ID(通过 image 模块获取) |
160
+ | `targetSize` | number | 否 | 640 | 图像缩放的检测大小,通常为 640(与模型训练时一致) |
161
+ | `threshold` | number | 否 | 0.4 | 置信度阈值,默认 0.4,低于此值的检测结果会被过滤 |
162
+
163
+ - `nmsThreshold` - 非极大值抑制阈值,默认 0.5,用于去除重叠检测框
164
+
165
+ **返回值:**
166
+
167
+ | 类型 | 描述 |
168
+ | -------------- | ---------------------------------------------- |
169
+ | `YoloResult[]` | 检测结果数组,每个元素包含一个检测到的物体信息 |
170
+
171
+ **示例:**
172
+
173
+ ```javascript
174
+ // 首先加载模型
175
+ const modelId = yolo.loadV11(
176
+ "/yolo11n_ncnn_model/model.ncnn.param",
177
+ "/yolo11n_ncnn_model/model.ncnn.bin",
178
+ 80
179
+ );
180
+
181
+ if (!modelId) {
182
+ logi("模型加载失败");
183
+ return;
184
+ }
185
+
186
+ // 检测当前屏幕
187
+ const screenResults = yolo.detect(
188
+ modelId,
189
+ "screen", // 使用当前屏幕
190
+ 640, // 标准检测尺寸
191
+ 0.4, // 置信度阈值
192
+ 0.5 // NMS 阈值
193
+ );
194
+
195
+ logi(`屏幕检测到 ${screenResults.length} 个物体`);
196
+
197
+ screenResults.forEach((result, index) => {
198
+ logi(`物体 ${index + 1}:`);
199
+ logi(` 类别ID: ${result.classId}`);
200
+ logi(` 置信度: ${(result.confidence * 100).toFixed(2)}%`);
201
+ logi(
202
+ ` 边界框: (${result.x}, ${result.y}, ${result.x + result.width}, ${
203
+ result.y + result.height
204
+ })`
205
+ );
206
+ logi(` 中心点: (${result.centerX}, ${result.centerY})`);
207
+ logi(` 尺寸: ${result.width} x ${result.height}`);
208
+ });
209
+
210
+ // 检测图片文件
211
+ const imageResults = yolo.detect(
212
+ modelId,
213
+ "/path/to/test_image.jpg",
214
+ 640,
215
+ 0.3, // 降低置信度阈值以检测更多物体
216
+ 0.5
217
+ );
218
+
219
+ if (imageResults.length > 0) {
220
+ logi(`图片中检测到 ${imageResults.length} 个物体`);
221
+ imageResults.forEach((result) => {
222
+ logi(
223
+ `检测到类别 ${result.classId},置信度: ${result.confidence.toFixed(3)}`
224
+ );
225
+ });
226
+ } else {
227
+ logi("图片中未检测到任何物体");
228
+ }
229
+
230
+ // 检测网络图片
231
+ const urlResults = yolo.detect(
232
+ modelId,
233
+ "https://example.com/test_image.jpg",
234
+ 640,
235
+ 0.5, // 提高置信度阈值以获得更可靠的结果
236
+ 0.4
237
+ );
238
+
239
+ logi(`网络图片检测结果: ${urlResults.length} 个物体`);
240
+
241
+ // 高精度检测(降低阈值)
242
+ const highPrecisionResults = yolo.detect(
243
+ modelId,
244
+ null,
245
+ 640,
246
+ 0.2, // 更低的置信度阈值
247
+ 0.3 // 更低的 NMS 阈值
248
+ );
249
+
250
+ logi(`高精度检测结果: ${highPrecisionResults.length} 个物体`);
251
+
252
+ // 快速检测(提高阈值)
253
+ const fastResults = yolo.detect(
254
+ modelId,
255
+ null,
256
+ 416, // 更小的检测尺寸以提高速度
257
+ 0.6, // 更高的置信度阈值
258
+ 0.6 // 更高的 NMS 阈值
259
+ );
260
+
261
+ logi(`快速检测结果: ${fastResults.length} 个物体`);
262
+ ```
263
+
264
+ ### 资源管理
265
+
266
+ #### free - 释放指定模型的资源。
267
+
268
+ ```typescript
269
+ function free(modelId: string): void;
270
+ ```
271
+
272
+ **参数:**
273
+
274
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
275
+ | --------- | ------ | -------- | ------ | --------------- |
276
+ | `modelId` | string | 是 | | 要释放的模型 ID |
277
+
278
+ **示例:**
279
+
280
+ ```javascript
281
+ // 释放特定模型
282
+ if (modelId) {
283
+ yolo.free(modelId);
284
+ logi(`模型 ${modelId} 资源已释放`);
285
+ }
286
+
287
+ // 使用完毕后释放资源
288
+ function cleanupModel(modelId) {
289
+ if (modelId) {
290
+ yolo.free(modelId);
291
+ logi("模型资源已清理");
292
+ }
293
+ }
294
+
295
+ cleanupModel(modelId);
296
+ ```
297
+
298
+ #### freeAll - 释放所有已加载模型的资源。
299
+
300
+ ```typescript
301
+ function freeAll(): void;
302
+ ```
303
+
304
+ **示例:**
305
+
306
+ ```javascript
307
+ // 释放所有模型资源
308
+ yolo.freeAll();
309
+ logi("所有 YOLO 模型资源已释放");
310
+ ```