ms-types 0.10.10 → 0.10.11

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 (36) hide show
  1. package/package.json +1 -1
  2. package/types/cryptoUtils.d.ts +50 -36
  3. package/types/dotocr.d.ts +9 -2
  4. package/types/file.d.ts +1 -1
  5. package/types/hid.d.ts +46 -4
  6. package/types/image.d.ts +447 -447
  7. package/types/lua/action.lua +6 -6
  8. package/types/lua/cryptoUtils.lua +7 -7
  9. package/types/lua/cv.lua +142 -142
  10. package/types/lua/dotocr.lua +4 -4
  11. package/types/lua/file.lua +1 -1
  12. package/types/lua/global.lua +5 -3
  13. package/types/lua/hid.lua +22 -22
  14. package/types/lua/http.lua +26 -11
  15. package/types/lua/image.lua +9 -5
  16. package/types/lua/node.lua +1 -1
  17. package/types/lua/pip.lua +6 -6
  18. package/types/lua/yolo.lua +1 -1
  19. package/types/lua/yolocls.lua +1 -1
  20. package/types/node.d.ts +1 -0
  21. package/types/opencv.d.ts +571 -38
  22. package/types/paddleocr.d.ts +1 -0
  23. package/types/pip.d.ts +11 -0
  24. package/types/system.d.ts +1 -0
  25. package/types/tts.d.ts +1 -1
  26. package/types/ui.d.ts +2 -0
  27. package/types/web.d.ts +16 -0
  28. package/types/zh/HID/346/250/241/345/235/227.d.ts +46 -4
  29. package/types/zh/PaddleOCR/346/250/241/345/235/227.d.ts +1 -0
  30. package/types/zh//345/212/250/344/275/234/346/250/241/345/235/227.d.ts +1 -1
  31. package/types/zh//346/202/254/346/265/256/347/252/227/346/250/241/345/235/227.d.ts +10 -0
  32. package/types/zh//346/226/207/344/273/266/346/250/241/345/235/227.d.ts +1 -1
  33. package/types/zh//347/202/271/351/230/265OCR/346/250/241/345/235/227.d.ts +9 -2
  34. package/types/zh//347/263/273/347/273/237/346/250/241/345/235/227.d.ts +1 -0
  35. package/types/zh//350/212/202/347/202/271/346/250/241/345/235/227.d.ts +1 -0
  36. package/types/zh//350/247/206/345/233/276/346/250/241/345/235/227.d.ts +2 -0
