ms-vite-plugin 1.4.18 → 1.4.20

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 CHANGED
@@ -684,6 +684,13 @@ async function ocrCommand(options) {
684
684
  const texts = textItems.length > 0 ? textItems : undefined;
685
685
  const languages = parseAppleOcrLanguages(options.languages);
686
686
  const confidenceThreshold = parseCliNumber(options.confidenceThreshold, 0.6, "confidence-threshold", 0, 1);
687
+ const paddleModel = options.paddleModel === undefined
688
+ ? undefined
689
+ : parseCliChoice(options.paddleModel, ocr_tools_1.PADDLE_OCR_MODELS[0], ocr_tools_1.PADDLE_OCR_MODELS, "paddle-model");
690
+ const maxSideLen = options.maxSideLen === undefined
691
+ ? undefined
692
+ : parseCliInteger(options.maxSideLen, 0, "max-side-len", 0);
693
+ const useGpu = options.useGpu === true ? true : undefined;
687
694
  const timeoutMs = parseCliInteger(options.timeoutMs, 60000, "timeout-ms", 1000, 600000);
688
695
  const format = parseCliChoice(options.format, "summary", ["summary", "json"], "format");
689
696
  const result = await (0, ocr_tools_1.runOcrRecognitionOnDevice)(target, {
@@ -698,6 +705,9 @@ async function ocrCommand(options) {
698
705
  languages,
699
706
  confidenceThreshold,
700
707
  exactMatch: options.exactMatch === true,
708
+ paddleModel,
709
+ maxSideLen,
710
+ useGpu,
701
711
  outputPath: format === "summary" ? options.output : undefined,
702
712
  timeoutMs,
703
713
  });
@@ -714,6 +724,12 @@ async function ocrCommand(options) {
714
724
  `mode: ${mode}`,
715
725
  `input: ${input}`,
716
726
  `region: x=${x}, y=${y}, ex=${ex}, ey=${ey}`,
727
+ ...(engine === "paddleocr" && paddleModel
728
+ ? [`paddleModel: ${paddleModel}`]
729
+ : []),
730
+ ...(engine === "paddleocr" && maxSideLen !== undefined
731
+ ? [`maxSideLen: ${maxSideLen}`]
732
+ : []),
717
733
  `status: ${result.status}`,
718
734
  ].join("\n"));
719
735
  }
@@ -1117,6 +1133,9 @@ commander_1.program
1117
1133
  .option("--languages <languages>", "Apple OCR 语言,支持 JSON 数组或逗号分隔")
1118
1134
  .option("--exact-match", "findText 要求完整匹配文本")
1119
1135
  .option("--confidence-threshold <confidenceThreshold>", "PaddleOCR 置信度阈值", "0.6")
1136
+ .option("--paddle-model <paddleModel>", "仅 paddleocr:切换模型 ppocr-v6-tiny|ppocr-v6-small|ppocr-v5")
1137
+ .option("--max-side-len <maxSideLen>", "仅 paddleocr:检测最大边长,0 回落默认 768")
1138
+ .option("--use-gpu", "仅 paddleocr:切换模型时启用 GPU")
1120
1139
  .option("--timeout-ms <timeoutMs>", "请求超时时间(毫秒)", "60000")
1121
1140
  .option("--format <format>", "返回格式: summary|json", "summary")
1122
1141
  .option("--output <output>", "OCR 输出文件路径(可选)")
@@ -1,6 +1,11 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  export type OcrEngine = "appleocr" | "paddleocr";
3
3
  export type OcrMode = "recognize" | "numbers" | "findText";
