ms-types 0.9.39 → 0.9.40

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-types",
3
- "version": "0.9.39",
3
+ "version": "0.9.40",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
package/types/image.d.ts CHANGED
@@ -293,6 +293,33 @@ declare namespace image {
293
293
  /** 仅 method=99 返回:命中时模板的纵向缩放比例 */
294
294
  scaleY?: number;
295
295
  }[];
296
+ /**
297
+ * 按 kjst 模板找图
298
+ * @param imageId 图片id,通常为 `"screen"`
299
+ * @param kjstPath res 下的 kjst 文件名,不要带 `res/` 前缀
300
+ * @returns 矩形数组,坐标已换算到传入图片(`screen` 即屏幕)像素,可直接 click;OCR 命中额外含 `text`
301
+ * @example
302
+ * const hits = image.findImageEx("screen", "login.kjst")
303
+ * if (hits.length > 0) {
304
+ * logi(hits[0].x, hits[0].y)
305
+ * }
306
+ */
307
+ function findImageEx(
308
+ imageId: string,
309
+ kjstPath: string,
310
+ ): {
311
+ index: number;
312
+ x: number;
313
+ y: number;
314
+ width: number;
315
+ height: number;
316
+ confidence: number;
317
+ centerX: number;
318
+ centerY: number;
319
+ ex: number;
320
+ ey: number;
321
+ text?: string;
322
+ }[];
296
323
  /**
297
324
  * 裁剪图片
298
325
  * @param imageId 图片id
@@ -23,6 +23,7 @@ local _Image = {}
23
23
  ---@field ey integer 右下角y坐标
24
24
  ---@field scaleX number|nil 仅 method=99:命中时模板横向缩放
25
25
  ---@field scaleY number|nil 仅 method=99:命中时模板纵向缩放
26
+ ---@field text string|nil OCR 命中文字
26
27
 
27
28
  ---@class FindImageOptions
28
29
  ---@field scaleFactors number[]|nil 仅 method=99:模板缩放比例列表
@@ -144,6 +145,12 @@ function _Image.cmpColor(id, points, threshold) return true end
144
145
  function _Image.findImage(id, templateImageId, x, y, ex, ey, threshold, limit,
145
146
  method, rgb, options) return {} end
146
147
 
148
+ --- 按 kjst 模板找图
149
+ --- @param id string 图片ID,通常为 screen
150
+ --- @param kjstPath string res 下的 kjst 文件名
151
+ --- @return Rect[] 结果矩形,坐标已换算到传入图(screen 即屏幕)像素,可直接 click;OCR 命中含 text
152
+ function _Image.findImageEx(id, kjstPath) return {} end
153
+
147
154
  --- 多点找色
148
155
  --- @param id string 图片ID
149
156
  --- @param firstColor string 首色 "#RRGGBB" 或 "#RRGGBB"
@@ -14,11 +14,11 @@ local _Yolo = {}
14
14
  ---@field confidence number 置信度
15
15
  ---@field classId integer 类别 ID
16
16
 
17
- --- 加载 YOLO 模型(版本 8/11/26)
17
+ --- 加载 YOLO 模型(版本 5/8/11/26)
18
18
  --- @param paramPath string ncnn param 路径
19
19
  --- @param binPath string ncnn bin 路径
20
20
  --- @param nc integer|nil 标签数量;传 0 或省略时按模型输出推断
21
- --- @param version integer|nil 模型版本,缺省 0 按 v11 处理
21
+ --- @param version integer|nil 模型版本,缺省 0 按 v11 处理;5 为官方 YOLOv5 6.0/6.2/7.0,兼容官方 export 单输出和三头原始特征
22
22
  --- @param useGpu boolean|nil 是否启用 GPU,默认 false
23
23
  --- @return string|nil 模型ID(失败返回 nil)
24
24
  function _Yolo.load(paramPath, binPath, nc, version, useGpu) return nil end
package/types/yolo.d.ts CHANGED
@@ -52,7 +52,7 @@ declare namespace yolo {
52
52
  * @param paramPath ncnn模型的param文件的绝对路径
53
53
  * @param binPath ncnn模型的bin文件绝对路径
54
54
  * @param nc 模型的标签数量;传 0 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空数组
55
- * @param version 模型版本,默认11, 支持 8 11 26
55
+ * @param version 模型版本,默认11, 支持 5 8 11 26。5 为官方 YOLOv5 6.0/6.2/7.0,兼容官方 export 单输出和三头原始特征
56
56
  * @param useGpu 是否使用 GPU 加载
57
57
  * @returns 加载成功返回模型ID字符串,失败返回null
58
58
  * @example
@@ -55,7 +55,7 @@ declare namespace $YOLO {
55
55
  * @param ncnn模型的param文件路径 ncnn模型的param文件的绝对路径
56
56
  * @param ncnn模型的bin文件路径 ncnn模型的bin文件绝对路径
57
57
  * @param 标签数量 模型的标签数量;传 0 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空数组
58
- * @param 模型版本 模型版本,默认11, 支持 8 11 26
58
+ * @param 模型版本 模型版本,默认11, 支持 5 8 11 26。5 为官方 YOLOv5 6.0/6.2/7.0,兼容官方 export 单输出和三头原始特征
59
59
  * @param useGpu 是否使用 GPU 加载
60
60
  * @returns 加载成功返回模型ID字符串,失败返回null
61
61
  * @example
@@ -291,6 +291,33 @@ declare namespace $图片 {
291
291
  /** 仅方法=99 返回:命中时模板的纵向缩放比例 */
292
292
  scaleY?: 数字;
293
293
  }[];
294
+ /**
295
+ * 按 kjst 模板找图
296
+ * @param 图片ID 图片id,通常为 `"screen"`
297
+ * @param kjst路径 res 下的 kjst 文件名,不要带 `res/` 前缀
298
+ * @returns 矩形数组,坐标已换算到传入图片(`screen` 即屏幕)像素,可直接点击;OCR 命中额外含 `text`
299
+ * @example
300
+ * const 命中 = $图片.找图Ex("screen", "login.kjst")
301
+ * if (命中.length > 0) {
302
+ * $打印信息日志(命中[0].x, 命中[0].y)
303
+ * }
304
+ */
305
+ function 找图Ex(
306
+ 图片ID: 字符串,
307
+ kjst路径: 字符串,
308
+ ): {
309
+ index: 数字;
310
+ x: 数字;
311
+ y: 数字;
312
+ width: 数字;
313
+ height: 数字;
314
+ confidence: 数字;
315
+ centerX: 数字;
316
+ centerY: 数字;
317
+ ex: 数字;
318
+ ey: 数字;
319
+ text?: 字符串;
320
+ }[];
294
321
  /**
295
322
  * 裁剪图片
296
323
  * @param 图片ID