package/types/opencv.d.ts CHANGED
@@ -240,110 +240,369 @@ declare namespace cv {
240
240
  const CV_32FC3: number;
241
241
 
242
242
  // ---- IO / 生命周期 ----
243
- /** 截屏为 Mat;参数与 `image.captureScreen` 一致,无参全屏 */
243
+ /**
244
+ * 截屏为 Mat;参数与 `image.captureScreen` 一致,无参全屏
245
+ * @example cv.capture(100, 100, 200, 200)
246
+ */
244
247
  function capture(
245
248
  x?: number,
246
249
  y?: number,
247
250
  ex?: number,
248
251
  ey?: number,
249
252
  ): Mat | null;
250
- /**
253
+ /**
251
254
  * 读取图片为 Mat 句柄。`cv` 中**唯一**支持路径类输入的加载入口(与 `image.readImage` 同源):
252
255
  * msbundle/res 相对路径、手机绝对路径、`$MS_IMG$_…` imageId、`screen` / `shortcut` /
253
256
  * `actionScreenshot`、HTTP(S)、`media:n`、`data:image/...;base64,...` 等。
254
257
  * 其它算子只接受 Mat 句柄。
255
- */
258
+ * @example cv.imread("/path/to/file.png")
259
+ */
256
260
  function imread(path: string): Mat | null;
257
- /** 仅解码 base64 / data URI;路径与 imageId 请用 `imread` */
258
- function imdecode(data: string): Mat | null;
259
261
  /**
262
+ * 仅解码 base64 / data URI;路径与 imageId 请用 `imread`
263
+ * @example cv.imdecode("data:image/png;base64,iVBORw0KGgo=")
264
+ */
265
+ function imdecode(data: string): Mat | null;
266
+ /**
260
267
  * 保存 Mat 到本地文件,格式由扩展名决定。
261
268
  * 可用 `png` / `apng` / `jpg` / `jpeg` / `jpe` / `bmp` / `dib` / `webp` /
262
269
  * `ppm` / `pgm` / `pbm` / `pnm` / `pam` / `sr` / `ras`;
263
270
  * 其它扩展名或通道数不是 1 / 3 / 4 的 Mat 返回 `false`。
264
- */
271
+ * @example cv.imwrite("/tmp/out.png", cv.capture())
272
+ */
265
273
  function imwrite(path: string, mat: Mat): boolean;
266
- /** 编码为纯 base64;扩展名与通道限制同 `imwrite`,`quality` 取值 1–100(仅 jpg 有效) */
274
+ /**
275
+ * 编码为纯 base64;扩展名与通道限制同 `imwrite`,`quality` 取值 1–100(仅 jpg 有效)
276
+ * @example cv.imencode(".png", cv.capture(), 90)
277
+ */
267
278
  function imencode(ext: string, mat: Mat, quality?: number): string | null;
279
+ /**
280
+ * 从 imageId 转为 Mat 句柄
281
+ * @example cv.fromImageId("screen")
282
+ */
268
283
  function fromImageId(imageId: string): Mat | null;
284
+ /**
285
+ * Mat 句柄转为 imageId
286
+ * @example cv.toImageId(cv.capture())
287
+ */
269
288
  function toImageId(mat: Mat): string | null;
289
+ /**
290
+ * 创建 Mat
291
+ * @example cv.Mat({ rows: 100, cols: 100, type: cv.CV_8UC3, scalar: [0, 0, 0] })
292
+ */
270
293
  function Mat(options: { rows: number; cols: number; type?: number; scalar?: number[] }): Mat | null;
294
+ /**
295
+ * 创建全 0 Mat
296
+ * @example cv.zeros({ rows: 100, cols: 100, type: cv.CV_8UC1 })
297
+ */
271
298
  function zeros(options: { rows: number; cols: number; type?: number }): Mat | null;
299
+ /**
300
+ * 创建全 1 Mat
301
+ * @example cv.ones({ rows: 100, cols: 100, type: cv.CV_8UC1 })
302
+ */
272
303
  function ones(options: { rows: number; cols: number; type?: number }): Mat | null;
304
+ /**
305
+ * 复制 Mat
306
+ * @example cv.clone(cv.capture())
307
+ */
273
308
  function clone(mat: Mat): Mat | null;
309
+ /**
310
+ * 判断 Mat 是否为空
311
+ * @example cv.empty(cv.capture())
312
+ */
274
313
  function empty(mat: Mat): boolean;
314
+ /**
315
+ * 判断句柄是否已释放
316
+ * @example cv.isRelease(cv.capture())
317
+ */
275
318
  function isRelease(mat: Mat): boolean;
319
+ /**
320
+ * 释放 Mat 句柄
321
+ * @example cv.release(cv.capture())
322
+ */
276
323
  function release(mat: Mat): void;
324
+ /**
325
+ * 释放全部 Mat 句柄
326
+ * @example cv.releaseAll()
327
+ */
277
328
  function releaseAll(): void;
329
+ /**
330
+ * 获取 Mat 宽高与类型
331
+ * @example cv.getSize(cv.capture())
332
+ */
278
333
  function getSize(mat: Mat): MatInfo | null;
334
+ /**
335
+ * 读取指定像素
336
+ * @example cv.at(cv.capture(), 10, 10)
337
+ */
279
338
  function at(mat: Mat, row: number, col: number): number[] | null;
339
+ /**
340
+ * 写入指定像素
341
+ * @example cv.set(cv.capture(), { row: 10, col: 10, value: [0, 255, 0] })
342
+ */
280
343
  function set(mat: Mat, options: { row: number; col: number; value: number | number[] }): boolean;
344
+ /**
345
+ * 复制为新的 Mat
346
+ * @example cv.copyTo(cv.capture())
347
+ */
281
348
  function copyTo(mat: Mat, mask?: Mat | null): Mat | null;
282
349
 
283
350
  // ---- 颜色 / 运算 ----
284
- /** 源图通道必须和转换码一致,例如 `COLOR_BGR2GRAY` 要 3 通道。 */
351
+ /**
352
+ * 源图通道必须和转换码一致,例如 `COLOR_BGR2GRAY` 要 3 通道。
353
+ * @example cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY)
354
+ */
285
355
  function cvtColor(mat: Mat, code: number): Mat | null;
356
+ /**
357
+ * 阈值化
358
+ * @example cv.threshold(cv.capture(), { thresh: 127, maxval: 255, type: cv.THRESH_BINARY })
359
+ */
286
360
  function threshold(mat: Mat, options: ThresholdOptions): Mat | null;
287
- /** 只接受 `CV_8UC1`。 */
361
+ /**
362
+ * 只接受 `CV_8UC1`。
363
+ * @example cv.adaptiveThreshold(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { maxValue: 255, adaptiveMethod: cv.ADAPTIVE_THRESH_GAUSSIAN_C, thresholdType: cv.THRESH_BINARY, blockSize: 11, C: 2 })
364
+ */
288
365
  function adaptiveThreshold(mat: Mat, options: AdaptiveThresholdOptions): Mat | null;
366
+ /**
367
+ * 按颜色范围生成掩膜
368
+ * @example cv.inRange(cv.capture(), { lowerb: [0, 0, 0], upperb: [50, 50, 50] })
369
+ */
289
370
  function inRange(mat: Mat, options: InRangeOptions): Mat | null;
371
+ /**
372
+ * 按位与
373
+ * @example cv.bitwise_and(cv.capture(), { src2: cv.imread("/path/to/tpl.png") })
374
+ */
290
375
  function bitwise_and(src1: Mat, options: BitwiseOptions): Mat | null;
376
+ /**
377
+ * 按位或
378
+ * @example cv.bitwise_or(cv.capture(), { src2: cv.imread("/path/to/tpl.png") })
379
+ */
291
380
  function bitwise_or(src1: Mat, options: BitwiseOptions): Mat | null;
381
+ /**
382
+ * 按位异或
383
+ * @example cv.bitwise_xor(cv.capture(), { src2: cv.imread("/path/to/tpl.png") })
384
+ */
292
385
  function bitwise_xor(src1: Mat, options: BitwiseOptions): Mat | null;
386
+ /**
387
+ * 按位取反
388
+ * @example cv.bitwise_not(cv.capture())
389
+ */
293
390
  function bitwise_not(mat: Mat, options?: { mask?: Mat }): Mat | null;
391
+ /**
392
+ * 逐像素绝对差
393
+ * @example cv.absdiff(cv.capture(), { src2: cv.imread("/path/to/tpl.png") })
394
+ */
294
395
  function absdiff(src1: Mat, options: { src2: Mat }): Mat | null;
396
+ /**
397
+ * 加权叠加
398
+ * @example cv.addWeighted(cv.capture(), { src2: cv.imread("/path/to/tpl.png"), alpha: 0.5, beta: 0.5, gamma: 0 })
399
+ */
295
400
  function addWeighted(src1: Mat, options: { src2: Mat; alpha?: number; beta?: number; gamma?: number }): Mat | null;
401
+ /**
402
+ * 缩放后取绝对值并转为 8 位
403
+ * @example cv.convertScaleAbs(cv.capture(), { alpha: 1.2, beta: 10 })
404
+ */
296
405
  function convertScaleAbs(mat: Mat, options?: { alpha?: number; beta?: number }): Mat | null;
297
- /** 只接受单通道 Mat;多通道返回 `-1`。 */
406
+ /**
407
+ * 只接受单通道 Mat;多通道返回 `-1`。
408
+ * @example cv.countNonZero(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
409
+ */
298
410
  function countNonZero(mat: Mat): number;
299
- /** 只接受单通道 Mat;多通道返回 `null`。可选 `mask` 必须是 `CV_8UC1`。 */
411
+ /**
412
+ * 只接受单通道 Mat;多通道返回 `null`。可选 `mask` 必须是 `CV_8UC1`。
413
+ * @example cv.minMaxLoc(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
414
+ */
300
415
  function minMaxLoc(mat: Mat, options?: { mask?: Mat }): MinMaxLocResult | null;
416
+ /**
417
+ * 计算均值
418
+ * @example cv.mean(cv.capture())
419
+ */
301
420
  function mean(mat: Mat, options?: { mask?: Mat }): number[] | null;
421
+ /**
422
+ * 分离通道
423
+ * @example cv.split(cv.capture())
424
+ */
302
425
  function split(mat: Mat): Mat[] | null;
426
+ /**
427
+ * 合并通道
428
+ * @example cv.merge(cv.split(cv.capture()))
429
+ */
303
430
  function merge(channels: Mat[]): Mat | null;
304
431
 
305
432
  // ---- 滤波 / 边缘 ----
433
+ /**
434
+ * 高斯模糊
435
+ * @example cv.GaussianBlur(cv.capture(), { ksize: 5, sigmaX: 1.5 })
436
+ */
306
437
  function GaussianBlur(mat: Mat, options: BlurOptions): Mat | null;
438
+ /**
439
+ * 均值模糊
440
+ * @example cv.blur(cv.capture(), { ksize: 5 })
441
+ */
307
442
  function blur(mat: Mat, options: { ksize: number | [number, number] | Size }): Mat | null;
443
+ /**
444
+ * 中值滤波
445
+ * @example cv.medianBlur(cv.capture(), { ksize: 5 })
446
+ */
308
447
  function medianBlur(mat: Mat, options: { ksize: number }): Mat | null;
309
- /** 只接受 1 或 3 通道,深度 `CV_8U` 或 `CV_32F`。 */
448
+ /**
449
+ * 只接受 1 或 3 通道,深度 `CV_8U` 或 `CV_32F`。
450
+ * @example cv.bilateralFilter(cv.capture(), { d: 9, sigmaColor: 75, sigmaSpace: 75 })
451
+ */
310
452
  function bilateralFilter(mat: Mat, options: { d?: number; sigmaColor?: number; sigmaSpace?: number }): Mat | null;
311
- /** 只接受 8 位图(`CV_8U`,1/3/4 通道均可)。 */
453
+ /**
454
+ * 只接受 8 位图(`CV_8U`,1/3/4 通道均可)。
455
+ * @example cv.Canny(cv.capture(), { threshold1: 100, threshold2: 200 })
456
+ */
312
457
  function Canny(mat: Mat, options: CannyOptions): Mat | null;
458
+ /**
459
+ * Sobel 边缘
460
+ * @example cv.Sobel(cv.capture(), { dx: 1, dy: 0, ksize: 3 })
461
+ */
313
462
  function Sobel(mat: Mat, options: { ddepth?: number; dx?: number; dy?: number; ksize?: number; scale?: number; delta?: number }): Mat | null;
463
+ /**
464
+ * Laplacian 边缘
465
+ * @example cv.Laplacian(cv.capture(), { ksize: 3 })
466
+ */
314
467
  function Laplacian(mat: Mat, options: { ddepth?: number; ksize?: number; scale?: number; delta?: number }): Mat | null;
315
- /** 只接受 `CV_8UC1`。 */
468
+ /**
469
+ * 只接受 `CV_8UC1`。
470
+ * @example cv.equalizeHist(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
471
+ */
316
472
  function equalizeHist(mat: Mat): Mat | null;
317
473
 
318
474
  // ---- 几何 / 绘制 ----
475
+ /**
476
+ * 缩放
477
+ * @example cv.resize(cv.capture(), { width: 200, height: 200 })
478
+ */
319
479
  function resize(mat: Mat, options: ResizeOptions): Mat | null;
480
+ /**
481
+ * 裁剪
482
+ * @example cv.crop(cv.capture(), { x: 10, y: 10, ex: 200, ey: 200 })
483
+ */
320
484
  function crop(mat: Mat, options: CropOptions): Mat | null;
485
+ /**
486
+ * 旋转
487
+ * @example cv.rotate(cv.capture(), cv.ROTATE_90_CLOCKWISE)
488
+ */
321
489
  function rotate(mat: Mat, rotateCode: number): Mat | null;
490
+ /**
491
+ * 翻转
492
+ * @example cv.flip(cv.capture(), 1)
493
+ */
322
494
  function flip(mat: Mat, flipCode: number): Mat | null;
495
+ /**
496
+ * 扩展边界
497
+ * @example cv.copyMakeBorder(cv.capture(), { top: 10, bottom: 10, left: 10, right: 10, borderType: cv.BORDER_CONSTANT })
498
+ */
323
499
  function copyMakeBorder(mat: Mat, options: { top?: number; bottom?: number; left?: number; right?: number; borderType?: number; value?: number[] }): Mat | null;
500
+ /**
501
+ * 生成 2D 旋转矩阵
502
+ * @example cv.getRotationMatrix2D({ center: { x: 100, y: 100 }, angle: 45, scale: 1 })
503
+ */
324
504
  function getRotationMatrix2D(options: { center: Point | [number, number]; angle?: number; scale?: number }): Mat | null;
505
+ /**
506
+ * 仿射变换
507
+ * @example cv.warpAffine(cv.capture(), { M: cv.getRotationMatrix2D({ center: { x: 100, y: 100 }, angle: 45, scale: 1 }), width: 200, height: 200 })
508
+ */
325
509
  function warpAffine(mat: Mat, options: { M: Mat; width?: number; height?: number; flags?: number }): Mat | null;
326
- /** 就地绘制,返回同一句柄 */
510
+ /**
511
+ * 就地绘制,返回同一句柄
512
+ * @example cv.rectangle(cv.capture(), { pt1: { x: 10, y: 10 }, pt2: { x: 200, y: 200 }, color: [0, 0, 255], thickness: 2 })
513
+ */
327
514
  function rectangle(mat: Mat, options: RectangleOptions): Mat | null;
515
+ /**
516
+ * 绘制圆
517
+ * @example cv.circle(cv.capture(), { center: { x: 100, y: 100 }, radius: 40, color: [0, 0, 255], thickness: 2 })
518
+ */
328
519
  function circle(mat: Mat, options: CircleOptions): Mat | null;
520
+ /**
521
+ * 绘制直线
522
+ * @example cv.line(cv.capture(), { pt1: { x: 10, y: 10 }, pt2: { x: 200, y: 200 }, color: [0, 0, 255], thickness: 2 })
523
+ */
329
524
  function line(mat: Mat, options: LineOptions): Mat | null;
525
+ /**
526
+ * 绘制文字
527
+ * @example cv.putText(cv.capture(), { text: "hello", org: { x: 20, y: 40 }, fontScale: 1, color: [0, 0, 255] })
528
+ */
330
529
  function putText(mat: Mat, options: PutTextOptions): Mat | null;
530
+ /**
531
+ * 填充多边形
532
+ * @example cv.fillPoly(cv.capture(), { pts: [[{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }]], color: [0, 0, 255] })
533
+ */
331
534
  function fillPoly(mat: Mat, options: { pts: Point[][] | Point[]; color?: number[] | string }): Mat | null;
535
+ /**
536
+ * 绘制折线
537
+ * @example cv.polylines(cv.capture(), { pts: [[{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }]], isClosed: true, color: [0, 0, 255], thickness: 2 })
538
+ */
332
539
  function polylines(mat: Mat, options: { pts: Point[][] | Point[]; isClosed?: boolean; color?: number[] | string; thickness?: number }): Mat | null;
540
+ /**
541
+ * 绘制轮廓
542
+ * @example cv.drawContours(cv.capture(), { contours: [[{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }]], color: [0, 0, 255], thickness: 2 })
543
+ */
333
544
  function drawContours(mat: Mat, options: { contours: Point[][]; contourIdx?: number; color?: number[] | string; thickness?: number }): Mat | null;
334
545
 
335
546
  // ---- 匹配 / 轮廓 / 形态学 ----
547
+ /**
548
+ * 模板匹配,返回结果图
549
+ * @example cv.matchTemplate(cv.capture(), cv.imread("/path/to/tpl.png"), { method: cv.TM_CCOEFF_NORMED })
550
+ */
336
551
  function matchTemplate(image: Mat, templ: Mat, options?: MatchTemplateOptions): Mat | null;
552
+ /**
553
+ * 模板匹配,返回最佳位置
554
+ * @example cv.matchTemplateLoc(cv.capture(), cv.imread("/path/to/tpl.png"), { method: cv.TM_CCOEFF_NORMED })
555
+ */
337
556
  function matchTemplateLoc(image: Mat, templ: Mat, options?: MatchTemplateOptions): MatchLocResult | null;
557
+ /**
558
+ * 查找轮廓
559
+ * @example cv.findContours(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { mode: cv.RETR_EXTERNAL, method: cv.CHAIN_APPROX_SIMPLE })
560
+ */
338
561
  function findContours(mat: Mat, options?: FindContoursOptions): { contours: Point[][]; hierarchy: number[][] } | null;
562
+ /**
563
+ * 外接正矩形
564
+ * @example cv.boundingRect([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }])
565
+ */
339
566
  function boundingRect(matOrPoints: Mat | Point[]): Rect | null;
567
+ /**
568
+ * 最小外接旋转矩形
569
+ * @example cv.minAreaRect([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }])
570
+ */
340
571
  function minAreaRect(points: Point[]): RotatedRect | null;
572
+ /**
573
+ * 轮廓面积
574
+ * @example cv.contourArea([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], false)
575
+ */
341
576
  function contourArea(matOrPoints: Mat | Point[], oriented?: boolean): number;
577
+ /**
578
+ * 轮廓周长
579
+ * @example cv.arcLength([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], true)
580
+ */
342
581
  function arcLength(points: Point[], closed?: boolean): number;
582
+ /**
583
+ * 多边形逼近
584
+ * @example cv.approxPolyDP([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], { epsilon: 2, closed: true })
585
+ */
343
586
  function approxPolyDP(points: Point[], options: { epsilon?: number; closed?: boolean }): Point[] | null;
587
+ /**
588
+ * 腐蚀
589
+ * @example cv.erode(cv.capture(), { kernel: cv.getStructuringElement({ shape: cv.MORPH_RECT, ksize: 3 }), iterations: 1 })
590
+ */
344
591
  function erode(mat: Mat, options: MorphOptions): Mat | null;
592
+ /**
593
+ * 膨胀
594
+ * @example cv.dilate(cv.capture(), { kernel: cv.getStructuringElement({ shape: cv.MORPH_RECT, ksize: 3 }), iterations: 1 })
595
+ */
345
596
  function dilate(mat: Mat, options: MorphOptions): Mat | null;
597
+ /**
598
+ * 形态学运算
599
+ * @example cv.morphologyEx(cv.capture(), { op: cv.MORPH_OPEN, kernel: cv.getStructuringElement({ shape: cv.MORPH_RECT, ksize: 3 }) })
600
+ */
346
601
  function morphologyEx(mat: Mat, options: MorphologyExOptions): Mat | null;
602
+ /**
603
+ * 生成形态学核
604
+ * @example cv.getStructuringElement({ shape: cv.MORPH_RECT, ksize: 3 })
605
+ */
347
606
  function getStructuringElement(options: StructuringElementOptions): Mat | null;
348
607
 
349
608
  // ---- 特征点 / 匹配 / 单应 ----
@@ -512,78 +771,215 @@ declare namespace cv {
512
771
  const CC_STAT_HEIGHT: number;
513
772
  const CC_STAT_AREA: number;
514
773
 
515
- /**
774
+ /**
516
775
  * SIFT 检测并计算描述子。
517
776
  * @example
518
777
  * const { keypoints, descriptors } = cv.SIFT(src, { nfeatures: 500 })
519
778
  */
520
779
  function SIFT(mat: Mat, options?: SIFTOptions): FeatureResult | null;
521
- /** ORB 检测并计算描述子(二进制描述子,匹配常用 NORM_HAMMING) */
780
+ /**
781
+ * ORB 检测并计算描述子(二进制描述子,匹配常用 NORM_HAMMING)
782
+ * @example cv.ORB(cv.capture(), { nfeatures: 500 })
783
+ */
522
784
  function ORB(mat: Mat, options?: ORBOptions): FeatureResult | null;
523
785
  /** FAST 仅返回关键点(无描述子) */
524
- /** 只接受 `CV_8UC1`。 */
786
+ /**
787
+ * 只接受 `CV_8UC1`。
788
+ * @example cv.FAST(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { threshold: 20 })
789
+ */
525
790
  function FAST(mat: Mat, options?: FASTOptions): { keypoints: KeyPoint[] } | null;
526
791
 
527
- /** 暴力匹配描述子,返回 DMatch 数组 */
792
+ /**
793
+ * 暴力匹配描述子,返回 DMatch 数组
794
+ * @example cv.BFMatcher(cv.capture(), cv.imread("/path/to/tpl.png"), { normType: cv.NORM_HAMMING })
795
+ */
528
796
  function BFMatcher(queryDescriptors: Mat, trainDescriptors: Mat, options?: MatcherOptions): DMatch[] | null;
529
- /** K 近邻匹配;可设 ratio 做 Lowe 筛选 */
797
+ /**
798
+ * K 近邻匹配;可设 ratio 做 Lowe 筛选
799
+ * @example cv.knnMatch(cv.capture(), cv.imread("/path/to/tpl.png"), { k: 2, ratio: 0.75 })
800
+ */
530
801
  function knnMatch(queryDescriptors: Mat, trainDescriptors: Mat, options?: KnnMatchOptions): DMatch[][] | null;
531
802
 
532
- /** 绘制关键点,返回新 Mat 句柄 */
803
+ /**
804
+ * 绘制关键点,返回新 Mat 句柄
805
+ * @example cv.drawKeypoints(cv.capture(), { keypoints: [{ x: 100, y: 100, size: 8 }], color: [0, 0, 255] })
806
+ */
533
807
  function drawKeypoints(mat: Mat, options: DrawKeypointsOptions): Mat | null;
534
- /** 绘制匹配连线 */
808
+ /**
809
+ * 绘制匹配连线
810
+ * @example cv.drawMatches(cv.capture(), { img2: cv.imread("/path/to/tpl.png"), keypoints1: [{ x: 40, y: 40, size: 8 }], keypoints2: [{ x: 80, y: 80, size: 8 }], matches: [{ queryIdx: 0, trainIdx: 0, distance: 0.1 }] })
811
+ */
535
812
  function drawMatches(mat: Mat, options: DrawMatchesOptions): Mat | null;
536
813
 
537
- /** 计算单应矩阵,返回 3x3 Mat 句柄 */
814
+ /**
815
+ * 计算单应矩阵,返回 3x3 Mat 句柄
816
+ * @example cv.findHomography({ srcPoints: [{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], dstPoints: [{ x: 10, y: 10 }, { x: 110, y: 10 }, { x: 60, y: 110 }] })
817
+ */
538
818
  function findHomography(options: FindHomographyOptions): Mat | null;
539
- /** 透视变换图像 */
819
+ /**
820
+ * 透视变换图像
821
+ * @example cv.warpPerspective(cv.capture(), { M: cv.getPerspectiveTransform({ srcPoints: [{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], dstPoints: [{ x: 0, y: 0 }, { x: 200, y: 0 }, { x: 100, y: 200 }] }), width: 200, height: 200 })
822
+ */
540
823
  function warpPerspective(mat: Mat, options: WarpPerspectiveOptions): Mat | null;
541
- /** 用单应矩阵变换点集 */
824
+ /**
825
+ * 用单应矩阵变换点集
826
+ * @example cv.perspectiveTransform([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], { M: cv.getPerspectiveTransform({ srcPoints: [{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], dstPoints: [{ x: 0, y: 0 }, { x: 200, y: 0 }, { x: 100, y: 200 }] }) })
827
+ */
542
828
  function perspectiveTransform(points: Point[], options: { M: Mat }): Point[] | null;
543
829
 
544
- /** Shi-Tomasi 角点 */
830
+ /**
831
+ * Shi-Tomasi 角点
832
+ * @example cv.goodFeaturesToTrack(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { maxCorners: 50, qualityLevel: 0.01, minDistance: 10 })
833
+ */
545
834
  function goodFeaturesToTrack(mat: Mat, options: GoodFeaturesOptions): Point[] | null;
546
- /** 概率霍夫直线,返回 {x1,y1,x2,y2}[] */
835
+ /**
836
+ * 概率霍夫直线,返回 {x1,y1,x2,y2}[]
837
+ * @example cv.HoughLinesP(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { rho: 1, theta: 3.14 / 180, threshold: 50 })
838
+ */
547
839
  function HoughLinesP(mat: Mat, options: HoughLinesPOptions): Array<{ x1: number; y1: number; x2: number; y2: number }> | null;
548
- /** 霍夫圆,返回 {x,y,radius}[] */
840
+ /**
841
+ * 霍夫圆,返回 {x,y,radius}[]
842
+ * @example cv.HoughCircles(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { dp: 1, minDist: 20 })
843
+ */
549
844
  function HoughCircles(mat: Mat, options: HoughCirclesOptions): Array<{ x: number; y: number; radius: number }> | null;
550
845
 
551
- /** CLAHE 对比度受限自适应直方图均衡 */
846
+ /**
847
+ * CLAHE 对比度受限自适应直方图均衡
848
+ * @example cv.CLAHE(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { clipLimit: 2.0, tileGridSize: [8, 8] })
849
+ */
552
850
  function CLAHE(mat: Mat, options?: CLAHEOptions): Mat | null;
851
+ /**
852
+ * 高斯金字塔向下采样
853
+ * @example cv.pyrDown(cv.capture())
854
+ */
553
855
  function pyrDown(mat: Mat): Mat | null;
856
+ /**
857
+ * 高斯金字塔向上采样
858
+ * @example cv.pyrUp(cv.capture())
859
+ */
554
860
  function pyrUp(mat: Mat): Mat | null;
861
+ /**
862
+ * Scharr 导数
863
+ * @example cv.Scharr(cv.capture(), { dx: 1, dy: 0 })
864
+ */
555
865
  function Scharr(mat: Mat, options: { ddepth?: number; dx?: number; dy?: number; scale?: number; delta?: number }): Mat | null;
866
+ /**
867
+ * 方框滤波
868
+ * @example cv.boxFilter(cv.capture(), { ksize: 5 })
869
+ */
556
870
  function boxFilter(mat: Mat, options: { ksize: number | [number, number] | Size; ddepth?: number }): Mat | null;
557
- /** 就地洪水填充,返回填充像素数与外接矩形 */
871
+ /**
872
+ * 就地洪水填充,返回填充像素数与外接矩形
873
+ * @example cv.floodFill(cv.capture(), { seedPoint: { x: 10, y: 10 }, newVal: [0, 0, 255] })
874
+ */
558
875
  function floodFill(mat: Mat, options: FloodFillOptions): { filled: number; rect: Rect } | null;
876
+ /**
877
+ * 凸包
878
+ * @example cv.convexHull([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }])
879
+ */
559
880
  function convexHull(points: Point[], options?: { clockwise?: boolean }): Point[] | null;
560
- /** Mat 输入必须是单通道栅格或 2 通道点集。 */
881
+ /**
882
+ * Mat 输入必须是单通道栅格或 2 通道点集。
883
+ * @example cv.moments([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }])
884
+ */
561
885
  function moments(matOrPoints: Mat | Point[], options?: { binaryImage?: boolean }): MomentsResult | null;
886
+ /**
887
+ * 轮廓形状匹配
888
+ * @example cv.matchShapes([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], [{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }])
889
+ */
562
890
  function matchShapes(contour1: Mat | Point[], contour2: Mat | Point[], options?: { method?: number; parameter?: number }): number;
891
+ /**
892
+ * 连通域及统计
893
+ * @example cv.connectedComponentsWithStats(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
894
+ */
563
895
  function connectedComponentsWithStats(mat: Mat): ConnectedComponentsResult | null;
896
+ /**
897
+ * 距离变换
898
+ * @example cv.distanceTransform(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
899
+ */
564
900
  function distanceTransform(mat: Mat, options?: { distanceType?: number; maskSize?: number }): Mat | null;
565
901
 
566
902
  // ---- 算术 / 归一化 / 拼接 ----
903
+ /**
904
+ * 逐像素相加
905
+ * @example cv.add(cv.capture(), { src2: cv.imread("/path/to/tpl.png") })
906
+ */
567
907
  function add(src1: Mat, options: { src2: Mat; mask?: Mat }): Mat | null;
908
+ /**
909
+ * 逐像素相减
910
+ * @example cv.subtract(cv.capture(), { src2: cv.imread("/path/to/tpl.png") })
911
+ */
568
912
  function subtract(src1: Mat, options: { src2: Mat; mask?: Mat }): Mat | null;
913
+ /**
914
+ * 逐像素相乘
915
+ * @example cv.multiply(cv.capture(), { src2: cv.imread("/path/to/tpl.png") })
916
+ */
569
917
  function multiply(src1: Mat, options: { src2: Mat; scale?: number }): Mat | null;
918
+ /**
919
+ * 逐像素相除
920
+ * @example cv.divide(cv.capture(), { src2: cv.imread("/path/to/tpl.png") })
921
+ */
570
922
  function divide(src1: Mat, options: { src2: Mat; scale?: number }): Mat | null;
923
+ /**
924
+ * 归一化
925
+ * @example cv.normalize(cv.capture(), { alpha: 0, beta: 255, normType: cv.NORM_MINMAX })
926
+ */
571
927
  function normalize(mat: Mat, options?: { alpha?: number; beta?: number; normType?: number }): Mat | null;
928
+ /**
929
+ * 计算范数
930
+ * @example cv.norm(cv.capture())
931
+ */
572
932
  function norm(mat: Mat, options?: { normType?: number; mask?: Mat; src2?: Mat }): number;
933
+ /**
934
+ * 均值与标准差
935
+ * @example cv.meanStdDev(cv.capture())
936
+ */
573
937
  function meanStdDev(mat: Mat, options?: { mask?: Mat }): { mean: number[]; stddev: number[] } | null;
938
+ /**
939
+ * 非零像素坐标
940
+ * @example cv.findNonZero(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
941
+ */
574
942
  function findNonZero(mat: Mat): Point[] | null;
943
+ /**
944
+ * 水平拼接
945
+ * @example cv.hconcat([cv.capture(), cv.imread("/path/to/tpl.png")])
946
+ */
575
947
  function hconcat(mats: Mat[]): Mat | null;
948
+ /**
949
+ * 垂直拼接
950
+ * @example cv.vconcat([cv.capture(), cv.imread("/path/to/tpl.png")])
951
+ */
576
952
  function vconcat(mats: Mat[]): Mat | null;
577
953
 
578
954
  // ---- 已知点变换矩阵 ----
955
+ /**
956
+ * 生成透视变换矩阵
957
+ * @example cv.getPerspectiveTransform({ srcPoints: [{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], dstPoints: [{ x: 0, y: 0 }, { x: 200, y: 0 }, { x: 100, y: 200 }] })
958
+ */
579
959
  function getPerspectiveTransform(options: { srcPoints: Point[]; dstPoints: Point[] }): Mat | null;
960
+ /**
961
+ * 生成仿射变换矩阵
962
+ * @example cv.getAffineTransform({ srcPoints: [{ x: 0, y: 0 }, { x: 100, y: 0 }, { x: 0, y: 100 }], dstPoints: [{ x: 10, y: 10 }, { x: 110, y: 10 }, { x: 10, y: 110 }] })
963
+ */
580
964
  function getAffineTransform(options: { srcPoints: Point[]; dstPoints: Point[] }): Mat | null;
581
965
 
582
966
  // ---- Flann(SIFT 推荐,与 image 找图同源)----
967
+ /**
968
+ * FLANN 匹配描述子
969
+ * @example cv.FlannBasedMatcher(cv.capture(), cv.imread("/path/to/tpl.png"))
970
+ */
583
971
  function FlannBasedMatcher(queryDescriptors: Mat, trainDescriptors: Mat): DMatch[] | null;
972
+ /**
973
+ * FLANN K 近邻匹配
974
+ * @example cv.flannKnnMatch(cv.capture(), cv.imread("/path/to/tpl.png"), { k: 2, ratio: 0.75 })
975
+ */
584
976
  function flannKnnMatch(queryDescriptors: Mat, trainDescriptors: Mat, options?: { k?: number; ratio?: number }): DMatch[][] | null;
585
977
 
586
978
  // ---- 直方图 ----
979
+ /**
980
+ * 计算直方图
981
+ * @example cv.calcHist(cv.capture(), { channels: [0], histSize: [256], ranges: [0, 256] })
982
+ */
587
983
  function calcHist(mat: Mat, options?: {
588
984
  channels?: number[];
589
985
  histSize?: number[];
@@ -591,15 +987,42 @@ declare namespace cv {
591
987
  mask?: Mat;
592
988
  accumulate?: boolean;
593
989
  }): Mat | null;
990
+ /**
991
+ * 比较直方图
992
+ * @example cv.compareHist(cv.capture(), cv.imread("/path/to/tpl.png"), { method: cv.HISTCMP_CORREL })
993
+ */
594
994
  function compareHist(H1: Mat, H2: Mat, options?: { method?: number }): number;
595
995
 
596
996
  // ---- 轮廓几何配套 ----
997
+ /**
998
+ * 旋转矩形的四个顶点
999
+ * @example cv.boxPoints({ center: { x: 100, y: 100 }, size: { width: 80, height: 40 }, angle: 15 })
1000
+ */
597
1001
  function boxPoints(options: { center: Point; size: Size | [number, number]; angle?: number }): Point[] | null;
1002
+ /**
1003
+ * 点与轮廓位置关系
1004
+ * @example cv.pointPolygonTest([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], { pt: { x: 150, y: 120 }, measureDist: true })
1005
+ */
598
1006
  function pointPolygonTest(contour: Point[], ptOrOptions: Point | { pt: Point; measureDist?: boolean }): number;
1007
+ /**
1008
+ * 最小外接圆
1009
+ * @example cv.minEnclosingCircle([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }])
1010
+ */
599
1011
  function minEnclosingCircle(points: Point[]): { center: Point; radius: number } | null;
600
- /** 椭圆拟合,至少 5 个点;可用于圆形/椭圆控件轮廓 */
1012
+ /**
1013
+ * 椭圆拟合,至少 5 个点;可用于圆形/椭圆控件轮廓
1014
+ * @example cv.fitEllipse([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }])
1015
+ */
601
1016
  function fitEllipse(points: Point[]): RotatedRect | null;
1017
+ /**
1018
+ * 二维卷积
1019
+ * @example cv.filter2D(cv.capture(), { kernel: cv.getStructuringElement({ shape: cv.MORPH_RECT, ksize: 3 }) })
1020
+ */
602
1021
  function filter2D(mat: Mat, options: { kernel: Mat; ddepth?: number; delta?: number }): Mat | null;
1022
+ /**
1023
+ * 绘制椭圆
1024
+ * @example cv.ellipse(cv.capture(), { center: { x: 100, y: 100 }, axes: { width: 60, height: 40 }, angle: 0, color: [0, 0, 255], thickness: 2 })
1025
+ */
603
1026
  function ellipse(mat: Mat, options: {
604
1027
  center: Point;
605
1028
  axes: Size | [number, number];
@@ -609,6 +1032,10 @@ declare namespace cv {
609
1032
  color?: number[] | string;
610
1033
  thickness?: number;
611
1034
  }): Mat | null;
1035
+ /**
1036
+ * 计算文字尺寸
1037
+ * @example cv.getTextSize({ text: "hello", fontScale: 1, thickness: 2 })
1038
+ */
612
1039
  function getTextSize(options: {
613
1040
  text: string;
614
1041
  fontFace?: number;
@@ -617,78 +1044,184 @@ declare namespace cv {
617
1044
  }): { width: number; height: number; baseLine: number } | null;
618
1045
 
619
1046
  // ---- QR / 条码 ----
620
- /** 编码二维码为可显示/可识别的 BGR Mat(已放大并加静区,可直接 detectQRCode) */
1047
+ /**
1048
+ * 编码二维码为可显示/可识别的 BGR Mat(已放大并加静区,可直接 detectQRCode)
1049
+ * @example cv.encodeQRCode("https://example.com")
1050
+ */
621
1051
  function encodeQRCode(text: string): Mat | null;
1052
+ /**
1053
+ * 检测二维码
1054
+ * @example cv.detectQRCode(cv.capture())
1055
+ */
622
1056
  function detectQRCode(mat: Mat): { decoded: string; points: Point[] } | null;
1057
+ /**
1058
+ * 检测条码
1059
+ * @example cv.detectBarcode(cv.capture())
1060
+ */
623
1061
  function detectBarcode(mat: Mat): { decoded: string[]; types: string[]; points: Point[] } | null;
624
1062
 
625
1063
  // ---- Photo ----
1064
+ /**
1065
+ * 图像修复
1066
+ * @example cv.inpaint(cv.capture(), { mask: cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), inpaintRadius: 3 })
1067
+ */
626
1068
  function inpaint(mat: Mat, options: { mask: Mat; inpaintRadius?: number; flags?: number }): Mat | null;
1069
+ /**
1070
+ * 非局部均值去噪(灰度)
1071
+ * @example cv.fastNlMeansDenoising(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { h: 3 })
1072
+ */
627
1073
  function fastNlMeansDenoising(mat: Mat, options?: {
628
1074
  h?: number; templateWindowSize?: number; searchWindowSize?: number;
629
1075
  }): Mat | null;
1076
+ /**
1077
+ * 非局部均值去噪(彩色)
1078
+ * @example cv.fastNlMeansDenoisingColored(cv.capture(), { h: 3, hColor: 3 })
1079
+ */
630
1080
  function fastNlMeansDenoisingColored(mat: Mat, options?: {
631
1081
  h?: number; hColor?: number; templateWindowSize?: number; searchWindowSize?: number;
632
1082
  }): Mat | null;
633
1083
 
634
1084
  // ---- Core 扩展 ----
1085
+ /**
1086
+ * 查找表映射
1087
+ * @example cv.LUT(cv.capture(), { lut: cv.Mat({ rows: 1, cols: 256, type: cv.CV_8UC1 }) })
1088
+ */
635
1089
  function LUT(mat: Mat, options: { lut: Mat }): Mat | null;
1090
+ /**
1091
+ * 逐像素比较
1092
+ * @example cv.compare(cv.capture(), { src2: cv.imread("/path/to/tpl.png"), cmpop: cv.CMP_EQ })
1093
+ */
636
1094
  function compare(src1: Mat, options: { src2: Mat; cmpop: number }): Mat | null;
1095
+ /**
1096
+ * 逐像素取较小值
1097
+ * @example cv.min(cv.capture(), { src2: cv.imread("/path/to/tpl.png") })
1098
+ */
637
1099
  function min(src1: Mat, options: { src2: Mat }): Mat | null;
1100
+ /**
1101
+ * 逐像素取较大值
1102
+ * @example cv.max(cv.capture(), { src2: cv.imread("/path/to/tpl.png") })
1103
+ */
638
1104
  function max(src1: Mat, options: { src2: Mat }): Mat | null;
1105
+ /**
1106
+ * 提取指定通道
1107
+ * @example cv.extractChannel(cv.capture(), { coi: 0 })
1108
+ */
639
1109
  function extractChannel(mat: Mat, options: { coi: number }): Mat | null;
1110
+ /**
1111
+ * 像素求和
1112
+ * @example cv.sum(cv.capture())
1113
+ */
640
1114
  function sum(mat: Mat): number[] | null;
641
1115
 
642
1116
  // ---- Imgproc 几何 / 滤波扩展 ----
1117
+ /**
1118
+ * 反转仿射矩阵
1119
+ * @example cv.invertAffineTransform(cv.getAffineTransform({ srcPoints: [{ x: 0, y: 0 }, { x: 100, y: 0 }, { x: 0, y: 100 }], dstPoints: [{ x: 10, y: 10 }, { x: 110, y: 10 }, { x: 10, y: 110 }] }))
1120
+ */
643
1121
  function invertAffineTransform(M: Mat): Mat | null;
1122
+ /**
1123
+ * 亚像素精度取块
1124
+ * @example cv.getRectSubPix(cv.capture(), { patchSize: { width: 32, height: 32 }, center: { x: 100, y: 100 } })
1125
+ */
644
1126
  function getRectSubPix(mat: Mat, options: {
645
1127
  patchSize: Size | [number, number]; center: Point;
646
1128
  }): Mat | null;
647
- /** 相位相关估计两图位移(如滚动/拖拽前后帧) */
1129
+ /**
1130
+ * 相位相关估计两图位移(如滚动/拖拽前后帧)
1131
+ * @example cv.phaseCorrelate(cv.capture(), { src2: cv.imread("/path/to/tpl.png") })
1132
+ */
648
1133
  function phaseCorrelate(src1: Mat, options: { src2: Mat; window?: Mat }): {
649
1134
  x: number; y: number; response?: number;
650
1135
  } | null;
1136
+ /**
1137
+ * Harris 角点
1138
+ * @example cv.cornerHarris(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { blockSize: 2, ksize: 3, k: 0.04 })
1139
+ */
651
1140
  function cornerHarris(mat: Mat, options?: { blockSize?: number; ksize?: number; k?: number }): Mat | null;
1141
+ /**
1142
+ * 角点亚像素精修
1143
+ * @example cv.cornerSubPix(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { corners: [{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], winSize: { width: 5, height: 5 } })
1144
+ */
652
1145
  function cornerSubPix(mat: Mat, options: {
653
1146
  corners: Point[];
654
1147
  winSize?: Size | [number, number];
655
1148
  zeroZone?: Size | [number, number];
656
1149
  criteria?: { type?: number; maxCount?: number; epsilon?: number };
657
1150
  }): Point[] | null;
1151
+ /**
1152
+ * 直方图反向投影
1153
+ * @example cv.calcBackProject(cv.capture(), { hist: cv.calcHist(cv.capture(), { channels: [0], histSize: [256], ranges: [0, 256] }), channels: [0], ranges: [0, 256] })
1154
+ */
658
1155
  function calcBackProject(mat: Mat, options: {
659
1156
  hist: Mat; channels?: number[]; ranges?: number[]; scale?: number;
660
1157
  }): Mat | null;
1158
+ /**
1159
+ * Hu 矩
1160
+ * @example cv.HuMoments([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }])
1161
+ */
661
1162
  function HuMoments(contourOrMoments: Point[] | MomentsResult): number[] | null;
1163
+ /**
1164
+ * 连通域标记
1165
+ * @example cv.connectedComponents(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
1166
+ */
662
1167
  function connectedComponents(mat: Mat, options?: { connectivity?: number }): {
663
1168
  count: number; labels: Mat;
664
1169
  } | null;
1170
+ /**
1171
+ * 凸缺陷
1172
+ * @example cv.convexityDefects([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], { hull: cv.convexHull([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }]) })
1173
+ */
665
1174
  function convexityDefects(contour: Point[], options: {
666
1175
  hull: number[] | Point[];
667
1176
  }): Array<{ start: number; end: number; farthest: number; depth: number }> | null;
1177
+ /**
1178
+ * 判断轮廓是否凸
1179
+ * @example cv.isContourConvex([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }])
1180
+ */
668
1181
  function isContourConvex(contour: Point[]): boolean;
1182
+ /**
1183
+ * 直线拟合
1184
+ * @example cv.fitLine([{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }])
1185
+ */
669
1186
  function fitLine(points: Point[], options?: {
670
1187
  distType?: number; param?: number; reps?: number; aeps?: number;
671
1188
  }): [number, number, number, number] | null;
672
1189
 
673
- /** 就地绘制标记点,返回原句柄 */
1190
+ /**
1191
+ * 就地绘制标记点,返回原句柄
1192
+ * @example cv.drawMarker(cv.capture(), { position: { x: 100, y: 100 }, color: [0, 0, 255], markerType: cv.MARKER_CROSS })
1193
+ */
674
1194
  function drawMarker(mat: Mat, options: {
675
1195
  position: Point; color?: number[] | string;
676
1196
  markerType?: number; markerSize?: number; thickness?: number;
677
1197
  }): Mat | null;
678
- /** 就地画箭头线,返回原句柄 */
1198
+ /**
1199
+ * 就地画箭头线,返回原句柄
1200
+ * @example cv.arrowedLine(cv.capture(), { pt1: { x: 10, y: 10 }, pt2: { x: 200, y: 200 }, color: [0, 0, 255] })
1201
+ */
679
1202
  function arrowedLine(mat: Mat, options: {
680
1203
  pt1: Point; pt2: Point; color?: number[] | string; thickness?: number; tipLength?: number;
681
1204
  }): Mat | null;
682
- /** 就地填充凸多边形,返回原句柄 */
1205
+ /**
1206
+ * 就地填充凸多边形,返回原句柄
1207
+ * @example cv.fillConvexPoly(cv.capture(), { pts: [{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], color: [0, 0, 255] })
1208
+ */
683
1209
  function fillConvexPoly(mat: Mat, options: {
684
1210
  pts: Point[]; color?: number[] | string;
685
1211
  }): Mat | null;
686
1212
 
687
1213
  // ---- Calib3d ----
1214
+ /**
1215
+ * 估计 2D 仿射变换
1216
+ * @example cv.estimateAffine2D({ srcPoints: [{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], dstPoints: [{ x: 10, y: 10 }, { x: 110, y: 10 }, { x: 60, y: 110 }] })
1217
+ */
688
1218
  function estimateAffine2D(options: {
689
1219
  srcPoints: Point[]; dstPoints: Point[]; method?: number; ransacReprojThreshold?: number;
690
1220
  }): Mat | null;
691
- /** 相似变换(平移+旋转+等比缩放,无剪切),点对齐/跨分辨率匹配常用 */
1221
+ /**
1222
+ * 相似变换(平移+旋转+等比缩放,无剪切),点对齐/跨分辨率匹配常用
1223
+ * @example cv.estimateAffinePartial2D({ srcPoints: [{ x: 100, y: 100 }, { x: 200, y: 100 }, { x: 150, y: 200 }], dstPoints: [{ x: 10, y: 10 }, { x: 110, y: 10 }, { x: 60, y: 110 }] })
1224
+ */
692
1225
  function estimateAffinePartial2D(options: {
693
1226
  srcPoints: Point[]; dstPoints: Point[]; method?: number; ransacReprojThreshold?: number;
694
1227
  }): Mat | null;