ms-types 0.0.29 → 0.0.31

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 (2) hide show
  1. package/package.json +1 -1
  2. package/types/appleOcr.d.ts +58 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-types",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -2,6 +2,32 @@
2
2
  * Apple OCR模块 使用Apple Vision框架进行文本识别
3
3
  */
4
4
  declare namespace appleOcr {
5
+ /**
6
+ * OCR识别结果接口
7
+ */
8
+ interface OCRResult {
9
+ /** 识别的文本内容 */
10
+ text: string;
11
+ /** 识别置信度 (0-1) */
12
+ confidence: number;
13
+ /** 文本区域左上角 x 坐标 */
14
+ x: number;
15
+ /** 文本区域左上角 y 坐标 */
16
+ y: number;
17
+ /** 文本区域右下角 x 坐标 */
18
+ ex: number;
19
+ /** 文本区域右下角 y 坐标 */
20
+ ey: number;
21
+ /** 文本区域宽度 */
22
+ width: number;
23
+ /** 文本区域高度 */
24
+ height: number;
25
+ /** 文本区域中心点 x 坐标 */
26
+ centerX: number;
27
+ /** 文本区域中心点 y 坐标 */
28
+ centerY: number;
29
+ }
30
+
5
31
  /**
6
32
  * 执行OCR识别(使用Apple Vision框架)
7
33
  * @param input 输入源(imageId、URL字符串、文件路径或"screen","screen"表示使用当前屏幕)
@@ -27,52 +53,50 @@ declare namespace appleOcr {
27
53
  ): OCRResult[];
28
54
 
29
55
  /**
30
- * 执行快速OCR识别(仅返回文本内容)
56
+ * 执行OCR识别(仅识别数字)0-9.,+-
31
57
  * @param input 输入源(imageId、URL字符串、文件路径或"screen","screen"表示使用当前屏幕)
32
58
  * @param x 边界框左上角x坐标
33
59
  * @param y 边界框左上角y坐标
34
60
  * @param ex 边界框右下角x坐标
35
61
  * @param ey 边界框右下角y坐标
36
- * @param languages 识别语言数组
37
- * @returns 识别到的文本字符串数组
62
+ * @returns 识别结果数组,包含文本、置信度、坐标等信息
38
63
  * @example
39
- * const texts = appleOcr.recognizeText("screen", 0, 0, 100, 100)
40
- * for (const text of texts) {
41
- * logger.info(text)
42
- * }
64
+ * const results = appleOcr.recognizeNumbers("screen", 0, 0, 100, 100)
65
+ * results.forEach(result => {
66
+ * logger.info(`文本: ${result.text}, 置信度: ${result.confidence}`)
67
+ * })
43
68
  */
44
- function recognizeText(
69
+ function recognizeNumbers(
45
70
  input: string,
46
71
  x: number,
47
72
  y: number,
48
73
  ex: number,
49
- ey: number,
50
- languages?: string[]
51
- ): string[];
74
+ ey: number
75
+ ): OCRResult[];
52
76
 
53
77
  /**
54
- * OCR识别结果接口
78
+ * 执行OCR识别(查找指定文本)
79
+ * @param input 输入源(imageId、URL字符串、文件路径或"screen","screen"表示使用当前屏幕)
80
+ * @param texts 要查找的文本数组
81
+ * @param x 边界框左上角x坐标
82
+ * @param y 边界框左上角y坐标
83
+ * @param ex 边界框右下角x坐标
84
+ * @param ey 边界框右下角y坐标
85
+ * @param languages 识别语言数组,默认为["zh-Hans", "en-US"]
86
+ * @returns 识别结果数组,包含文本、置信度、坐标等信息
87
+ * @example
88
+ * const results = appleOcr.findText("screen", ["123", "456"], 0, 0, 100, 100, ["zh-Hans", "en-US"])
89
+ * results.forEach(result => {
90
+ * logger.info(`文本: ${result.text}, 置信度: ${result.confidence}`)
91
+ * })
55
92
  */
56
- interface OCRResult {
57
- /** 识别的文本内容 */
58
- text: string;
59
- /** 识别置信度 (0-1) */
60
- confidence: number;
61
- /** 文本区域左上角 x 坐标 */
62
- x: number;
63
- /** 文本区域左上角 y 坐标 */
64
- y: number;
65
- /** 文本区域右下角 x 坐标 */
66
- ex: number;
67
- /** 文本区域右下角 y 坐标 */
68
- ey: number;
69
- /** 文本区域宽度 */
70
- width: number;
71
- /** 文本区域高度 */
72
- height: number;
73
- /** 文本区域中心点 x 坐标 */
74
- centerX: number;
75
- /** 文本区域中心点 y 坐标 */
76
- centerY: number;
77
- }
93
+ function findText(
94
+ input: string,
95
+ texts: string[],
96
+ x: number,
97
+ y: number,
98
+ ex: number,
99
+ ey: number,
100
+ languages?: string[]
101
+ ): OCRResult[];
78
102
  }