@bettergi/types 0.1.2 → 0.1.4

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/objects/file.d.ts CHANGED
@@ -49,6 +49,27 @@ declare global {
49
49
  */
50
50
  function readImageMatSync(path: string): Mat;
51
51
 
52
+ /**
53
+ * 读取Mat图片,并调整到指定尺寸
54
+ * @param path 文件路径(相对于脚本根目录)
55
+ * @param width 调整后的宽度
56
+ * @param height 调整后的高度
57
+ * @param interpolation 插值算法(默认值:1)
58
+ * - 0: 最近邻插值
59
+ * - 1: 双线性插值
60
+ * - 2: 双三次插值
61
+ * - 3: 像素区域关系重采样
62
+ * - 4: Lanczos插值
63
+ * - 5: 精确双线性插值
64
+ * @since 0.54.0
65
+ */
66
+ function readImageMatWithResizeSync(
67
+ path: string,
68
+ width: number,
69
+ height: number,
70
+ interpolation?: number
71
+ ): Mat;
72
+
52
73
  /**
53
74
  * 输出文本文件
54
75
  * @param path 文件路径(相对于脚本根目录,会自动创建目录)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bettergi/types",
3
- "version": "0.1.2",
4
- "description": "TypeScript Definitions for BetterGI JavaScript",
3
+ "version": "0.1.4",
4
+ "description": "BetterGI TypeScript 类型定义",
5
5
  "type": "module",
6
6
  "author": "Bread Grocery<https://github.com/breadgrocery>",
7
7
  "license": "MIT",
@@ -16,7 +16,7 @@ declare global {
16
16
  namespace BetterGenshinImpact.Core.Recognition {
17
17
  class RecognitionObject {
18
18
  /** 匹配类型 */
19
- recognitionType: RecognitionTypes;
19
+ recognitionType: BetterGenshinImpact.Core.Recognition.RecognitionTypes;
20
20
 
21
21
  /** 感兴趣的区域 */
22
22
  regionOfInterest: Rect;
@@ -82,6 +82,18 @@ declare global {
82
82
  */
83
83
  maxMatchCount: number;
84
84
 
85
+ /**
86
+ * 是否启用二值化后模板匹配
87
+ * @default false
88
+ */
89
+ useBinaryMatch: boolean;
90
+
91
+ /**
92
+ * 二值化阈值
93
+ * @default 128
94
+ */
95
+ binaryThreshold: number;
96
+
85
97
  /** 颜色匹配方式 */
86
98
  colorConversionCode: ColorConversionCodes;
87
99
 
@@ -98,7 +110,7 @@ declare global {
98
110
  matchCount: number;
99
111
 
100
112
  /** OCR 引擎 */
101
- ocrEngine: OcrEngineTypes;
113
+ ocrEngine: BetterGenshinImpact.Core.Recognition.OcrEngineTypes;
102
114
 
103
115
  /** 文字识别替换字典(部分文字识别结果不准确) */
104
116
  replaceDictionary: System.Collections.Generic.Dictionary<string, string[]>;
@@ -112,20 +124,29 @@ declare global {
112
124
  /** 正则匹配 多个值全匹配的情况下才算成功 */
113
125
  regexMatchText: System.Collections.Generic.List<string>;
114
126
 
127
+ /** 用于多个OCR结果的匹配 */
128
+ text: string;
129
+
115
130
  /** 初始化模板 */
116
- initTemplate(): RecognitionObject;
131
+ initTemplate(): BetterGenshinImpact.Core.Recognition.RecognitionObject;
117
132
 
118
- /**
119
- * 识别图片模板
120
- * @param mat 模板图片
121
- */
122
- static templateMatch(mat: Mat): RecognitionObject;
133
+ clone(): BetterGenshinImpact.Core.Recognition.RecognitionObject;
123
134
 
124
135
  /**
125
136
  * 识别图片模板
126
137
  * @param mat 模板图片
127
138
  */
128
- static templateMatch(mat: Mat): RecognitionObject;
139
+ static templateMatch(mat: Mat): BetterGenshinImpact.Core.Recognition.RecognitionObject;
140
+ // overload
141
+ static templateMatch(
142
+ mat: Mat,
143
+ useMask: boolean
144
+ ): BetterGenshinImpact.Core.Recognition.RecognitionObject;
145
+ static templateMatch(
146
+ mat: Mat,
147
+ useMask: boolean,
148
+ maskColor: System.Drawing.Color
149
+ ): BetterGenshinImpact.Core.Recognition.RecognitionObject;
129
150
 
130
151
  /**
131
152
  * 在指定区域识别图片模板
@@ -135,7 +156,13 @@ declare global {
135
156
  * @param w 宽度
136
157
  * @param h 高度
137
158
  */
138
- static templateMatch(mat: Mat, x: number, y: number, w: number, h: number): RecognitionObject;
159
+ static templateMatch(
160
+ mat: Mat,
161
+ x: number,
162
+ y: number,
163
+ w: number,
164
+ h: number
165
+ ): BetterGenshinImpact.Core.Recognition.RecognitionObject;
139
166
 
140
167
  /**
141
168
  * 识别指定区域
@@ -144,16 +171,29 @@ declare global {
144
171
  * @param w 宽度
145
172
  * @param h 高度
146
173
  */
147
- static ocr(x: number, y: number, w: number, h: number): RecognitionObject;
174
+ static ocr(
175
+ x: number,
176
+ y: number,
177
+ w: number,
178
+ h: number
179
+ ): BetterGenshinImpact.Core.Recognition.RecognitionObject;
148
180
 
149
181
  /**
150
182
  * 识别矩形区域
151
183
  * @param rect 矩形
152
184
  */
153
- static ocr(rect: Rect): RecognitionObject;
185
+ static ocr(rect: Rect): BetterGenshinImpact.Core.Recognition.RecognitionObject;
186
+
187
+ static ocrMatch(
188
+ x: number,
189
+ y: number,
190
+ w: number,
191
+ h: number,
192
+ ...matchTexts: string[]
193
+ ): BetterGenshinImpact.Core.Recognition.RecognitionObject;
154
194
 
155
195
  /** 识别文字 */
156
- static readonly ocrThis: RecognitionObject;
196
+ static readonly ocrThis: BetterGenshinImpact.Core.Recognition.RecognitionObject;
157
197
  }
158
198
  }
159
199
  export import RecognitionObject = BetterGenshinImpact.Core.Recognition.RecognitionObject;