ms-vite-plugin 1.5.17 → 1.5.19

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.
@@ -13,20 +13,20 @@
13
13
 
14
14
  ## 功能一览
15
15
 
16
- | 类别 | API |
17
- | --- | --- |
18
- | 读图 / 截屏 | `capture` · `imread` · `imdecode` · `imwrite` · `imencode` · `fromImageId` / `toImageId` |
19
- | Mat | `Mat` / `zeros` / `ones` · `clone` · `empty` / `isRelease` · `release` / `releaseAll` · `getSize` / `at` / `set` · `copyTo` |
20
- | 颜色 / 阈值 | `cvtColor` · `threshold` · `adaptiveThreshold` · `inRange` · `CLAHE` / `equalizeHist` |
21
- | 算术 / 位运算 | `add` / `subtract` / `multiply` / `divide` · bitwise_* · `absdiff` · `addWeighted` · `convertScaleAbs` · `normalize` / `norm` · `meanStdDev` · `findNonZero` · `countNonZero` · `minMaxLoc` / `mean` / `sum` · `split` / `merge` · `hconcat` / `vconcat` · `LUT` · `compare` · `min` / `max` · `extractChannel` |
22
- | 滤波边缘 | `GaussianBlur` / `blur` / `medianBlur` / `bilateralFilter` / `boxFilter` · `Canny` / `Sobel` / `Laplacian` / `Scharr` · `filter2D` · `pyrDown` / `pyrUp` · `fastNlMeansDenoising` / `fastNlMeansDenoisingColored` · `inpaint` |
23
- | 几何 | `resize` / `crop` / `rotate` / `flip` · `copyMakeBorder` · `warpAffine` / `warpPerspective` · `getRotationMatrix2D` · `getAffineTransform` · `getPerspectiveTransform` · `invertAffineTransform` · `findHomography` · `perspectiveTransform` · `estimateAffine2D` / `estimateAffinePartial2D` · `getRectSubPix` · `phaseCorrelate` |
24
- | 绘制 | `rectangle` / `circle` / `line` / `ellipse` / `arrowedLine` / `drawMarker` · `putText` / `fillPoly` / `fillConvexPoly` / `polylines` / `drawContours` · `getTextSize` |
25
- | 匹配 | `matchTemplate` / `matchTemplateLoc` · `SIFT` / `ORB` / `FAST` · `BFMatcher` / `knnMatch` · `FlannBasedMatcher` / `flannKnnMatch` · `drawKeypoints` / `drawMatches` |
26
- | 轮廓 | `findContours` · `boundingRect` / `minAreaRect` / `boxPoints` · `contourArea` / `arcLength` / `approxPolyDP` / `convexHull` / `convexityDefects` / `isContourConvex` · `moments` / `HuMoments` / `matchShapes` · `pointPolygonTest` · `fitEllipse` / `fitLine` / `minEnclosingCircle` |
27
- | 霍夫 / 连通域 | `HoughLinesP` / `HoughCircles` · `connectedComponents` / `connectedComponentsWithStats` · `distanceTransform` · `floodFill` · `goodFeaturesToTrack` / `cornerHarris` / `cornerSubPix` |
28
- | 直方图 | `calcHist` · `compareHist` · `calcBackProject` |
29
- | 扫码 | `encodeQRCode` · `detectQRCode` · `detectBarcode` |
16
+ | 类别 | API |
17
+ | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
18
+ | 读图 / 截屏 | `capture` · `imread` · `imdecode` · `imwrite` · `imencode` · `fromImageId` / `toImageId` |
19
+ | Mat | `Mat` / `zeros` / `ones` · `clone` · `empty` / `isRelease` · `release` / `releaseAll` · `getSize` / `at` / `set` · `copyTo` |
20
+ | 颜色 / 阈值 | `cvtColor` · `threshold` · `adaptiveThreshold` · `inRange` · `CLAHE` / `equalizeHist` |
21
+ | 算术 / 位运算 | `add` / `subtract` / `multiply` / `divide` · bitwise\_\* · `absdiff` · `addWeighted` · `convertScaleAbs` · `normalize` / `norm` · `meanStdDev` · `findNonZero` · `countNonZero` · `minMaxLoc` / `mean` / `sum` · `split` / `merge` · `hconcat` / `vconcat` · `LUT` · `compare` · `min` / `max` · `extractChannel` |
22
+ | 滤波边缘 | `GaussianBlur` / `blur` / `medianBlur` / `bilateralFilter` / `boxFilter` · `Canny` / `Sobel` / `Laplacian` / `Scharr` · `filter2D` · `pyrDown` / `pyrUp` · `fastNlMeansDenoising` / `fastNlMeansDenoisingColored` · `inpaint` |
23
+ | 几何 | `resize` / `crop` / `rotate` / `flip` · `copyMakeBorder` · `warpAffine` / `warpPerspective` · `getRotationMatrix2D` · `getAffineTransform` · `getPerspectiveTransform` · `invertAffineTransform` · `findHomography` · `perspectiveTransform` · `estimateAffine2D` / `estimateAffinePartial2D` · `getRectSubPix` · `phaseCorrelate` |
24
+ | 绘制 | `rectangle` / `circle` / `line` / `ellipse` / `arrowedLine` / `drawMarker` · `putText` / `fillPoly` / `fillConvexPoly` / `polylines` / `drawContours` · `getTextSize` |
25
+ | 匹配 | `matchTemplate` / `matchTemplateLoc` · `SIFT` / `ORB` / `FAST` · `BFMatcher` / `knnMatch` · `FlannBasedMatcher` / `flannKnnMatch` · `drawKeypoints` / `drawMatches` |
26
+ | 轮廓 | `findContours` · `boundingRect` / `minAreaRect` / `boxPoints` · `contourArea` / `arcLength` / `approxPolyDP` / `convexHull` / `convexityDefects` / `isContourConvex` · `moments` / `HuMoments` / `matchShapes` · `pointPolygonTest` · `fitEllipse` / `fitLine` / `minEnclosingCircle` |
27
+ | 霍夫 / 连通域 | `HoughLinesP` / `HoughCircles` · `connectedComponents` / `connectedComponentsWithStats` · `distanceTransform` · `floodFill` · `goodFeaturesToTrack` / `cornerHarris` / `cornerSubPix` |
28
+ | 直方图 | `calcHist` · `compareHist` · `calcBackProject` |
29
+ | 扫码 | `encodeQRCode` · `detectQRCode` · `detectBarcode` |
30
30
 
31
31
  ---
32
32
 