4
+ export type PaddleOcrModel = "ppocr-v6-tiny" | "ppocr-v6-small" | "ppocr-v5";
5
+ /** PaddleOCR 内置可切换模型 ID;同一时间只保留一个 active 模型。 */
6
+ export declare const PADDLE_OCR_MODELS: readonly ["ppocr-v6-tiny", "ppocr-v6-small", "ppocr-v5"];
7
+ /** PaddleOCR 检测阶段默认最大边长,与运行时一致;传 0 或负数时回落到该值。 */
8
+ export declare const PADDLE_OCR_DEFAULT_MAX_SIDE_LEN = 768;
4
9
  export type ScriptResultResponse = {
5
10
  success?: boolean;
6
11
  result?: unknown;
@@ -19,6 +24,9 @@ export type OcrRecognitionOptions = {
19
24
  languages?: string[];
20
25
  confidenceThreshold: number;
21
26
  exactMatch: boolean;
27
+ paddleModel?: PaddleOcrModel;
28
+ maxSideLen?: number;
29
+ useGpu?: boolean;
22
30
  outputPath?: string;
23
31
  timeoutMs: number;
24
32
  };
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.APPLE_OCR_LANGUAGES = void 0;
36
+ exports.APPLE_OCR_LANGUAGES = exports.PADDLE_OCR_DEFAULT_MAX_SIDE_LEN = exports.PADDLE_OCR_MODELS = void 0;
37
37
  exports.formatOcrToolText = formatOcrToolText;
38
38
  exports.runOcrRecognitionOnDevice = runOcrRecognitionOnDevice;
39
39
  exports.registerOcrTools = registerOcrTools;
@@ -42,6 +42,14 @@ const os = __importStar(require("os"));
42
42
  const path = __importStar(require("path"));
43
43
  const z = __importStar(require("zod/v4"));
44
44
  const tool_utils_1 = require("./tool-utils");
45
+ /** PaddleOCR 内置可切换模型 ID;同一时间只保留一个 active 模型。 */
46
+ exports.PADDLE_OCR_MODELS = [
47
+ "ppocr-v6-tiny",
48
+ "ppocr-v6-small",
49
+ "ppocr-v5",
50
+ ];
51
+ /** PaddleOCR 检测阶段默认最大边长,与运行时一致;传 0 或负数时回落到该值。 */
52
+ exports.PADDLE_OCR_DEFAULT_MAX_SIDE_LEN = 768;
45
53
  exports.APPLE_OCR_LANGUAGES = [
46
54
  "en-US",
47
55
  "fr-FR",
@@ -113,21 +121,36 @@ function buildAppleOcrScript(mode, input, x, y, ex, ey, texts, languages, exactM
113
121
  * @param texts 查找文本数组
114
122
  * @param confidenceThreshold 置信度阈值
115
123
  * @param exactMatch 是否完整匹配文本
124
+ * @param paddleModel 可选切换的 PaddleOCR 模型 ID
125
+ * @param maxSideLen 可选检测阶段最大边长
126
+ * @param useGpu loadModel 时是否启用 GPU
116
127
  * @returns 返回可交给 runScript 的 JavaScript 脚本
117
128
  * @example
118
- * buildPaddleOcrScript("recognize", "screen", 0, 0, 0, 0)
129
+ * buildPaddleOcrScript("recognize", "screen", 0, 0, 0, 0, undefined, 0.6, false)
119
130
  */
120
- function buildPaddleOcrScript(mode, input, x, y, ex, ey, texts, confidenceThreshold, exactMatch) {
131
+ function buildPaddleOcrScript(mode, input, x, y, ex, ey, texts, confidenceThreshold, exactMatch, paddleModel, maxSideLen, useGpu) {
121
132
  if (mode === "numbers") {
122
133
  throw new Error("PaddleOCR 文档未提供 numbers 模式,请使用 appleocr 引擎。");
123
134
  }
135
+ // 先设置检测长边,再切换模型;loadModel 会沿用当前长边加载目标模型。
136
+ const setup = [];
137
+ if (maxSideLen !== undefined) {
138
+ setup.push(`paddleOcr.setMaxSideLen(${maxSideLen});`);
139
+ }
140
+ if (paddleModel) {
141
+ setup.push(`paddleOcr.loadModel(${jsonLiteral(paddleModel)}, ${useGpu ?? false});`);
142
+ }
143
+ let call;
124
144
  if (mode === "findText") {
125
145
  if (!texts || texts.length === 0) {
126
146
  throw new Error("findText 模式必须传 texts。");
127
147
  }
128
- return `paddleOcr.findTextAbs(${jsonLiteral(input)}, ${jsonLiteral(texts)}, ${x}, ${y}, ${ex}, ${ey}, ${confidenceThreshold}, ${exactMatch});`;
148
+ call = `paddleOcr.findTextAbs(${jsonLiteral(input)}, ${jsonLiteral(texts)}, ${x}, ${y}, ${ex}, ${ey}, ${confidenceThreshold}, ${exactMatch});`;
129
149
  }
130
- return `paddleOcr.recognizeAbs(${jsonLiteral(input)}, ${x}, ${y}, ${ex}, ${ey}, ${confidenceThreshold});`;
150
+ else {
151
+ call = `paddleOcr.recognizeAbs(${jsonLiteral(input)}, ${x}, ${y}, ${ex}, ${ey}, ${confidenceThreshold});`;
152
+ }
153
+ return [...setup, call].join("\n");
131
154
  }
132
155
  /**
133
156
  * 构建 OCR 运行脚本
@@ -142,13 +165,21 @@ function buildPaddleOcrScript(mode, input, x, y, ex, ey, texts, confidenceThresh
142
165
  * @param languages Apple OCR 识别语言数组
143
166
  * @param confidenceThreshold PaddleOCR 置信度阈值
144
167
  * @param exactMatch 是否完整匹配文本
168
+ * @param paddleModel 可选切换的 PaddleOCR 模型 ID
169
+ * @param maxSideLen 可选 PaddleOCR 检测阶段最大边长
170
+ * @param useGpu PaddleOCR loadModel 时是否启用 GPU
145
171
  * @returns 返回可交给 runScript 的 JavaScript 脚本
146
172
  * @example
147
173
  * buildOcrScript("appleocr", "recognize", "screen", 0, 0, 0, 0)
148
174
  */
149
- function buildOcrScript(engine, mode, input, x, y, ex, ey, texts, languages, confidenceThreshold, exactMatch) {
175
+ function buildOcrScript(engine, mode, input, x, y, ex, ey, texts, languages, confidenceThreshold, exactMatch, paddleModel, maxSideLen, useGpu) {
150
176
  if (engine === "paddleocr") {
151
- return buildPaddleOcrScript(mode, input, x, y, ex, ey, texts, confidenceThreshold, exactMatch);
177
+ return buildPaddleOcrScript(mode, input, x, y, ex, ey, texts, confidenceThreshold, exactMatch, paddleModel, maxSideLen, useGpu);
178
+ }
179
+ if (paddleModel !== undefined ||
180
+ maxSideLen !== undefined ||
181
+ useGpu !== undefined) {
182
+ throw new Error("paddleModel / maxSideLen / useGpu 仅适用于 paddleocr 引擎。");
152
183
  }
153
184
  return buildAppleOcrScript(mode, input, x, y, ex, ey, texts, languages, exactMatch);
154
185
  }
@@ -241,7 +272,7 @@ async function formatOcrToolText(response, outputPath) {
241
272
  * await runOcrRecognitionOnDevice({ ip: "192.168.1.10", port: "9800" }, options)
242
273
  */
243
274
  async function runOcrRecognitionOnDevice(target, options) {
244
- const script = buildOcrScript(options.engine, options.mode, options.input, options.x, options.y, options.ex, options.ey, options.texts, options.languages, options.confidenceThreshold, options.exactMatch);
275
+ const script = buildOcrScript(options.engine, options.mode, options.input, options.x, options.y, options.ex, options.ey, options.texts, options.languages, options.confidenceThreshold, options.exactMatch, options.paddleModel, options.maxSideLen, options.useGpu);
245
276
  const response = await callRunScript(target.ip, target.port, script, options.timeoutMs);
246
277
  const text = await formatOcrToolText(response.body, options.outputPath);
247
278
  return {
@@ -314,6 +345,20 @@ function registerOcrTools(server) {
314
345
  .optional()
315
346
  .default(0.6)
316
347
  .describe("PaddleOCR 置信度阈值,默认 0.6"),
348
+ paddleModel: z
349
+ .enum(exports.PADDLE_OCR_MODELS)
350
+ .optional()
351
+ .describe("仅 paddleocr:切换内置模型,识别前执行 loadModel;不传则使用当前 active 模型,未加载时自动加载 ppocr-v6-small"),
352
+ maxSideLen: z
353
+ .number()
354
+ .int()
355
+ .min(0)
356
+ .optional()
357
+ .describe(`仅 paddleocr:检测阶段最大边长,识别前执行 setMaxSideLen;不传保持运行时当前值,0 回落到默认 ${exports.PADDLE_OCR_DEFAULT_MAX_SIDE_LEN}`),
358
+ useGpu: z
359
+ .boolean()
360
+ .optional()
361
+ .describe("仅 paddleocr:配合 paddleModel 切换模型时是否启用 GPU,默认 false"),
317
362
  outputPath: z
318
363
  .string()
319
364
  .min(1)
@@ -328,7 +373,7 @@ function registerOcrTools(server) {
328
373
  .default(60000)
329
374
  .describe("runScript 请求超时时间,默认 60000 毫秒"),
330
375
  },
331
- }, async ({ engine, mode, input, x, y, ex, ey, texts, languages, exactMatch, confidenceThreshold, outputPath, timeoutMs, }) => {
376
+ }, async ({ engine, mode, input, x, y, ex, ey, texts, languages, exactMatch, confidenceThreshold, paddleModel, maxSideLen, useGpu, outputPath, timeoutMs, }) => {
332
377
  const target = await (0, tool_utils_1.resolveRuntimeHttpTarget)();
333
378
  const response = await runOcrRecognitionOnDevice(target, {
334
379
  engine,
@@ -342,6 +387,9 @@ function registerOcrTools(server) {
342
387
  languages,
343
388
  confidenceThreshold,
344
389
  exactMatch,
390
+ paddleModel,
391
+ maxSideLen,
392
+ useGpu,
345
393
  outputPath,
346
394
  timeoutMs,
347
395
  });
@@ -353,6 +401,12 @@ function registerOcrTools(server) {
353
401
  `mode: ${mode}`,
354
402
  `input: ${input}`,
355
403
  `region: x=${x}, y=${y}, ex=${ex}, ey=${ey}`,
404
+ ...(engine === "paddleocr" && paddleModel
405
+ ? [`paddleModel: ${paddleModel}`]
406
+ : []),
407
+ ...(engine === "paddleocr" && maxSideLen !== undefined
408
+ ? [`maxSideLen: ${maxSideLen}`]
409
+ : []),
356
410
  `status: ${response.status}`,
357
411
  ].join("\n"), response.body.success === false);
358
412
  });
package/docs/AGENTS.md CHANGED
@@ -164,7 +164,8 @@ OCR 识别使用 `ocr_recognize`,不要手写未确认的 OCR 调用链路。
164
164
  - `ocr_recognize` 支持 `appleocr` 和 `paddleocr`。
165
165
  - 默认使用 `appleocr`。
166
166
  - 数字识别优先使用 `appleocr`。
167
- - PaddleOCR 同一时间只保留一个 active 模型;识别和查找方法默认自动加载 PP-OCRv6 tiny,如需 PP-OCRv6 small 调用 `loadModel("ppocr-v6-small")`,如需 PP-OCRv5 调用 `loadModel("ppocr-v5")`,加载成功后会替换当前模型。
167
+ - PaddleOCR 同一时间只保留一个 active 模型;识别和查找方法默认自动加载 PP-OCRv6 small,如需 PP-OCRv6 tiny 调用 `loadModel("ppocr-v6-tiny")`,如需 PP-OCRv5 调用 `loadModel("ppocr-v5")`,加载成功后会替换当前模型。
168
+ - 切换模型与调整检测长边时,优先使用 `ocr_recognize` 的 `paddleModel`、`maxSideLen`(CLI 为 `--paddle-model`、`--max-side-len`)参数,工具会在识别前自动执行 `setMaxSideLen` 和 `loadModel`,无需手写 runScript 链路;`maxSideLen` 默认 768,传 0 回落默认值;`useGpu`/`--use-gpu` 仅在切换模型时生效。这些参数仅适用于 `paddleocr`,与 `appleocr` 同传会报错。
168
169
 
169
170
  ## 验证要求
170
171
 
package/docs/SKILL.md CHANGED
@@ -189,7 +189,7 @@ CLI 入口:
189
189
 
190
190
  控制、HID、IME、镜像、配置、当前应用、运行脚本等普通设备 HTTP API 通过 `get_docs_paths` 和 `http_api_call` 使用;CLI 入口使用 `ms docs paths` 和 `ms http-call`。
191
191
 
192
- 使用 `ocr_recognize` 执行 OCR 识别。`ocr_recognize` 支持 `appleocr` 和 `paddleocr`,默认 `appleocr`,识别结果坐标可直接用于点击。
192
+ 使用 `ocr_recognize` 执行 OCR 识别。`ocr_recognize` 支持 `appleocr` 和 `paddleocr`,默认 `appleocr`,识别结果坐标可直接用于点击。使用 `paddleocr` 时可传 `paddleModel`(`ppocr-v6-tiny`/`ppocr-v6-small`/`ppocr-v5`)切换模型,传 `maxSideLen` 调整检测最大边长(默认 768),传 `useGpu` 切换 GPU;工具会在识别前自动执行 `setMaxSideLen` 和 `loadModel`,这些参数仅对 `paddleocr` 生效。
193
193
 
194
194
  图片与识别工作流:
195
195
 
@@ -5,7 +5,7 @@ PaddleOCR 模块基于百度飞桨 PaddleOCR 技术,提供强大的光学字
5
5
  ## 功能概览
6
6
 
7
7
  - **自动加载**: 识别和查找方法会自动加载所需模型,无需先手动加载
8
- - **模型选择**: 同一时间只保留一个 active 模型,默认 `ppocr-v6-tiny`,可通过模型 ID 手动加载 `ppocr-v6-small` 或 `ppocr-v5`
8
+ - **模型选择**: 同一时间只保留一个 active 模型,默认 `ppocr-v6-small`,可通过模型 ID 手动加载 `ppocr-v6-tiny` 或 `ppocr-v5`
9
9
  - **长边设置**: 可单独调整检测阶段最大边长,不需要重新加载已加载模型
10
10
  - **多源识别**: 支持屏幕截图、图片文件、URL 等多种输入源
11
11
  - **区域识别**: 支持指定区域的精确文字识别
@@ -65,7 +65,7 @@ interface OCRResult {
65
65
 
66
66
  #### loadModel - 按模型 ID 手动加载内置 PaddleOCR 模型。
67
67
 
68
- 识别和查找方法默认自动加载 `ppocr-v6-tiny`。只有需要切换模型或指定 GPU 参数时才调用 `loadModel`。PaddleOCR 同一时间只保留一个 active 模型,`loadModel` 加载成功后会替换已加载模型;检测长边请使用 `setMaxSideLen` 单独设置。
68
+ 识别和查找方法默认自动加载 `ppocr-v6-small`。只有需要切换模型或指定 GPU 参数时才调用 `loadModel`。PaddleOCR 同一时间只保留一个 active 模型,`loadModel` 加载成功后会替换已加载模型;检测长边请使用 `setMaxSideLen` 单独设置。
69
69
 
70
70
  ```typescript
71
71
  function loadModel(modelId: "ppocr-v6-tiny" | "ppocr-v6-small" | "ppocr-v5", useGpu?: boolean): boolean;
@@ -100,7 +100,7 @@ paddleOcr.loadModel("ppocr-v5", false);
100
100
 
101
101
  #### setMaxSideLen - 单独设置检测阶段输入最大边长。
102
102
 
103
- 该方法只调整后续检测输入缩放,不会重新加载已加载的 PP-OCRv5/v6 模型。如果当前尚未加载模型,后续识别或查找触发默认 PP-OCRv6 tiny 自动加载时会沿用该设置。
103
+ 该方法只调整后续检测输入缩放,不会重新加载已加载的 PP-OCRv5/v6 模型。如果当前尚未加载模型,后续识别或查找触发默认 PP-OCRv6 small 自动加载时会沿用该设置。
104
104
 
105
105
  ```typescript
106
106
  function setMaxSideLen(maxSideLen?: number): boolean;
@@ -110,7 +110,7 @@ function setMaxSideLen(maxSideLen?: number): boolean;
110
110
 
111
111
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
112
112
  | ------------ | ------ | -------- | ------ | ----------------------------------------- |
113
- | `maxSideLen` | number | 否 | 640 | 输入图像的最大边长;传 0 或负数时使用 640 |
113
+ | `maxSideLen` | number | 否 | 768 | 输入图像的最大边长;传 0 或负数时使用 768 |
114
114
 
115
115
  **返回值:**
116
116
 
@@ -5,7 +5,7 @@ PaddleOCR 模块基于百度飞桨 PaddleOCR 技术,提供强大的光学字
5
5
  ## 功能概览
6
6
 
7
7
  - **自动加载**: 识别和查找方法会自动加载所需模型,无需先手动加载
8
- - **模型选择**: 同一时间只保留一个 active 模型,默认 `ppocr-v6-tiny`,可通过模型 ID 手动加载 `ppocr-v6-small` 或 `ppocr-v5`
8
+ - **模型选择**: 同一时间只保留一个 active 模型,默认 `ppocr-v6-small`,可通过模型 ID 手动加载 `ppocr-v6-tiny` 或 `ppocr-v5`
9
9
  - **长边设置**: 可单独调整检测阶段最大边长,不需要重新加载已加载模型
10
10
  - **多源识别**: 支持屏幕截图、图片文件、URL 等多种输入源
11
11
  - **区域识别**: 支持指定区域的精确文字识别
@@ -65,7 +65,7 @@ interface OCR识别结果 {
65
65
 
66
66
  #### 加载模型 - 按模型 ID 手动加载内置 PaddleOCR 模型。
67
67
 
68
- 识别和查找方法默认自动加载 `ppocr-v6-tiny`。只有需要切换模型或指定 GPU 参数时才调用 `加载模型`。PaddleOCR 同一时间只保留一个 active 模型,`加载模型` 加载成功后会替换已加载模型;检测长边请使用 `设置最大边长` 单独设置。
68
+ 识别和查找方法默认自动加载 `ppocr-v6-small`。只有需要切换模型或指定 GPU 参数时才调用 `加载模型`。PaddleOCR 同一时间只保留一个 active 模型,`加载模型` 加载成功后会替换已加载模型;检测长边请使用 `设置最大边长` 单独设置。
69
69
 
70
70
  ```typescript
71
71
  function 加载模型(模型ID: "ppocr-v6-tiny" | "ppocr-v6-small" | "ppocr-v5", useGpu?: 布尔值): 布尔值;
@@ -100,7 +100,7 @@ $PaddleOCR.加载模型("ppocr-v5", false);
100
100
 
101
101
  #### 设置最大边长 - 单独设置检测阶段输入最大边长。
102
102
 
103
- 该方法只调整后续检测输入缩放,不会重新加载已加载的 PP-OCRv5/v6 模型。如果当前尚未加载模型,后续识别或查找触发默认 PP-OCRv6 tiny 自动加载时会沿用该设置。
103
+ 该方法只调整后续检测输入缩放,不会重新加载已加载的 PP-OCRv5/v6 模型。如果当前尚未加载模型,后续识别或查找触发默认 PP-OCRv6 small 自动加载时会沿用该设置。
104
104
 
105
105
  ```typescript
106
106
  function 设置最大边长(最大边长?: 数字): 布尔值;
@@ -110,7 +110,7 @@ function 设置最大边长(最大边长?: 数字): 布尔值;
110
110
 
111
111
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
112
112
  | ---------- | ---- | -------- | ------ | ----------------------------------------- |
113
- | `最大边长` | 数字 | 否 | 640 | 输入图像的最大边长;传 0 或负数时使用 640 |
113
+ | `最大边长` | 数字 | 否 | 768 | 输入图像的最大边长;传 0 或负数时使用 768 |
114
114
 
115
115
  **返回值:**
116
116
 
@@ -5,7 +5,7 @@ PaddleOCR 模块基于百度飞桨 PaddleOCR 技术,提供强大的光学字
5
5
  ## 功能概览
6
6
 
7
7
  - **自动加载**: 识别和查找方法会自动加载所需模型,无需先手动加载
8
- - **模型选择**: 同一时间只保留一个 active 模型,默认 `ppocr-v6-tiny`,可通过模型 ID 手动加载 `ppocr-v6-small` 或 `ppocr-v5`
8
+ - **模型选择**: 同一时间只保留一个 active 模型,默认 `ppocr-v6-small`,可通过模型 ID 手动加载 `ppocr-v6-tiny` 或 `ppocr-v5`
9
9
  - **长边设置**: 可单独调整检测阶段最大边长,不需要重新加载已加载模型
10
10
  - **多源识别**: 支持屏幕截图、图片文件、URL 等多种输入源
11
11
  - **区域识别**: 支持指定区域的精确文字识别
@@ -42,7 +42,7 @@ class OCRResult(TypedDict):
42
42
 
43
43
  #### `loadModel` - 按模型 ID 手动加载内置 PaddleOCR 模型
44
44
 
45
- 识别和查找方法默认自动加载 `ppocr-v6-tiny`。只有需要切换模型或指定 GPU 参数时才调用 `loadModel`。PaddleOCR 同一时间只保留一个 active 模型,`loadModel` 加载成功后会替换已加载模型;检测长边请使用 `setMaxSideLen` 单独设置。
45
+ 识别和查找方法默认自动加载 `ppocr-v6-small`。只有需要切换模型或指定 GPU 参数时才调用 `loadModel`。PaddleOCR 同一时间只保留一个 active 模型,`loadModel` 加载成功后会替换已加载模型;检测长边请使用 `setMaxSideLen` 单独设置。
46
46
 
47
47
  ```python
48
48
  def loadModel(modelId: str, useGpu: bool = False) -> bool
@@ -79,17 +79,17 @@ paddleocr.loadModel("ppocr-v5", False)
79
79
 
80
80
  #### `setMaxSideLen` - 单独设置检测阶段输入最大边长
81
81
 
82
- 该方法只调整后续检测输入缩放,不会重新加载已加载的 PP-OCRv5/v6 模型。如果当前尚未加载模型,后续识别或查找触发默认 PP-OCRv6 tiny 自动加载时会沿用该设置。
82
+ 该方法只调整后续检测输入缩放,不会重新加载已加载的 PP-OCRv5/v6 模型。如果当前尚未加载模型,后续识别或查找触发默认 PP-OCRv6 small 自动加载时会沿用该设置。
83
83
 
84
84
  ```python
85
- def setMaxSideLen(maxSideLen: int = 640) -> bool
85
+ def setMaxSideLen(maxSideLen: int = 768) -> bool
86
86
  ```
87
87
 
88
88
  **参数:**
89
89
 
90
90
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
91
91
  | ------------ | ---- | -------- | ------ | ----------------------------------------- |
92
- | `maxSideLen` | int | 否 | 640 | 输入图像的最大边长;传 0 或负数时使用 640 |
92
+ | `maxSideLen` | int | 否 | 768 | 输入图像的最大边长;传 0 或负数时使用 768 |
93
93
 
94
94
  **返回值:**
95
95
 
@@ -177,7 +177,8 @@ UI 预览发起后不需要长时间等待结果,可以通过 `take_screenshot
177
177
  - 从本地图片指定坐标取色:使用 `image_pick_color` 或 `npx ms image-pick-color`。
178
178
  - 从当前设备截图指定坐标取色:使用 `screen_pick_color` 或 `npx ms screen-pick-color`。
179
179
  - 执行 OCR 识别、数字识别或查找文字:使用 `ocr_recognize` 或 `npx ms ocr`。
180
- - OCR 识别支持 `appleocr` 和 `paddleocr`,默认 `appleocr`,PaddleOCR 同一时间只保留一个 active 模型,识别方法默认自动加载 PP-OCRv6 tiny;如需 PP-OCRv6 small 请调用 `loadModel("ppocr-v6-small")`,如需 PP-OCRv5 请调用 `loadModel("ppocr-v5")`,加载成功后会替换当前模型。
180
+ - OCR 识别支持 `appleocr` 和 `paddleocr`,默认 `appleocr`,PaddleOCR 同一时间只保留一个 active 模型,识别方法默认自动加载 PP-OCRv6 small;如需 PP-OCRv6 tiny 请调用 `loadModel("ppocr-v6-tiny")`,如需 PP-OCRv5 请调用 `loadModel("ppocr-v5")`,加载成功后会替换当前模型。
181
+ - 切换模型或调整检测长边时,直接给 `ocr_recognize` 传 `paddleModel`、`maxSideLen`(CLI 为 `--paddle-model`、`--max-side-len`,GPU 用 `--use-gpu`),工具会在识别前自动执行 `setMaxSideLen` 和 `loadModel`;这些参数仅适用于 `paddleocr`。
181
182
  - 制作透明找图模板:使用 `image_make_transparent` 或 `npx ms image-transparent`,输出到 `res`。
182
183
  - 获取节点 XML:使用 `get_node_source` 或 `npx ms source --mode 1`。
183
184
  - 查看日志:使用 `get_logs` 或 `npx ms logs`。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "1.4.18",
3
+ "version": "1.4.20",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {