ms-types 0.0.28 → 0.0.30
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/package.json +1 -1
- package/types/appleOcr.d.ts +35 -37
- package/types/file.d.ts +8 -0
- package/types/utils.d.ts +0 -8
package/package.json
CHANGED
package/types/appleOcr.d.ts
CHANGED
|
@@ -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,24 @@ declare namespace appleOcr {
|
|
|
27
53
|
): OCRResult[];
|
|
28
54
|
|
|
29
55
|
/**
|
|
30
|
-
*
|
|
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
|
-
* @
|
|
37
|
-
* @returns 识别到的文本字符串数组
|
|
62
|
+
* @returns 识别结果数组,包含文本、置信度、坐标等信息
|
|
38
63
|
* @example
|
|
39
|
-
* const
|
|
40
|
-
*
|
|
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
|
|
69
|
+
function recognizeNumbers(
|
|
45
70
|
input: string,
|
|
46
71
|
x: number,
|
|
47
72
|
y: number,
|
|
48
73
|
ex: number,
|
|
49
|
-
ey: number
|
|
50
|
-
|
|
51
|
-
): string[];
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* OCR识别结果接口
|
|
55
|
-
*/
|
|
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
|
-
}
|
|
74
|
+
ey: number
|
|
75
|
+
): OCRResult[];
|
|
78
76
|
}
|
package/types/file.d.ts
CHANGED
|
@@ -52,6 +52,14 @@ declare namespace file {
|
|
|
52
52
|
* @example file.readFile("config.json")
|
|
53
53
|
*/
|
|
54
54
|
function readFile(path: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* 读取资源文件
|
|
57
|
+
* @param fileName 文件名
|
|
58
|
+
* @returns 文件内容
|
|
59
|
+
* @example
|
|
60
|
+
* file.readResFile("test.txt")
|
|
61
|
+
*/
|
|
62
|
+
function readResFile(fileName: string): string | null;
|
|
55
63
|
/**
|
|
56
64
|
* 删除文件内容
|
|
57
65
|
* @param path 文件路径
|
package/types/utils.d.ts
CHANGED
|
@@ -10,14 +10,6 @@ declare namespace utils {
|
|
|
10
10
|
* utils.timeFormat("yyyy-MM-dd hh:mm:ss")
|
|
11
11
|
*/
|
|
12
12
|
function timeFormat(format: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* 读取资源文件
|
|
15
|
-
* @param fileName 文件名
|
|
16
|
-
* @returns 文件内容
|
|
17
|
-
* @example
|
|
18
|
-
* utils.readResFile("test.txt")
|
|
19
|
-
*/
|
|
20
|
-
function readResFile(fileName: string): string | null;
|
|
21
13
|
/**
|
|
22
14
|
* 生成随机数
|
|
23
15
|
* @param min 最小值
|