@@ -76,19 +76,19 @@ function capture(
76
76
 
77
77
  **参数:**
78
78
 
79
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
80
- | --- | --- | --- | --- | --- |
81
- | `x` | number | 否 | 0 | 区域左上角 X 坐标 |
82
- | `y` | number | 否 | 0 | 区域左上角 Y 坐标 |
83
- | `ex` | number | 否 | 0 | 区域右下角 X 坐标 |
84
- | `ey` | number | 否 | 0 | 区域右下角 Y 坐标 |
79
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
80
+ | ------ | ------ | -------- | ------ | ----------------- |
81
+ | `x` | number | 否 | 0 | 区域左上角 X 坐标 |
82
+ | `y` | number | 否 | 0 | 区域左上角 Y 坐标 |
83
+ | `ex` | number | 否 | 0 | 区域右下角 X 坐标 |
84
+ | `ey` | number | 否 | 0 | 区域右下角 Y 坐标 |
85
85
 
86
86
  无参或全 0 表示全屏。
87
87
 
88
88
  **返回值:**
89
89
 
90
- | 类型 | 描述 |
91
- | --- | --- |
90
+ | 类型 | 描述 |
91
+ | -------- | ------------------------------ |
92
92
  | `string` | Mat 句柄,失败返回 `undefined` |
93
93
 
94
94
  **示例:**
@@ -108,29 +108,29 @@ function imread(path: string): Mat | undefined;
108
108
 
109
109
  **参数:**
110
110
 
111
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
112
- | --- | --- | --- | --- | --- |
113
- | `path` | string | 是 | - | 见下方支持的输入源 |
111
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
112
+ | ------ | ------ | -------- | ------ | ------------------ |
113
+ | `path` | string | 是 | - | 见下方支持的输入源 |
114
114
 
115
115
  **支持的输入源:**
116
116
 
117
- | 输入 | 说明 |
118
- | --- | --- |
119
- | msbundle/res 相对路径 | 如 `"template.png"`、`"images/logo.jpg"` |
120
- | 手机绝对路径 | 如 documents 下文件 |
121
- | `$MS_IMG$_…` | `image` 模块 imageId |
122
- | `"screen"` | 当前屏幕截图 |
123
- | `"shortcut"` | HID 快捷指令截图 |
124
- | `"actionScreenshot"` | HID 系统截图 |
125
- | `"vpnScreenshot"` | VPN/iDevice 截图 |
126
- | `http://` / `https://` | 网络图片 |
127
- | `media:n` | 相册第 n 张(从 1 起) |
128
- | `data:image/...;base64,...` | data URI |
117
+ | 输入 | 说明 |
118
+ | --------------------------- | ---------------------------------------- |
119
+ | msbundle/res 相对路径 | 如 `"template.png"`、`"images/logo.jpg"` |
120
+ | 手机绝对路径 | 如 documents 下文件 |
121
+ | `$MS_IMG$_…` | `image` 模块 imageId |
122
+ | `"screen"` | 当前屏幕截图 |
123
+ | `"shortcut"` | HID 快捷指令截图 |
124
+ | `"actionScreenshot"` | HID 系统截图 |
125
+ | `"vpnScreenshot"` | VPN免自动化截图 |
126
+ | `http://` / `https://` | 网络图片 |
127
+ | `media:n` | 相册第 n 张(从 1 起) |
128
+ | `data:image/...;base64,...` | data URI |
129
129
 
130
130
  **返回值:**
131
131
 
132
- | 类型 | 描述 |
133
- | --- | --- |
132
+ | 类型 | 描述 |
133
+ | -------- | ------------------------------ |
134
134
  | `string` | Mat 句柄,失败返回 `undefined` |
135
135
 
136
136
  **示例:**
@@ -155,9 +155,9 @@ function imdecode(data: string): Mat | undefined;
155
155
 
156
156
  **参数:**
157
157
 
158
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
159
- | --- | --- | --- | --- | --- |
160
- | `data` | string | 是 | - | 纯 base64,或 `data:image/...;base64,...` |
158
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
159
+ | ------ | ------ | -------- | ------ | ----------------------------------------- |
160
+ | `data` | string | 是 | - | 纯 base64,或 `data:image/...;base64,...` |
161
161
 
162
162
  **说明:** 不解析文件路径 / msbundle / imageId;路径类请用 `imread`。常与 `imencode` 成对使用。
163
163
 
@@ -181,10 +181,10 @@ function imwrite(path: string, mat: Mat): boolean;
181
181
 
182
182
  **参数:**
183
183
 
184
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
185
- | --- | --- | --- | --- | --- |
186
- | `path` | string | 是 | - | 本地绝对路径(写入磁盘,不是 msbundle) |
187
- | `mat` | Mat | 是 | - | Mat 句柄 |
184
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
185
+ | ------ | ------ | -------- | ------ | --------------------------------------- |
186
+ | `path` | string | 是 | - | 本地绝对路径(写入磁盘,不是 msbundle) |
187
+ | `mat` | Mat | 是 | - | Mat 句柄 |
188
188
 
189
189
  **说明:** 格式由 `path` 的扩展名决定,可用 `png` / `apng` / `jpg` / `jpeg` / `jpe` / `bmp` / `dib` / `webp` / `ppm` / `pgm` / `pbm` / `pnm` / `pam` / `sr` / `ras`;其它扩展名(如 `tiff`)或通道数不是 1 / 3 / 4 的 Mat 会直接返回 `false`。
190
190
 
@@ -206,11 +206,11 @@ function imencode(ext: string, mat: Mat, quality?: number): string | undefined;
206
206
 
207
207
  **参数:**
208
208
 
209
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
210
- | --- | --- | --- | --- | --- |
211
- | `ext` | string | 是 | - | 如 `.png` / `.jpg` / `png` |
212
- | `mat` | Mat | 是 | - | Mat 句柄 |
213
- | `quality` | number | 否 | 90 | JPEG 质量,取值 1–100(仅 jpg 有效) |
209
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
210
+ | --------- | ------ | -------- | ------ | ------------------------------------ |
211
+ | `ext` | string | 是 | - | 如 `.png` / `.jpg` / `png` |
212
+ | `mat` | Mat | 是 | - | Mat 句柄 |
213
+ | `quality` | number | 否 | 90 | JPEG 质量,取值 1–100(仅 jpg 有效) |
214
214
 
215
215
  **说明:** 可用扩展名与通道限制同 `imwrite`,不支持的格式返回 `undefined`。
216
216
 
@@ -231,10 +231,10 @@ function toImageId(mat: Mat): string | undefined;
231
231
 
232
232
  **参数:**
233
233
 
234
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
235
- | --- | --- | --- | --- | --- |
236
- | `imageId` | string | 是 | - | `image` 模块句柄 |
237
- | `mat` | Mat | 是 | - | `cv` Mat 句柄 |
234
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
235
+ | --------- | ------ | -------- | ------ | ---------------- |
236
+ | `imageId` | string | 是 | - | `image` 模块句柄 |
237
+ | `mat` | Mat | 是 | - | `cv` Mat 句柄 |
238
238
 
239
239
  **说明:** 均为独立拷贝。`fromImageId(id)` 与 `imread(id)` 对 imageId 效果相同。
240
240
 
@@ -252,18 +252,31 @@ image.release(outId);
252
252
  ### Mat / zeros / ones - 创建矩阵
253
253
 
254
254
  ```typescript
255
- function Mat(options: { rows: number; cols: number; type?: number; scalar?: number[] }): Mat | undefined;
256
- function zeros(options: { rows: number; cols: number; type?: number }): Mat | undefined;
257
- function ones(options: { rows: number; cols: number; type?: number }): Mat | undefined;
255
+ function Mat(options: {
256
+ rows: number;
257
+ cols: number;
258
+ type?: number;
259
+ scalar?: number[];
260
+ }): Mat | undefined;
261
+ function zeros(options: {
262
+ rows: number;
263
+ cols: number;
264
+ type?: number;
265
+ }): Mat | undefined;
266
+ function ones(options: {
267
+ rows: number;
268
+ cols: number;
269
+ type?: number;
270
+ }): Mat | undefined;
258
271
  ```
259
272
 
260
273
  **参数:**
261
274
 
262
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
263
- | --- | --- | --- | --- | --- |
264
- | `rows` / `cols` | number | 是 | - | 行 / 列 |
265
- | `type` | number | 否 | `CV_8UC3` | 如 `cv.CV_8UC1` |
266
- | `scalar` | number[] | 否 | - | 仅 `Mat`:填充值 |
275
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
276
+ | --------------- | -------- | -------- | --------- | ---------------- |
277
+ | `rows` / `cols` | number | 是 | - | 行 / 列 |
278
+ | `type` | number | 否 | `CV_8UC3` | 如 `cv.CV_8UC1` |
279
+ | `scalar` | number[] | 否 | - | 仅 `Mat`:填充值 |
267
280
 
268
281
  **示例:**
269
282
 
@@ -326,45 +339,55 @@ const hsv = cv.cvtColor(src, cv.COLOR_BGR2HSV);
326
339
  ### threshold - 固定阈值
327
340
 
328
341
  ```typescript
329
- function threshold(mat: Mat, options: { thresh?: number; maxval?: number; type?: number }): Mat | undefined;
342
+ function threshold(
343
+ mat: Mat,
344
+ options: { thresh?: number; maxval?: number; type?: number },
345
+ ): Mat | undefined;
330
346
  ```
331
347
 
332
348
  **参数:**
333
349
 
334
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
335
- | --- | --- | --- | --- | --- |
336
- | `thresh` | number | 否 | 127 | 阈值 |
337
- | `maxval` | number | 否 | 255 | 最大值 |
338
- | `type` | number | 否 | `THRESH_BINARY` | 如 `THRESH_BINARY` / `THRESH_OTSU` |
350
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
351
+ | -------- | ------ | -------- | --------------- | ---------------------------------- |
352
+ | `thresh` | number | 否 | 127 | 阈值 |
353
+ | `maxval` | number | 否 | 255 | 最大值 |
354
+ | `type` | number | 否 | `THRESH_BINARY` | 如 `THRESH_BINARY` / `THRESH_OTSU` |
339
355
 
340
356
  **示例:**
341
357
 
342
358
  ```javascript
343
- const bin = cv.threshold(gray, { thresh: 127, maxval: 255, type: cv.THRESH_BINARY });
359
+ const bin = cv.threshold(gray, {
360
+ thresh: 127,
361
+ maxval: 255,
362
+ type: cv.THRESH_BINARY,
363
+ });
344
364
  const otsu = cv.threshold(gray, { type: cv.THRESH_BINARY | cv.THRESH_OTSU });
345
365
  ```
346
366
 
347
367
  ### adaptiveThreshold - 自适应阈值
348
368
 
349
369
  ```typescript
350
- function adaptiveThreshold(mat: Mat, options: {
351
- maxValue?: number;
352
- adaptiveMethod?: number;
353
- thresholdType?: number;
354
- blockSize?: number;
355
- C?: number;
356
- }): Mat | undefined;
370
+ function adaptiveThreshold(
371
+ mat: Mat,
372
+ options: {
373
+ maxValue?: number;
374
+ adaptiveMethod?: number;
375
+ thresholdType?: number;
376
+ blockSize?: number;
377
+ C?: number;
378
+ },
379
+ ): Mat | undefined;
357
380
  ```
358
381
 
359
382
  **参数:**
360
383
 
361
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
362
- | --- | --- | --- | --- | --- |
363
- | `maxValue` | number | 否 | 255 | 最大值 |
364
- | `adaptiveMethod` | number | 否 | `ADAPTIVE_THRESH_GAUSSIAN_C` | 或 `ADAPTIVE_THRESH_MEAN_C` |
365
- | `thresholdType` | number | 否 | `THRESH_BINARY` | |
366
- | `blockSize` | number | 否 | 11 | 奇数邻域 |
367
- | `C` | number | 否 | 2 | 常数偏移 |
384
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
385
+ | ---------------- | ------ | -------- | ---------------------------- | --------------------------- |
386
+ | `maxValue` | number | 否 | 255 | 最大值 |
387
+ | `adaptiveMethod` | number | 否 | `ADAPTIVE_THRESH_GAUSSIAN_C` | 或 `ADAPTIVE_THRESH_MEAN_C` |
388
+ | `thresholdType` | number | 否 | `THRESH_BINARY` | |
389
+ | `blockSize` | number | 否 | 11 | 奇数邻域 |
390
+ | `C` | number | 否 | 2 | 常数偏移 |
368
391
 
369
392
  **示例:**
370
393
 
@@ -381,7 +404,10 @@ const bin = cv.adaptiveThreshold(gray, {
381
404
  ### inRange - 范围掩膜
382
405
 
383
406
  ```typescript
384
- function inRange(mat: Mat, options: { lowerb: number[]; upperb: number[] }): Mat | undefined;
407
+ function inRange(
408
+ mat: Mat,
409
+ options: { lowerb: number[]; upperb: number[] },
410
+ ): Mat | undefined;
385
411
  ```
386
412
 
387
413
  **参数:** `lowerb` / `upperb` 为各通道下/上限数组。
@@ -409,7 +435,10 @@ const abs = cv.convertScaleAbs(sobel, { alpha: 1, beta: 0 });
409
435
 
410
436
  ```typescript
411
437
  function countNonZero(mat: Mat): number;
412
- function minMaxLoc(mat: Mat, options?: { mask?: Mat }): MinMaxLocResult | undefined;
438
+ function minMaxLoc(
439
+ mat: Mat,
440
+ options?: { mask?: Mat },
441
+ ): MinMaxLocResult | undefined;
413
442
  ```
414
443
 
415
444
  `minMaxLoc` / `countNonZero` 需要单通道,先转灰度:
@@ -431,11 +460,27 @@ cv.release(merged);
431
460
  ### GaussianBlur / blur / medianBlur / bilateralFilter / boxFilter
432
461
 
433
462
  ```typescript
434
- function GaussianBlur(mat: Mat, options: { ksize: number | [number, number] | Size; sigmaX?: number; sigmaY?: number }): Mat | undefined;
435
- function blur(mat: Mat, options: { ksize: number | [number, number] | Size }): Mat | undefined;
463
+ function GaussianBlur(
464
+ mat: Mat,
465
+ options: {
466
+ ksize: number | [number, number] | Size;
467
+ sigmaX?: number;
468
+ sigmaY?: number;
469
+ },
470
+ ): Mat | undefined;
471
+ function blur(
472
+ mat: Mat,
473
+ options: { ksize: number | [number, number] | Size },
474
+ ): Mat | undefined;
436
475
  function medianBlur(mat: Mat, options: { ksize: number }): Mat | undefined;
437
- function bilateralFilter(mat: Mat, options: { d?: number; sigmaColor?: number; sigmaSpace?: number }): Mat | undefined;
438
- function boxFilter(mat: Mat, options: { ksize: number | [number, number] | Size; ddepth?: number }): Mat | undefined;
476
+ function bilateralFilter(
477
+ mat: Mat,
478
+ options: { d?: number; sigmaColor?: number; sigmaSpace?: number },
479
+ ): Mat | undefined;
480
+ function boxFilter(
481
+ mat: Mat,
482
+ options: { ksize: number | [number, number] | Size; ddepth?: number },
483
+ ): Mat | undefined;
439
484
  ```
440
485
 
441
486
  `ksize` 可为 `5`、`[5,5]` 或 `{ width, height }`。高斯核尺寸需为奇数。
@@ -451,22 +496,58 @@ const b = cv.bilateralFilter(src, { d: 9, sigmaColor: 75, sigmaSpace: 75 });
451
496
  ### Canny / Sobel / Laplacian / Scharr / equalizeHist / CLAHE
452
497
 
453
498
  ```typescript
454
- function Canny(mat: Mat, options: { threshold1?: number; threshold2?: number; apertureSize?: number; L2gradient?: boolean }): Mat | undefined;
455
- function Sobel(mat: Mat, options: { ddepth?: number; dx?: number; dy?: number; ksize?: number; scale?: number; delta?: number }): Mat | undefined;
456
- function Laplacian(mat: Mat, options: { ddepth?: number; ksize?: number; scale?: number; delta?: number }): Mat | undefined;
457
- function Scharr(mat: Mat, options: { ddepth?: number; dx?: number; dy?: number; scale?: number; delta?: number }): Mat | undefined;
499
+ function Canny(
500
+ mat: Mat,
501
+ options: {
502
+ threshold1?: number;
503
+ threshold2?: number;
504
+ apertureSize?: number;
505
+ L2gradient?: boolean;
506
+ },
507
+ ): Mat | undefined;
508
+ function Sobel(
509
+ mat: Mat,
510
+ options: {
511
+ ddepth?: number;
512
+ dx?: number;
513
+ dy?: number;
514
+ ksize?: number;
515
+ scale?: number;
516
+ delta?: number;
517
+ },
518
+ ): Mat | undefined;
519
+ function Laplacian(
520
+ mat: Mat,
521
+ options: { ddepth?: number; ksize?: number; scale?: number; delta?: number },
522
+ ): Mat | undefined;
523
+ function Scharr(
524
+ mat: Mat,
525
+ options: {
526
+ ddepth?: number;
527
+ dx?: number;
528
+ dy?: number;
529
+ scale?: number;
530
+ delta?: number;
531
+ },
532
+ ): Mat | undefined;
458
533
  function equalizeHist(mat: Mat): Mat | undefined;
459
- function CLAHE(mat: Mat, options?: { clipLimit?: number; tileGridSize?: number | [number, number] | Size }): Mat | undefined;
534
+ function CLAHE(
535
+ mat: Mat,
536
+ options?: {
537
+ clipLimit?: number;
538
+ tileGridSize?: number | [number, number] | Size;
539
+ },
540
+ ): Mat | undefined;
460
541
  ```
461
542
 
462
543
  **Canny 参数:**
463
544
 
464
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
465
- | --- | --- | --- | --- | --- |
466
- | `threshold1` | number | 否 | 100 | 低阈值 |
467
- | `threshold2` | number | 否 | 200 | 高阈值 |
468
- | `apertureSize` | number | 否 | 3 | Sobel 孔径 |
469
- | `L2gradient` | boolean | 否 | false | 是否用 L2 范数 |
545
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
546
+ | -------------- | ------- | -------- | ------ | -------------- |
547
+ | `threshold1` | number | 否 | 100 | 低阈值 |
548
+ | `threshold2` | number | 否 | 200 | 高阈值 |
549
+ | `apertureSize` | number | 否 | 3 | Sobel 孔径 |
550
+ | `L2gradient` | boolean | 否 | false | 是否用 L2 范数 |
470
551
 
471
552
  **CLAHE 参数:** `clipLimit` 默认 40;`tileGridSize` 默认 `[8,8]`。输入一般为单通道灰度。
472
553
 
@@ -502,13 +583,16 @@ const back = cv.pyrUp(small);
502
583
  ### resize - 缩放
503
584
 
504
585
  ```typescript
505
- function resize(mat: Mat, options: {
506
- width?: number;
507
- height?: number;
508
- fx?: number;
509
- fy?: number;
510
- interpolation?: number;
511
- }): Mat | undefined;
586
+ function resize(
587
+ mat: Mat,
588
+ options: {
589
+ width?: number;
590
+ height?: number;
591
+ fx?: number;
592
+ fy?: number;
593
+ interpolation?: number;
594
+ },
595
+ ): Mat | undefined;
512
596
  ```
513
597
 
514
598
  用 `width`/`height` 指定目标尺寸;也可设为 0 并用 `fx`/`fy` 按比例缩放。`interpolation` 如 `cv.INTER_LINEAR`、`cv.INTER_AREA`。
@@ -523,10 +607,15 @@ const half = cv.resize(src, { fx: 0.5, fy: 0.5, interpolation: cv.INTER_AREA });
523
607
  ### crop - 裁剪 ROI(拷贝)
524
608
 
525
609
  ```typescript
526
- function crop(mat: Mat, options: {
527
- x?: number; y?: number;
528
- ex?: number; ey?: number;
529
- }): Mat | undefined;
610
+ function crop(
611
+ mat: Mat,
612
+ options: {
613
+ x?: number;
614
+ y?: number;
615
+ ex?: number;
616
+ ey?: number;
617
+ },
618
+ ): Mat | undefined;
530
619
  ```
531
620
 
532
621
  参数与 `cv.capture` / `image.captureScreen` 一致,使用左上角与右下角。
@@ -545,23 +634,41 @@ const roi = cv.crop(src, { x: 10, y: 10, ex: 110, ey: 110 });
545
634
  function rotate(mat: Mat, rotateCode: number): Mat | undefined;
546
635
  const f = cv.flip(src, 1);
547
636
  const padded = cv.copyMakeBorder(src, {
548
- top: 10, bottom: 10, left: 10, right: 10,
549
- borderType: cv.BORDER_CONSTANT, value: [0, 0, 0],
637
+ top: 10,
638
+ bottom: 10,
639
+ left: 10,
640
+ right: 10,
641
+ borderType: cv.BORDER_CONSTANT,
642
+ value: [0, 0, 0],
550
643
  });
551
644
  ```
552
645
 
553
646
  ### getRotationMatrix2D / warpAffine / warpPerspective
554
647
 
555
648
  ```typescript
556
- function getRotationMatrix2D(options: { center: Point | [number, number]; angle?: number; scale?: number }): Mat | undefined;
557
- function warpAffine(mat: Mat, options: { M: Mat; width?: number; height?: number; flags?: number }): Mat | undefined;
558
- function warpPerspective(mat: Mat, options: { M: Mat; width?: number; height?: number; flags?: number }): Mat | undefined;
649
+ function getRotationMatrix2D(options: {
650
+ center: Point | [number, number];
651
+ angle?: number;
652
+ scale?: number;
653
+ }): Mat | undefined;
654
+ function warpAffine(
655
+ mat: Mat,
656
+ options: { M: Mat; width?: number; height?: number; flags?: number },
657
+ ): Mat | undefined;
658
+ function warpPerspective(
659
+ mat: Mat,
660
+ options: { M: Mat; width?: number; height?: number; flags?: number },
661
+ ): Mat | undefined;
559
662
  ```
560
663
 
561
664
  **示例:**
562
665
 
563
666
  ```javascript
564
- const M = cv.getRotationMatrix2D({ center: { x: 100, y: 100 }, angle: 30, scale: 1 });
667
+ const M = cv.getRotationMatrix2D({
668
+ center: { x: 100, y: 100 },
669
+ angle: 30,
670
+ scale: 1,
671
+ });
565
672
  const out = cv.warpAffine(src, { M, width: 200, height: 200 });
566
673
  cv.release(M);
567
674
  cv.release(out);
@@ -592,8 +699,18 @@ cv.rectangle(src, {
592
699
  color: [0, 0, 255],
593
700
  thickness: 2,
594
701
  });
595
- cv.circle(src, { center: { x: 50, y: 50 }, radius: 20, color: "#00FF00", thickness: -1 });
596
- cv.line(src, { pt1: { x: 0, y: 0 }, pt2: { x: 100, y: 100 }, color: [255, 0, 0], thickness: 2 });
702
+ cv.circle(src, {
703
+ center: { x: 50, y: 50 },
704
+ radius: 20,
705
+ color: "#00FF00",
706
+ thickness: -1,
707
+ });
708
+ cv.line(src, {
709
+ pt1: { x: 0, y: 0 },
710
+ pt2: { x: 100, y: 100 },
711
+ color: [255, 0, 0],
712
+ thickness: 2,
713
+ });
597
714
  cv.putText(src, {
598
715
  text: "hello",
599
716
  org: { x: 20, y: 40 },
@@ -607,15 +724,29 @@ cv.putText(src, {
607
724
  ### fillPoly / polylines / drawContours
608
725
 
609
726
  ```typescript
610
- function fillPoly(mat: Mat, options: { pts: Point[][] | Point[]; color?: number[] | string }): Mat | undefined;
611
- function polylines(mat: Mat, options: { pts: Point[][] | Point[]; isClosed?: boolean; color?: number[] | string; thickness?: number }): Mat | undefined;
612
- function drawContours(mat: Mat, options: {
613
- contours?: Point[][];
614
- pts?: Point[][];
615
- contourIdx?: number;
616
- color?: number[] | string;
617
- thickness?: number;
618
- }): Mat | undefined;
727
+ function fillPoly(
728
+ mat: Mat,
729
+ options: { pts: Point[][] | Point[]; color?: number[] | string },
730
+ ): Mat | undefined;
731
+ function polylines(
732
+ mat: Mat,
733
+ options: {
734
+ pts: Point[][] | Point[];
735
+ isClosed?: boolean;
736
+ color?: number[] | string;
737
+ thickness?: number;
738
+ },
739
+ ): Mat | undefined;
740
+ function drawContours(
741
+ mat: Mat,
742
+ options: {
743
+ contours?: Point[][];
744
+ pts?: Point[][];
745
+ contourIdx?: number;
746
+ color?: number[] | string;
747
+ thickness?: number;
748
+ },
749
+ ): Mat | undefined;
619
750
  ```
620
751
 
621
752
  就地绘制。`contourIdx` 为 `-1`(默认)表示画全部。
@@ -624,7 +755,14 @@ function drawContours(mat: Mat, options: {
624
755
 
625
756
  ```javascript
626
757
  cv.polylines(src, {
627
- pts: [[{ x: 0, y: 0 }, { x: 100, y: 0 }, { x: 100, y: 80 }, { x: 0, y: 80 }]],
758
+ pts: [
759
+ [
760
+ { x: 0, y: 0 },
761
+ { x: 100, y: 0 },
762
+ { x: 100, y: 80 },
763
+ { x: 0, y: 80 },
764
+ ],
765
+ ],
628
766
  isClosed: true,
629
767
  color: [0, 255, 0],
630
768
  thickness: 2,
@@ -638,17 +776,25 @@ cv.polylines(src, {
638
776
  ### matchTemplate / matchTemplateLoc
639
777
 
640
778
  ```typescript
641
- function matchTemplate(image: Mat, templ: Mat, methodOrOptions?: number | { method?: number; mask?: Mat }): Mat | undefined;
642
- function matchTemplateLoc(image: Mat, templ: Mat, methodOrOptions?: number | { method?: number }): MatchLocResult | undefined;
779
+ function matchTemplate(
780
+ image: Mat,
781
+ templ: Mat,
782
+ methodOrOptions?: number | { method?: number; mask?: Mat },
783
+ ): Mat | undefined;
784
+ function matchTemplateLoc(
785
+ image: Mat,
786
+ templ: Mat,
787
+ methodOrOptions?: number | { method?: number },
788
+ ): MatchLocResult | undefined;
643
789
  ```
644
790
 
645
791
  **参数:**
646
792
 
647
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
648
- | --- | --- | --- | --- | --- |
649
- | `image` | Mat | 是 | - | 大图 |
650
- | `templ` | Mat | 是 | - | 模板(须小于大图) |
651
- | `method` | number | 否 | `TM_CCOEFF_NORMED` | 匹配方法 |
793
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
794
+ | -------- | ------ | -------- | ------------------ | ------------------ |
795
+ | `image` | Mat | 是 | - | 大图 |
796
+ | `templ` | Mat | 是 | - | 模板(须小于大图) |
797
+ | `method` | number | 否 | `TM_CCOEFF_NORMED` | 匹配方法 |
652
798
 
653
799
  **matchTemplateLoc 返回:** `{ x, y, minVal, maxVal }`(最佳位置取自 max 或 min,取决于 method)。
654
800
 
@@ -668,15 +814,18 @@ cv.rectangle(src, {
668
814
  ### findContours
669
815
 
670
816
  ```typescript
671
- function findContours(mat: Mat, options?: { mode?: number; method?: number }): { contours: Point[][]; hierarchy: number[][] } | undefined;
817
+ function findContours(
818
+ mat: Mat,
819
+ options?: { mode?: number; method?: number },
820
+ ): { contours: Point[][]; hierarchy: number[][] } | undefined;
672
821
  ```
673
822
 
674
823
  **参数:**
675
824
 
676
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
677
- | --- | --- | --- | --- | --- |
678
- | `mode` | number | 否 | `RETR_EXTERNAL` | 如 `RETR_LIST` / `RETR_TREE` |
679
- | `method` | number | 否 | `CHAIN_APPROX_SIMPLE` | 如 `CHAIN_APPROX_NONE` |
825
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
826
+ | -------- | ------ | -------- | --------------------- | ---------------------------- |
827
+ | `mode` | number | 否 | `RETR_EXTERNAL` | 如 `RETR_LIST` / `RETR_TREE` |
828
+ | `method` | number | 否 | `CHAIN_APPROX_SIMPLE` | 如 `CHAIN_APPROX_NONE` |
680
829
 
681
830
  **返回值:** `contours` 为点集;`hierarchy` 为每个轮廓的 `[next, prev, child, parent]`(`-1` 表示无)。
682
831
 
@@ -685,7 +834,10 @@ function findContours(mat: Mat, options?: { mode?: number; method?: number }): {
685
834
  **示例:**
686
835
 
687
836
  ```javascript
688
- const { contours, hierarchy } = cv.findContours(bin, { mode: cv.RETR_TREE, method: cv.CHAIN_APPROX_SIMPLE });
837
+ const { contours, hierarchy } = cv.findContours(bin, {
838
+ mode: cv.RETR_TREE,
839
+ method: cv.CHAIN_APPROX_SIMPLE,
840
+ });
689
841
  logi(`count=${contours.length} h0=${hierarchy[0]}`);
690
842
  ```
691
843
 
@@ -694,10 +846,22 @@ logi(`count=${contours.length} h0=${hierarchy[0]}`);
694
846
  ```typescript
695
847
  function boundingRect(matOrPoints: Mat | Point[]): Rect | undefined;
696
848
  function minAreaRect(points: Point[]): RotatedRect | undefined;
697
- function contourArea(matOrPoints: Mat | Point[], orientedOrOptions?: boolean | { oriented?: boolean }): number;
698
- function arcLength(points: Point[], closedOrOptions?: boolean | { closed?: boolean; isClosed?: boolean }): number;
699
- function approxPolyDP(points: Point[], options: { epsilon?: number; closed?: boolean }): Point[] | undefined;
700
- function convexHull(points: Point[], options?: { clockwise?: boolean }): Point[] | undefined;
849
+ function contourArea(
850
+ matOrPoints: Mat | Point[],
851
+ orientedOrOptions?: boolean | { oriented?: boolean },
852
+ ): number;
853
+ function arcLength(
854
+ points: Point[],
855
+ closedOrOptions?: boolean | { closed?: boolean; isClosed?: boolean },
856
+ ): number;
857
+ function approxPolyDP(
858
+ points: Point[],
859
+ options: { epsilon?: number; closed?: boolean },
860
+ ): Point[] | undefined;
861
+ function convexHull(
862
+ points: Point[],
863
+ options?: { clockwise?: boolean },
864
+ ): Point[] | undefined;
701
865
  ```
702
866
 
703
867
  **示例:**
@@ -708,7 +872,10 @@ for (const c of contours) {
708
872
  if (area < 100) continue;
709
873
  const rect = cv.boundingRect(c);
710
874
  const hull = cv.convexHull(c);
711
- const approx = cv.approxPolyDP(c, { epsilon: 0.02 * cv.arcLength(c, true), closed: true });
875
+ const approx = cv.approxPolyDP(c, {
876
+ epsilon: 0.02 * cv.arcLength(c, true),
877
+ closed: true,
878
+ });
712
879
  cv.rectangle(src, { rect, color: [0, 255, 0], thickness: 1 });
713
880
  }
714
881
  ```
@@ -716,10 +883,17 @@ for (const c of contours) {
716
883
  ### moments / matchShapes
717
884
 
718
885
  ```typescript
719
- function moments(mat: Mat, options?: { binaryImage?: boolean }): MomentsResult | undefined;
886
+ function moments(
887
+ mat: Mat,
888
+ options?: { binaryImage?: boolean },
889
+ ): MomentsResult | undefined;
720
890
  function moments(mat: Mat, binaryImage?: boolean): MomentsResult | undefined;
721
891
  function moments(points: Point[]): MomentsResult | undefined;
722
- function matchShapes(contour1: Mat, contour2: Mat, options?: { method?: number; parameter?: number }): number;
892
+ function matchShapes(
893
+ contour1: Mat,
894
+ contour2: Mat,
895
+ options?: { method?: number; parameter?: number },
896
+ ): number;
723
897
  const cx = m.m10 / m.m00;
724
898
  const cy = m.m01 / m.m00;
725
899
  const score = cv.matchShapes(c1, c2, { method: cv.CONTOURS_MATCH_I1 });
@@ -728,7 +902,10 @@ const score = cv.matchShapes(c1, c2, { method: cv.CONTOURS_MATCH_I1 });
728
902
  ### erode / dilate / morphologyEx / getStructuringElement
729
903
 
730
904
  ```typescript
731
- function getStructuringElement(options: { shape?: number; ksize: number | [number, number] | Size }): Mat | undefined;
905
+ function getStructuringElement(options: {
906
+ shape?: number;
907
+ ksize: number | [number, number] | Size;
908
+ }): Mat | undefined;
732
909
  const opened = cv.morphologyEx(bin, { op: cv.MORPH_OPEN, kernel: k });
733
910
  cv.release(k);
734
911
  cv.release(opened);
@@ -737,28 +914,39 @@ cv.release(opened);
737
914
  ### connectedComponentsWithStats / distanceTransform / floodFill / goodFeaturesToTrack
738
915
 
739
916
  ```typescript
740
- function connectedComponentsWithStats(mat: Mat): {
741
- count: number;
742
- labels?: Mat;
743
- stats?: Mat;
744
- centroids?: Mat;
745
- } | undefined;
746
-
747
- function distanceTransform(mat: Mat, options?: { distanceType?: number; maskSize?: number }): Mat | undefined;
748
-
749
- function floodFill(mat: Mat, options: {
750
- seedPoint: Point | [number, number];
751
- newVal: number[] | string;
752
- loDiff?: number[] | string;
753
- upDiff?: number[] | string;
754
- }): { filled: number; rect: Rect } | undefined;
755
-
756
- function goodFeaturesToTrack(mat: Mat, options: {
757
- maxCorners?: number;
758
- qualityLevel?: number;
759
- minDistance?: number;
760
- mask?: Mat;
761
- }): Point[] | undefined;
917
+ function connectedComponentsWithStats(mat: Mat):
918
+ | {
919
+ count: number;
920
+ labels?: Mat;
921
+ stats?: Mat;
922
+ centroids?: Mat;
923
+ }
924
+ | undefined;
925
+
926
+ function distanceTransform(
927
+ mat: Mat,
928
+ options?: { distanceType?: number; maskSize?: number },
929
+ ): Mat | undefined;
930
+
931
+ function floodFill(
932
+ mat: Mat,
933
+ options: {
934
+ seedPoint: Point | [number, number];
935
+ newVal: number[] | string;
936
+ loDiff?: number[] | string;
937
+ upDiff?: number[] | string;
938
+ },
939
+ ): { filled: number; rect: Rect } | undefined;
940
+
941
+ function goodFeaturesToTrack(
942
+ mat: Mat,
943
+ options: {
944
+ maxCorners?: number;
945
+ qualityLevel?: number;
946
+ minDistance?: number;
947
+ mask?: Mat;
948
+ },
949
+ ): Point[] | undefined;
762
950
  ```
763
951
 
764
952
  **说明:**
@@ -786,16 +974,29 @@ const corners = cv.goodFeaturesToTrack(gray, {
786
974
  ### HoughLinesP / HoughCircles
787
975
 
788
976
  ```typescript
789
- function HoughLinesP(mat: Mat, options: {
790
- rho?: number; theta?: number; threshold?: number;
791
- minLineLength?: number; maxLineGap?: number;
792
- }): Array<{ x1: number; y1: number; x2: number; y2: number }> | undefined;
793
-
794
- function HoughCircles(mat: Mat, options: {
795
- method?: number; dp?: number; minDist?: number;
796
- param1?: number; param2?: number;
797
- minRadius?: number; maxRadius?: number;
798
- }): Array<{ x: number; y: number; radius: number }> | undefined;
977
+ function HoughLinesP(
978
+ mat: Mat,
979
+ options: {
980
+ rho?: number;
981
+ theta?: number;
982
+ threshold?: number;
983
+ minLineLength?: number;
984
+ maxLineGap?: number;
985
+ },
986
+ ): Array<{ x1: number; y1: number; x2: number; y2: number }> | undefined;
987
+
988
+ function HoughCircles(
989
+ mat: Mat,
990
+ options: {
991
+ method?: number;
992
+ dp?: number;
993
+ minDist?: number;
994
+ param1?: number;
995
+ param2?: number;
996
+ minRadius?: number;
997
+ maxRadius?: number;
998
+ },
999
+ ): Array<{ x: number; y: number; radius: number }> | undefined;
799
1000
  ```
800
1001
 
801
1002
  输入一般为边缘图(直线)或灰度图(圆)。`method` 常用 `cv.HOUGH_GRADIENT`。
@@ -811,7 +1012,12 @@ const lines = cv.HoughLinesP(edges, {
811
1012
  maxLineGap: 10,
812
1013
  });
813
1014
  for (const l of lines) {
814
- cv.line(src, { pt1: { x: l.x1, y: l.y1 }, pt2: { x: l.x2, y: l.y2 }, color: [0, 255, 0], thickness: 1 });
1015
+ cv.line(src, {
1016
+ pt1: { x: l.x1, y: l.y1 },
1017
+ pt2: { x: l.x2, y: l.y2 },
1018
+ color: [0, 255, 0],
1019
+ thickness: 1,
1020
+ });
815
1021
  }
816
1022
 
817
1023
  const circles = cv.HoughCircles(gray, {
@@ -833,9 +1039,18 @@ const circles = cv.HoughCircles(gray, {
833
1039
 
834
1040
  ```typescript
835
1041
  function add(src1: Mat, options: { src2: Mat; mask?: Mat }): Mat | undefined;
836
- function subtract(src1: Mat, options: { src2: Mat; mask?: Mat }): Mat | undefined;
837
- function multiply(src1: Mat, options: { src2: Mat; scale?: number }): Mat | undefined;
838
- function divide(src1: Mat, options: { src2: Mat; scale?: number }): Mat | undefined;
1042
+ function subtract(
1043
+ src1: Mat,
1044
+ options: { src2: Mat; mask?: Mat },
1045
+ ): Mat | undefined;
1046
+ function multiply(
1047
+ src1: Mat,
1048
+ options: { src2: Mat; scale?: number },
1049
+ ): Mat | undefined;
1050
+ function divide(
1051
+ src1: Mat,
1052
+ options: { src2: Mat; scale?: number },
1053
+ ): Mat | undefined;
839
1054
  ```
840
1055
 
841
1056
  **示例:**
@@ -848,9 +1063,18 @@ const scaled = cv.multiply(a, { src2: b, scale: 0.5 });
848
1063
  ### normalize / norm / meanStdDev / findNonZero / hconcat / vconcat
849
1064
 
850
1065
  ```typescript
851
- function normalize(mat: Mat, options?: { alpha?: number; beta?: number; normType?: number }): Mat | undefined;
852
- function norm(mat: Mat, options?: { normType?: number; mask?: Mat; src2?: Mat }): number;
853
- function meanStdDev(mat: Mat, options?: { mask?: Mat }): { mean: number[]; stddev: number[] } | undefined;
1066
+ function normalize(
1067
+ mat: Mat,
1068
+ options?: { alpha?: number; beta?: number; normType?: number },
1069
+ ): Mat | undefined;
1070
+ function norm(
1071
+ mat: Mat,
1072
+ options?: { normType?: number; mask?: Mat; src2?: Mat },
1073
+ ): number;
1074
+ function meanStdDev(
1075
+ mat: Mat,
1076
+ options?: { mask?: Mat },
1077
+ ): { mean: number[]; stddev: number[] } | undefined;
854
1078
  function findNonZero(mat: Mat): Point[] | undefined;
855
1079
  function hconcat(mats: Mat[]): Mat | undefined;
856
1080
  function vconcat(mats: Mat[]): Mat | undefined;
@@ -859,7 +1083,11 @@ function vconcat(mats: Mat[]): Mat | undefined;
859
1083
  **示例:**
860
1084
 
861
1085
  ```javascript
862
- const n01 = cv.normalize(gray, { alpha: 0, beta: 255, normType: cv.NORM_MINMAX });
1086
+ const n01 = cv.normalize(gray, {
1087
+ alpha: 0,
1088
+ beta: 255,
1089
+ normType: cv.NORM_MINMAX,
1090
+ });
863
1091
  const pts = cv.findNonZero(mask);
864
1092
  const side = cv.hconcat([left, right]);
865
1093
  ```
@@ -869,16 +1097,32 @@ const side = cv.hconcat([left, right]);
869
1097
  已知对应点求变换矩阵。透视 ≥4 点,仿射 ≥3 点。
870
1098
 
871
1099
  ```typescript
872
- function getPerspectiveTransform(options: { srcPoints: Point[]; dstPoints: Point[] }): Mat | undefined;
873
- function getAffineTransform(options: { srcPoints: Point[]; dstPoints: Point[] }): Mat | undefined;
1100
+ function getPerspectiveTransform(options: {
1101
+ srcPoints: Point[];
1102
+ dstPoints: Point[];
1103
+ }): Mat | undefined;
1104
+ function getAffineTransform(options: {
1105
+ srcPoints: Point[];
1106
+ dstPoints: Point[];
1107
+ }): Mat | undefined;
874
1108
  ```
875
1109
 
876
1110
  **示例:**
877
1111
 
878
1112
  ```javascript
879
1113
  const M = cv.getPerspectiveTransform({
880
- srcPoints: [{ x: 10, y: 10 }, { x: 200, y: 20 }, { x: 190, y: 300 }, { x: 20, y: 280 }],
881
- dstPoints: [{ x: 0, y: 0 }, { x: 300, y: 0 }, { x: 300, y: 400 }, { x: 0, y: 400 }],
1114
+ srcPoints: [
1115
+ { x: 10, y: 10 },
1116
+ { x: 200, y: 20 },
1117
+ { x: 190, y: 300 },
1118
+ { x: 20, y: 280 },
1119
+ ],
1120
+ dstPoints: [
1121
+ { x: 0, y: 0 },
1122
+ { x: 300, y: 0 },
1123
+ { x: 300, y: 400 },
1124
+ { x: 0, y: 400 },
1125
+ ],
882
1126
  });
883
1127
  const warped = cv.warpPerspective(src, { M, width: 300, height: 400 });
884
1128
  cv.release(M);
@@ -888,8 +1132,15 @@ cv.release(warped);
888
1132
  ### FlannBasedMatcher / flannKnnMatch
889
1133
 
890
1134
  ```typescript
891
- function FlannBasedMatcher(queryDescriptors: Mat, trainDescriptors: Mat): DMatch[] | undefined;
892
- function flannKnnMatch(queryDescriptors: Mat, trainDescriptors: Mat, options?: { k?: number; ratio?: number }): DMatch[][] | undefined;
1135
+ function FlannBasedMatcher(
1136
+ queryDescriptors: Mat,
1137
+ trainDescriptors: Mat,
1138
+ ): DMatch[] | undefined;
1139
+ function flannKnnMatch(
1140
+ queryDescriptors: Mat,
1141
+ trainDescriptors: Mat,
1142
+ options?: { k?: number; ratio?: number },
1143
+ ): DMatch[][] | undefined;
893
1144
  ```
894
1145
 
895
1146
  SIFT 等浮点描述子可用 Flann;ORB 建议 `BFMatcher` + `NORM_HAMMING`。
@@ -897,14 +1148,26 @@ SIFT 等浮点描述子可用 Flann;ORB 建议 `BFMatcher` + `NORM_HAMMING`。
897
1148
  **示例:**
898
1149
 
899
1150
  ```javascript
900
- const knn = cv.flannKnnMatch(f2.descriptors, f1.descriptors, { k: 2, ratio: 0.75 });
1151
+ const knn = cv.flannKnnMatch(f2.descriptors, f1.descriptors, {
1152
+ k: 2,
1153
+ ratio: 0.75,
1154
+ });
901
1155
  const good = knn.map((g) => g[0]);
902
1156
  ```
903
1157
 
904
1158
  ### calcHist / compareHist
905
1159
 
906
1160
  ```typescript
907
- function calcHist(mat: Mat, options?: { channels?: number[]; histSize?: number[]; ranges?: number[]; mask?: Mat; accumulate?: boolean }): Mat | undefined;
1161
+ function calcHist(
1162
+ mat: Mat,
1163
+ options?: {
1164
+ channels?: number[];
1165
+ histSize?: number[];
1166
+ ranges?: number[];
1167
+ mask?: Mat;
1168
+ accumulate?: boolean;
1169
+ },
1170
+ ): Mat | undefined;
908
1171
  function compareHist(H1: Mat, H2: Mat, options?: { method?: number }): number;
909
1172
  ```
910
1173
 
@@ -916,15 +1179,20 @@ function compareHist(H1: Mat, H2: Mat, options?: { method?: number }): number;
916
1179
  const h1 = cv.calcHist(gray1);
917
1180
  const h2 = cv.calcHist(gray2);
918
1181
  const score = cv.compareHist(h1, h2, { method: cv.HISTCMP_CORREL });
919
- cv.release(h1); cv.release(h2);
1182
+ cv.release(h1);
1183
+ cv.release(h2);
920
1184
  ```
921
1185
 
922
1186
  ### encodeQRCode / detectQRCode / detectBarcode
923
1187
 
924
1188
  ```typescript
925
1189
  function encodeQRCode(text: string): Mat | undefined;
926
- function detectQRCode(mat: Mat): { decoded: string; points: Point[] } | undefined;
927
- function detectBarcode(mat: Mat): { decoded: string[]; types: string[]; points: Point[] } | undefined;
1190
+ function detectQRCode(
1191
+ mat: Mat,
1192
+ ): { decoded: string; points: Point[] } | undefined;
1193
+ function detectBarcode(
1194
+ mat: Mat,
1195
+ ): { decoded: string[]; types: string[]; points: Point[] } | undefined;
928
1196
  ```
929
1197
 
930
1198
  `encodeQRCode` 返回可显示/可识别的 BGR Mat(已放大并加静区),可直接交给 `detectQRCode`。
@@ -943,9 +1211,28 @@ cv.release(qrMat);
943
1211
  ### filter2D / ellipse / getTextSize
944
1212
 
945
1213
  ```typescript
946
- function filter2D(mat: Mat, options: { kernel: Mat; ddepth?: number; delta?: number }): Mat | undefined;
947
- function ellipse(mat: Mat, options: { center: Point; axes: Size | [number, number]; angle?: number; startAngle?: number; endAngle?: number; color?: number[] | string; thickness?: number }): Mat | undefined;
948
- function getTextSize(options: { text: string; fontFace?: number; fontScale?: number; thickness?: number }): { width: number; height: number; baseLine: number } | undefined;
1214
+ function filter2D(
1215
+ mat: Mat,
1216
+ options: { kernel: Mat; ddepth?: number; delta?: number },
1217
+ ): Mat | undefined;
1218
+ function ellipse(
1219
+ mat: Mat,
1220
+ options: {
1221
+ center: Point;
1222
+ axes: Size | [number, number];
1223
+ angle?: number;
1224
+ startAngle?: number;
1225
+ endAngle?: number;
1226
+ color?: number[] | string;
1227
+ thickness?: number;
1228
+ },
1229
+ ): Mat | undefined;
1230
+ function getTextSize(options: {
1231
+ text: string;
1232
+ fontFace?: number;
1233
+ fontScale?: number;
1234
+ thickness?: number;
1235
+ }): { width: number; height: number; baseLine: number } | undefined;
949
1236
  ```
950
1237
 
951
1238
  `ellipse` 就地绘制;`thickness: cv.FILLED` 表示填充。
@@ -958,21 +1245,21 @@ function getTextSize(options: { text: string; fontFace?: number; fontScale?: num
958
1245
 
959
1246
  **KeyPoint:**
960
1247
 
961
- | 字段 | 类型 | 描述 |
962
- | --- | --- | --- |
963
- | `x` / `y` | number | 坐标 |
964
- | `size` | number | 邻域直径 |
965
- | `angle` | number | 方向;不适用为 `-1` |
966
- | `response` | number | 响应强度 |
967
- | `octave` | number | 金字塔层 |
968
- | `class_id` | number | 类别 id |
1248
+ | 字段 | 类型 | 描述 |
1249
+ | ---------- | ------ | ------------------- |
1250
+ | `x` / `y` | number | 坐标 |
1251
+ | `size` | number | 邻域直径 |
1252
+ | `angle` | number | 方向;不适用为 `-1` |
1253
+ | `response` | number | 响应强度 |
1254
+ | `octave` | number | 金字塔层 |
1255
+ | `class_id` | number | 类别 id |
969
1256
 
970
1257
  **DMatch:**
971
1258
 
972
- | 字段 | 类型 | 描述 |
973
- | --- | --- | --- |
974
- | `queryIdx` | number | 查询描述子索引 |
975
- | `trainIdx` | number | 训练描述子索引 |
1259
+ | 字段 | 类型 | 描述 |
1260
+ | ---------- | ------ | ------------------ |
1261
+ | `queryIdx` | number | 查询描述子索引 |
1262
+ | `trainIdx` | number | 训练描述子索引 |
976
1263
  | `distance` | number | 距离(越小越相似) |
977
1264
 
978
1265
  **FeatureResult:** `{ keypoints: KeyPoint[], descriptors: Mat | null }`
@@ -981,27 +1268,30 @@ function getTextSize(options: { text: string; fontFace?: number; fontScale?: num
981
1268
  ### SIFT
982
1269
 
983
1270
  ```typescript
984
- function SIFT(mat: Mat, options?: {
985
- nfeatures?: number;
986
- nOctaveLayers?: number;
987
- contrastThreshold?: number;
988
- edgeThreshold?: number;
989
- sigma?: number;
990
- mask?: Mat;
991
- }): FeatureResult | undefined;
1271
+ function SIFT(
1272
+ mat: Mat,
1273
+ options?: {
1274
+ nfeatures?: number;
1275
+ nOctaveLayers?: number;
1276
+ contrastThreshold?: number;
1277
+ edgeThreshold?: number;
1278
+ sigma?: number;
1279
+ mask?: Mat;
1280
+ },
1281
+ ): FeatureResult | undefined;
992
1282
  ```
993
1283
 
994
1284
  **参数:**
995
1285
 
996
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
997
- | --- | --- | --- | --- | --- |
998
- | `mat` | Mat | 是 | - | 输入图(建议灰度) |
999
- | `nfeatures` | number | 否 | 0(不限制) | 保留最佳特征数量 |
1000
- | `nOctaveLayers` | number | 否 | 3 | 每组 octave 层数 |
1001
- | `contrastThreshold` | number | 否 | 0.04 | 对比度阈值,越大特征越少 |
1002
- | `edgeThreshold` | number | 否 | 10 | 边缘过滤阈值 |
1003
- | `sigma` | number | 否 | 1.6 | 第 0 层高斯 sigma |
1004
- | `mask` | Mat | 否 | - | 可选 ROI 掩膜 |
1286
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
1287
+ | ------------------- | ------ | -------- | ----------- | ------------------------ |
1288
+ | `mat` | Mat | 是 | - | 输入图(建议灰度) |
1289
+ | `nfeatures` | number | 否 | 0(不限制) | 保留最佳特征数量 |
1290
+ | `nOctaveLayers` | number | 否 | 3 | 每组 octave 层数 |
1291
+ | `contrastThreshold` | number | 否 | 0.04 | 对比度阈值,越大特征越少 |
1292
+ | `edgeThreshold` | number | 否 | 10 | 边缘过滤阈值 |
1293
+ | `sigma` | number | 否 | 1.6 | 第 0 层高斯 sigma |
1294
+ | `mask` | Mat | 否 | - | 可选 ROI 掩膜 |
1005
1295
 
1006
1296
  **返回值:** `{ keypoints, descriptors }`;整次失败 `undefined`,描述子失败时 `descriptors` 为 `null`。
1007
1297
 
@@ -1012,7 +1302,10 @@ const gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY);
1012
1302
  const feat = cv.SIFT(gray, { nfeatures: 500 });
1013
1303
  if (feat) {
1014
1304
  logi(`SIFT keypoints=${feat.keypoints.length}`);
1015
- const vis = cv.drawKeypoints(src, { keypoints: feat.keypoints, color: [0, 255, 0] });
1305
+ const vis = cv.drawKeypoints(src, {
1306
+ keypoints: feat.keypoints,
1307
+ color: [0, 255, 0],
1308
+ });
1016
1309
  cv.imwrite(`${file.getInternalDir("documents")}/sift.png`, vis);
1017
1310
  cv.release(vis);
1018
1311
  cv.release(feat.descriptors);
@@ -1023,21 +1316,24 @@ cv.release(gray);
1023
1316
  ### ORB
1024
1317
 
1025
1318
  ```typescript
1026
- function ORB(mat: Mat, options?: {
1027
- nfeatures?: number;
1028
- scaleFactor?: number;
1029
- nlevels?: number;
1030
- mask?: Mat;
1031
- }): FeatureResult | undefined;
1319
+ function ORB(
1320
+ mat: Mat,
1321
+ options?: {
1322
+ nfeatures?: number;
1323
+ scaleFactor?: number;
1324
+ nlevels?: number;
1325
+ mask?: Mat;
1326
+ },
1327
+ ): FeatureResult | undefined;
1032
1328
  ```
1033
1329
 
1034
1330
  **参数:**
1035
1331
 
1036
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
1037
- | --- | --- | --- | --- | --- |
1038
- | `nfeatures` | number | 否 | 500 | 最大特征数 |
1039
- | `scaleFactor` | number | 否 | 1.2 | 金字塔尺度因子 |
1040
- | `nlevels` | number | 否 | 8 | 金字塔层数 |
1332
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
1333
+ | ------------- | ------ | -------- | ------ | -------------- |
1334
+ | `nfeatures` | number | 否 | 500 | 最大特征数 |
1335
+ | `scaleFactor` | number | 否 | 1.2 | 金字塔尺度因子 |
1336
+ | `nlevels` | number | 否 | 8 | 金字塔层数 |
1041
1337
 
1042
1338
  **说明:** ORB 描述子为二进制,匹配请用 `cv.NORM_HAMMING`(或 `NORM_HAMMING2`)。实时/循环优先 ORB。
1043
1339
 
@@ -1058,10 +1354,14 @@ cv.release(b.descriptors);
1058
1354
  ### BFMatcher
1059
1355
 
1060
1356
  ```typescript
1061
- function BFMatcher(queryDescriptors: Mat, trainDescriptors: Mat, options?: {
1062
- normType?: number;
1063
- crossCheck?: boolean;
1064
- }): DMatch[] | undefined;
1357
+ function BFMatcher(
1358
+ queryDescriptors: Mat,
1359
+ trainDescriptors: Mat,
1360
+ options?: {
1361
+ normType?: number;
1362
+ crossCheck?: boolean;
1363
+ },
1364
+ ): DMatch[] | undefined;
1065
1365
  matches.sort((a, b) => a.distance - b.distance);
1066
1366
  const top = matches.slice(0, 30);
1067
1367
  ```
@@ -1069,20 +1369,24 @@ const top = matches.slice(0, 30);
1069
1369
  ### knnMatch
1070
1370
 
1071
1371
  ```typescript
1072
- function knnMatch(queryDescriptors: Mat, trainDescriptors: Mat, options?: {
1073
- k?: number;
1074
- normType?: number;
1075
- ratio?: number;
1076
- }): DMatch[][] | undefined;
1372
+ function knnMatch(
1373
+ queryDescriptors: Mat,
1374
+ trainDescriptors: Mat,
1375
+ options?: {
1376
+ k?: number;
1377
+ normType?: number;
1378
+ ratio?: number;
1379
+ },
1380
+ ): DMatch[][] | undefined;
1077
1381
  ```
1078
1382
 
1079
1383
  **参数:**
1080
1384
 
1081
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
1082
- | --- | --- | --- | --- | --- |
1083
- | `k` | number | 否 | 2 | 每个查询点取 K 个最近邻 |
1084
- | `normType` | number | 否 | `NORM_L2` | 距离类型 |
1085
- | `ratio` | number | 否 | - | 如 `0.75`:启用 Lowe ratio test,只保留通过筛选的最近邻 |
1385
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
1386
+ | ---------- | ------ | -------- | --------- | ------------------------------------------------------- |
1387
+ | `k` | number | 否 | 2 | 每个查询点取 K 个最近邻 |
1388
+ | `normType` | number | 否 | `NORM_L2` | 距离类型 |
1389
+ | `ratio` | number | 否 | - | 如 `0.75`:启用 Lowe ratio test,只保留通过筛选的最近邻 |
1086
1390
 
1087
1391
  **返回值:**
1088
1392
 
@@ -1104,13 +1408,19 @@ logi(`good matches=${good.length}`);
1104
1408
  ### drawKeypoints / drawMatches
1105
1409
 
1106
1410
  ```typescript
1107
- function drawKeypoints(mat: Mat, options: { keypoints: KeyPoint[]; color?: number[] | string }): Mat | undefined;
1108
- function drawMatches(img1: Mat, options: {
1109
- img2: Mat;
1110
- keypoints1: KeyPoint[];
1111
- keypoints2: KeyPoint[];
1112
- matches1to2: DMatch[];
1113
- }): Mat | undefined;
1411
+ function drawKeypoints(
1412
+ mat: Mat,
1413
+ options: { keypoints: KeyPoint[]; color?: number[] | string },
1414
+ ): Mat | undefined;
1415
+ function drawMatches(
1416
+ img1: Mat,
1417
+ options: {
1418
+ img2: Mat;
1419
+ keypoints1: KeyPoint[];
1420
+ keypoints2: KeyPoint[];
1421
+ matches1to2: DMatch[];
1422
+ },
1423
+ ): Mat | undefined;
1114
1424
  cv.imwrite(`${file.getInternalDir("documents")}/matches.png`, vis);
1115
1425
  cv.release(vis);
1116
1426
  ```
@@ -1125,7 +1435,10 @@ function findHomography(options: {
1125
1435
  ransacReprojThreshold?: number;
1126
1436
  }): Mat | undefined;
1127
1437
 
1128
- function perspectiveTransform(points: Point[], options: { M: Mat }): Point[] | undefined;
1438
+ function perspectiveTransform(
1439
+ points: Point[],
1440
+ options: { M: Mat },
1441
+ ): Point[] | undefined;
1129
1442
  const templ = cv.imread("logo.png");
1130
1443
  const g1 = cv.cvtColor(src, cv.COLOR_BGR2GRAY);
1131
1444
  const g2 = cv.cvtColor(templ, cv.COLOR_BGR2GRAY);
@@ -1164,7 +1477,12 @@ if (good.length >= 4) {
1164
1477
  ],
1165
1478
  { M: H },
1166
1479
  );
1167
- cv.polylines(src, { pts: [corners], isClosed: true, color: [0, 255, 0], thickness: 2 });
1480
+ cv.polylines(src, {
1481
+ pts: [corners],
1482
+ isClosed: true,
1483
+ color: [0, 255, 0],
1484
+ thickness: 2,
1485
+ });
1168
1486
  cv.release(H);
1169
1487
  }
1170
1488
 
@@ -1183,14 +1501,17 @@ cv.release(f2.descriptors);
1183
1501
  ### inpaint
1184
1502
 
1185
1503
  ```typescript
1186
- function inpaint(mat: Mat, options: { mask: Mat; inpaintRadius?: number; flags?: number }): Mat | undefined;
1504
+ function inpaint(
1505
+ mat: Mat,
1506
+ options: { mask: Mat; inpaintRadius?: number; flags?: number },
1507
+ ): Mat | undefined;
1187
1508
  ```
1188
1509
 
1189
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
1190
- | --- | --- | --- | --- | --- |
1191
- | `mask` | Mat | 是 | - | 非零区域待修复 |
1192
- | `inpaintRadius` | number | 否 | 3 | 邻域半径 |
1193
- | `flags` | number | 否 | `INPAINT_TELEA` | `INPAINT_NS` / `INPAINT_TELEA` |
1510
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
1511
+ | --------------- | ------ | -------- | --------------- | ------------------------------ |
1512
+ | `mask` | Mat | 是 | - | 非零区域待修复 |
1513
+ | `inpaintRadius` | number | 否 | 3 | 邻域半径 |
1514
+ | `flags` | number | 否 | `INPAINT_TELEA` | `INPAINT_NS` / `INPAINT_TELEA` |
1194
1515
 
1195
1516
  ```javascript
1196
1517
  const out = cv.inpaint(src, { mask, flags: cv.INPAINT_TELEA });
@@ -1199,12 +1520,23 @@ const out = cv.inpaint(src, { mask, flags: cv.INPAINT_TELEA });
1199
1520
  ### fastNlMeansDenoising / fastNlMeansDenoisingColored
1200
1521
 
1201
1522
  ```typescript
1202
- function fastNlMeansDenoising(mat: Mat, options?: {
1203
- h?: number; templateWindowSize?: number; searchWindowSize?: number;
1204
- }): Mat | undefined;
1205
- function fastNlMeansDenoisingColored(mat: Mat, options?: {
1206
- h?: number; hColor?: number; templateWindowSize?: number; searchWindowSize?: number;
1207
- }): Mat | undefined;
1523
+ function fastNlMeansDenoising(
1524
+ mat: Mat,
1525
+ options?: {
1526
+ h?: number;
1527
+ templateWindowSize?: number;
1528
+ searchWindowSize?: number;
1529
+ },
1530
+ ): Mat | undefined;
1531
+ function fastNlMeansDenoisingColored(
1532
+ mat: Mat,
1533
+ options?: {
1534
+ h?: number;
1535
+ hColor?: number;
1536
+ templateWindowSize?: number;
1537
+ searchWindowSize?: number;
1538
+ },
1539
+ ): Mat | undefined;
1208
1540
  ```
1209
1541
 
1210
1542
  ```javascript
@@ -1218,7 +1550,10 @@ const d2 = cv.fastNlMeansDenoisingColored(src, { h: 3, hColor: 3 });
1218
1550
 
1219
1551
  ```typescript
1220
1552
  function LUT(mat: Mat, options: { lut: Mat }): Mat | undefined;
1221
- function compare(src1: Mat, options: { src2: Mat; cmpop: number }): Mat | undefined;
1553
+ function compare(
1554
+ src1: Mat,
1555
+ options: { src2: Mat; cmpop: number },
1556
+ ): Mat | undefined;
1222
1557
  function min(src1: Mat, options: { src2: Mat }): Mat | undefined;
1223
1558
  function max(src1: Mat, options: { src2: Mat }): Mat | undefined;
1224
1559
  ```
@@ -1235,13 +1570,26 @@ const lo = cv.min(a, { src2: b });
1235
1570
  ### connectedComponents / convexityDefects / isContourConvex / fitLine / fitEllipse
1236
1571
 
1237
1572
  ```typescript
1238
- function connectedComponents(mat: Mat, options?: { connectivity?: number }): { count: number; labels: Mat } | undefined;
1239
- function convexityDefects(contour: Point[], options: { hull: number[] | Point[] }):
1240
- Array<{ start: number; end: number; farthest: number; depth: number }> | undefined;
1573
+ function connectedComponents(
1574
+ mat: Mat,
1575
+ options?: { connectivity?: number },
1576
+ ): { count: number; labels: Mat } | undefined;
1577
+ function convexityDefects(
1578
+ contour: Point[],
1579
+ options: { hull: number[] | Point[] },
1580
+ ):
1581
+ | Array<{ start: number; end: number; farthest: number; depth: number }>
1582
+ | undefined;
1241
1583
  function isContourConvex(contour: Point[]): boolean;
1242
- function fitLine(points: Point[], options?: {
1243
- distType?: number; param?: number; reps?: number; aeps?: number;
1244
- }): [number, number, number, number] | undefined;
1584
+ function fitLine(
1585
+ points: Point[],
1586
+ options?: {
1587
+ distType?: number;
1588
+ param?: number;
1589
+ reps?: number;
1590
+ aeps?: number;
1591
+ },
1592
+ ): [number, number, number, number] | undefined;
1245
1593
  function fitEllipse(points: Point[]): RotatedRect | undefined;
1246
1594
  ```
1247
1595
 
@@ -1259,17 +1607,34 @@ cv.release(cc.labels);
1259
1607
  ### getRectSubPix / phaseCorrelate / estimateAffine2D / estimateAffinePartial2D
1260
1608
 
1261
1609
  ```typescript
1262
- function getRectSubPix(mat: Mat, options: {
1263
- patchSize: Size | [number, number]; center: Point;
1264
- }): Mat | undefined;
1265
- function phaseCorrelate(src1: Mat, options: { src2: Mat; window?: Mat }): {
1266
- x: number; y: number; response?: number;
1267
- } | undefined;
1610
+ function getRectSubPix(
1611
+ mat: Mat,
1612
+ options: {
1613
+ patchSize: Size | [number, number];
1614
+ center: Point;
1615
+ },
1616
+ ): Mat | undefined;
1617
+ function phaseCorrelate(
1618
+ src1: Mat,
1619
+ options: { src2: Mat; window?: Mat },
1620
+ ):
1621
+ | {
1622
+ x: number;
1623
+ y: number;
1624
+ response?: number;
1625
+ }
1626
+ | undefined;
1268
1627
  function estimateAffine2D(options: {
1269
- srcPoints: Point[]; dstPoints: Point[]; method?: number; ransacReprojThreshold?: number;
1628
+ srcPoints: Point[];
1629
+ dstPoints: Point[];
1630
+ method?: number;
1631
+ ransacReprojThreshold?: number;
1270
1632
  }): Mat | undefined;
1271
1633
  function estimateAffinePartial2D(options: {
1272
- srcPoints: Point[]; dstPoints: Point[]; method?: number; ransacReprojThreshold?: number;
1634
+ srcPoints: Point[];
1635
+ dstPoints: Point[];
1636
+ method?: number;
1637
+ ransacReprojThreshold?: number;
1273
1638
  }): Mat | undefined;
1274
1639
  ```
1275
1640
 
@@ -1277,28 +1642,62 @@ function estimateAffinePartial2D(options: {
1277
1642
 
1278
1643
  ```javascript
1279
1644
  const shift = cv.phaseCorrelate(prevGray, { src2: gray });
1280
- const M = cv.estimateAffinePartial2D({ srcPoints, dstPoints, method: cv.RANSAC });
1645
+ const M = cv.estimateAffinePartial2D({
1646
+ srcPoints,
1647
+ dstPoints,
1648
+ method: cv.RANSAC,
1649
+ });
1281
1650
  ```
1282
1651
 
1283
1652
  ### drawMarker / arrowedLine / fillConvexPoly(就地)
1284
1653
 
1285
1654
  ```typescript
1286
- function drawMarker(mat: Mat, options: {
1287
- position: Point; color?: number[] | string;
1288
- markerType?: number; markerSize?: number; thickness?: number;
1289
- }): Mat | undefined;
1290
- function arrowedLine(mat: Mat, options: {
1291
- pt1: Point; pt2: Point; color?: number[] | string; thickness?: number; tipLength?: number;
1292
- }): Mat | undefined;
1293
- function fillConvexPoly(mat: Mat, options: { pts: Point[]; color?: number[] | string }): Mat | undefined;
1655
+ function drawMarker(
1656
+ mat: Mat,
1657
+ options: {
1658
+ position: Point;
1659
+ color?: number[] | string;
1660
+ markerType?: number;
1661
+ markerSize?: number;
1662
+ thickness?: number;
1663
+ },
1664
+ ): Mat | undefined;
1665
+ function arrowedLine(
1666
+ mat: Mat,
1667
+ options: {
1668
+ pt1: Point;
1669
+ pt2: Point;
1670
+ color?: number[] | string;
1671
+ thickness?: number;
1672
+ tipLength?: number;
1673
+ },
1674
+ ): Mat | undefined;
1675
+ function fillConvexPoly(
1676
+ mat: Mat,
1677
+ options: { pts: Point[]; color?: number[] | string },
1678
+ ): Mat | undefined;
1294
1679
  ```
1295
1680
 
1296
1681
  就地修改输入 Mat,返回同一句柄。适合调试标注匹配点、滑动方向等。
1297
1682
 
1298
1683
  ```javascript
1299
- cv.drawMarker(src, { position: { x: 100, y: 80 }, markerType: cv.MARKER_CROSS });
1300
- cv.arrowedLine(src, { pt1: { x: 10, y: 10 }, pt2: { x: 120, y: 80 }, color: [0, 255, 0] });
1301
- cv.fillConvexPoly(src, { pts: [{ x: 20, y: 20 }, { x: 70, y: 20 }, { x: 45, y: 60 }], color: [128, 0, 128] });
1684
+ cv.drawMarker(src, {
1685
+ position: { x: 100, y: 80 },
1686
+ markerType: cv.MARKER_CROSS,
1687
+ });
1688
+ cv.arrowedLine(src, {
1689
+ pt1: { x: 10, y: 10 },
1690
+ pt2: { x: 120, y: 80 },
1691
+ color: [0, 255, 0],
1692
+ });
1693
+ cv.fillConvexPoly(src, {
1694
+ pts: [
1695
+ { x: 20, y: 20 },
1696
+ { x: 70, y: 20 },
1697
+ { x: 45, y: 60 },
1698
+ ],
1699
+ color: [128, 0, 128],
1700
+ });
1302
1701
  ```
1303
1702
 
1304
1703
  ## 常用常量
@@ -1339,4 +1738,4 @@ cv.fillConvexPoly(src, { pts: [{ x: 20, y: 20 }, { x: 70, y: 20 }, { x: 45, y: 6
1339
1738
  4. 特征匹配前建议转灰度;大图可先 `pyrDown` / `resize`。
1340
1739
  5. `findHomography` 至少需要 4 对对应点,不足会返回 `undefined`。
1341
1740
  6. 绘制类、`floodFill` 会改原图或指定目标句柄;需保留原图请先 `clone`。
1342
- 7. 与 `image` 互通时,两边句柄各自 `release`。
1741
+ 7. 与 `image` 互通时,两边句柄各自 `release`。