ms-vite-plugin 1.4.58 → 1.4.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/luaBundle.js +1 -1
- package/dist/luaObfuscator/addVararg.d.ts +2 -0
- package/dist/luaObfuscator/addVararg.js +1 -0
- package/dist/luaObfuscator/antiTamper.d.ts +2 -0
- package/dist/luaObfuscator/antiTamper.js +26 -0
- package/dist/luaObfuscator/ast.d.ts +191 -0
- package/dist/luaObfuscator/ast.js +1 -0
- package/dist/luaObfuscator/cipher.d.ts +10 -0
- package/dist/luaObfuscator/cipher.js +28 -0
- package/dist/luaObfuscator/compiler.d.ts +31 -0
- package/dist/luaObfuscator/compiler.js +1 -0
- package/dist/luaObfuscator/constantArray.d.ts +5 -0
- package/dist/luaObfuscator/constantArray.js +1 -0
- package/dist/luaObfuscator/flatten.d.ts +2 -0
- package/dist/luaObfuscator/flatten.js +1 -0
- package/dist/luaObfuscator/index.d.ts +6 -0
- package/dist/luaObfuscator/index.js +1 -0
- package/dist/luaObfuscator/lexer.d.ts +14 -0
- package/dist/luaObfuscator/lexer.js +10 -0
- package/dist/luaObfuscator/minify.d.ts +3 -0
- package/dist/luaObfuscator/minify.js +1 -0
- package/dist/luaObfuscator/numbers.d.ts +2 -0
- package/dist/luaObfuscator/numbers.js +1 -0
- package/dist/luaObfuscator/opcodes.d.ts +3 -0
- package/dist/luaObfuscator/opcodes.js +1 -0
- package/dist/luaObfuscator/parser.d.ts +8 -0
- package/dist/luaObfuscator/parser.js +1 -0
- package/dist/luaObfuscator/rename.d.ts +3 -0
- package/dist/luaObfuscator/rename.js +1 -0
- package/dist/luaObfuscator/reserved.d.ts +5 -0
- package/dist/luaObfuscator/reserved.js +1 -0
- package/dist/luaObfuscator/scope.d.ts +11 -0
- package/dist/luaObfuscator/scope.js +1 -0
- package/dist/luaObfuscator/selftest.d.ts +1 -0
- package/dist/luaObfuscator/selftest.js +39 -0
- package/dist/luaObfuscator/splitStrings.d.ts +2 -0
- package/dist/luaObfuscator/splitStrings.js +1 -0
- package/dist/luaObfuscator/strings.d.ts +4 -0
- package/dist/luaObfuscator/strings.js +1 -0
- package/dist/luaObfuscator/visit.d.ts +5 -0
- package/dist/luaObfuscator/visit.js +1 -0
- package/dist/luaObfuscator/vmEmit.d.ts +2 -0
- package/dist/luaObfuscator/vmEmit.js +281 -0
- package/dist/luaObfuscator/wrapInFunction.d.ts +2 -0
- package/dist/luaObfuscator/wrapInFunction.js +1 -0
- package/docs/AGENTS.md +1 -1
- package/docs/SKILL.md +1 -1
- package/docs/api/media.md +22 -0
- package/docs/apicn/media.md +22 -0
- package/docs/apilua/action.md +2 -27
- package/docs/apilua/appleocr.md +41 -126
- package/docs/apilua/cloud.md +2 -6
- package/docs/apilua/config.md +2 -6
- package/docs/apilua/cryptoUtils.md +2 -7
- package/docs/apilua/device.md +2 -19
- package/docs/apilua/dotocr.md +2 -5
- package/docs/apilua/file.md +2 -17
- package/docs/apilua/global.md +1 -1
- package/docs/apilua/hid.md +2 -44
- package/docs/apilua/hotUpdate.md +2 -3
- package/docs/apilua/http.md +2 -7
- package/docs/apilua/image.md +16 -107
- package/docs/apilua/ime.md +2 -10
- package/docs/apilua/logger.md +3 -9
- package/docs/apilua/media.md +2 -9
- package/docs/apilua/mysql.md +2 -10
- package/docs/apilua/netCard.md +2 -6
- package/docs/apilua/node.md +2 -3
- package/docs/apilua/opencv.md +4 -30
- package/docs/apilua/paddleocr.md +20 -126
- package/docs/apilua/pip.md +2 -12
- package/docs/apilua/system.md +2 -40
- package/docs/apilua/tomatoocr.md +2 -16
- package/docs/apilua/tts.md +2 -9
- package/docs/apilua/ui.md +3 -22
- package/docs/apilua/utils.md +2 -9
- package/docs/apilua/yolo.md +25 -119
- package/docs/apilua/yolocls.md +2 -5
- package/docs/apipython/media.md +20 -0
- package/docs/mcp-agent-description.md +1 -1
- package/docs/quick/vscode/createProject.md +1 -1
- package/docs/quick/vscode/packProject.md +1 -1
- package/package.json +1 -1
package/docs/apilua/opencv.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# OpenCV 模块 (cv)
|
|
2
2
|
|
|
3
3
|
提供图像读写、颜色与阈值、滤波、几何变换、绘制、模板/特征匹配、轮廓、形态学、直方图、霍夫、扫码等能力。
|
|
4
|
-
|
|
4
|
+
模块表是内置全局 `cv`,直接调用即可。不要 `require` 宿主模块。无中文别名。方法与常量对齐 JS `cv`。
|
|
5
5
|
|
|
6
6
|
注意:
|
|
7
7
|
|
|
@@ -51,8 +51,6 @@ Mat:`Mat` · `zeros` · `ones` · `clone` · `empty` · `isRelease` · `releas
|
|
|
51
51
|
霍夫/连通域/直方图/扫码:`HoughLinesP` · `HoughCircles` · `connectedComponents` · `connectedComponentsWithStats` · `distanceTransform` · `floodFill` · `goodFeaturesToTrack` · `cornerHarris` · `cornerSubPix` · `calcHist` · `compareHist` · `calcBackProject` · `encodeQRCode` · `detectQRCode` · `detectBarcode`
|
|
52
52
|
|
|
53
53
|
```lua
|
|
54
|
-
local cv = require("cv")
|
|
55
|
-
local file = require("file")
|
|
56
54
|
|
|
57
55
|
local src = cv.capture()
|
|
58
56
|
local gray = cv.cvtColor(src, { code = cv.COLOR_BGR2GRAY })
|
|
@@ -97,7 +95,6 @@ function capture(x, y, ex, ey) end
|
|
|
97
95
|
**示例:**
|
|
98
96
|
|
|
99
97
|
```lua
|
|
100
|
-
local cv = require("cv")
|
|
101
98
|
local full = cv.capture()
|
|
102
99
|
local roi = cv.capture(100, 100, 300, 300)
|
|
103
100
|
cv.release(full)
|
|
@@ -142,13 +139,10 @@ function imread(path) end
|
|
|
142
139
|
**示例:**
|
|
143
140
|
|
|
144
141
|
```lua
|
|
145
|
-
local cv = require("cv")
|
|
146
|
-
local file = require("file")
|
|
147
|
-
local image = require("image")
|
|
148
142
|
local a = cv.imread("template.png")
|
|
149
143
|
local dir = file.getInternalDir("documents")
|
|
150
144
|
local b = cv.imread(dir .. "/shot.jpg")
|
|
151
|
-
local imageId = image.
|
|
145
|
+
local imageId = image.captureScreen()
|
|
152
146
|
local c = cv.imread(imageId)
|
|
153
147
|
image.release(imageId)
|
|
154
148
|
cv.release(a)
|
|
@@ -177,7 +171,6 @@ function imdecode(data) end
|
|
|
177
171
|
**示例:**
|
|
178
172
|
|
|
179
173
|
```lua
|
|
180
|
-
local cv = require("cv")
|
|
181
174
|
local m = cv.imread("template.png")
|
|
182
175
|
local b64 = cv.imencode(".png", m)
|
|
183
176
|
local again = cv.imdecode(b64)
|
|
@@ -206,8 +199,6 @@ function imwrite(path, mat) end
|
|
|
206
199
|
**示例:**
|
|
207
200
|
|
|
208
201
|
```lua
|
|
209
|
-
local cv = require("cv")
|
|
210
|
-
local file = require("file")
|
|
211
202
|
local src = cv.capture()
|
|
212
203
|
cv.imwrite(file.getInternalDir("documents") .. "/out.png", src)
|
|
213
204
|
cv.release(src)
|
|
@@ -236,7 +227,6 @@ function imencode(ext, mat, quality) end
|
|
|
236
227
|
**示例:**
|
|
237
228
|
|
|
238
229
|
```lua
|
|
239
|
-
local cv = require("cv")
|
|
240
230
|
local b64 = cv.imencode(".jpg", mat, { quality = 85 })
|
|
241
231
|
```
|
|
242
232
|
|
|
@@ -260,8 +250,7 @@ function fromImageId(imageId) end
|
|
|
260
250
|
**示例:**
|
|
261
251
|
|
|
262
252
|
```lua
|
|
263
|
-
local
|
|
264
|
-
local imageId = image.captureFullScreen()
|
|
253
|
+
local imageId = image.captureScreen()
|
|
265
254
|
local mat = cv.fromImageId(imageId)
|
|
266
255
|
image.release(imageId)
|
|
267
256
|
local outId = cv.toImageId(mat)
|
|
@@ -288,7 +277,6 @@ function Mat(options) end
|
|
|
288
277
|
**示例:**
|
|
289
278
|
|
|
290
279
|
```lua
|
|
291
|
-
local cv = require("cv")
|
|
292
280
|
local z = cv.zeros({ rows = 100, cols = 100, type = cv.CV_8UC3 })
|
|
293
281
|
local filled = cv.Mat({ rows = 10, cols = 10, type = cv.CV_8UC1, scalar = [255] })
|
|
294
282
|
cv.release(z)
|
|
@@ -313,7 +301,6 @@ function clone(mat) end
|
|
|
313
301
|
**示例:**
|
|
314
302
|
|
|
315
303
|
```lua
|
|
316
|
-
local cv = require("cv")
|
|
317
304
|
local a = cv.capture()
|
|
318
305
|
local b = cv.clone(a)
|
|
319
306
|
cv.release(a)
|
|
@@ -360,7 +347,6 @@ function threshold(mat, options) end
|
|
|
360
347
|
**示例:**
|
|
361
348
|
|
|
362
349
|
```lua
|
|
363
|
-
local cv = require("cv")
|
|
364
350
|
local bin = cv.threshold(gray, { thresh = 127, maxval = 255, type = cv.THRESH_BINARY })
|
|
365
351
|
local otsu = cv.threshold(gray, { type = cv.THRESH_BINARY | cv.THRESH_OTSU })
|
|
366
352
|
```
|
|
@@ -387,7 +373,6 @@ function adaptiveThreshold(mat, options) end
|
|
|
387
373
|
**示例:**
|
|
388
374
|
|
|
389
375
|
```lua
|
|
390
|
-
local cv = require("cv")
|
|
391
376
|
local bin = cv.adaptiveThreshold(gray, {
|
|
392
377
|
maxValue = 255,
|
|
393
378
|
adaptiveMethod = cv.ADAPTIVE_THRESH_GAUSSIAN_C,
|
|
@@ -411,7 +396,6 @@ function inRange(mat, options) end
|
|
|
411
396
|
**示例:**
|
|
412
397
|
|
|
413
398
|
```lua
|
|
414
|
-
local cv = require("cv")
|
|
415
399
|
local hsv = cv.cvtColor(src, { code = cv.COLOR_BGR2HSV })
|
|
416
400
|
local mask = cv.inRange(hsv, { lower = [0, 80, 80], upper = [20, 255, 255] })
|
|
417
401
|
```
|
|
@@ -440,7 +424,6 @@ function GaussianBlur(mat, options) end
|
|
|
440
424
|
**示例:**
|
|
441
425
|
|
|
442
426
|
```lua
|
|
443
|
-
local cv = require("cv")
|
|
444
427
|
local g = cv.GaussianBlur(src, { ksize = 5, sigmaX = 1.5 })
|
|
445
428
|
local m = cv.medianBlur(src, { ksize = 5 })
|
|
446
429
|
local b = cv.bilateralFilter(src, { d = 9, sigmaColor = 75, sigmaSpace = 75 })
|
|
@@ -467,7 +450,6 @@ function Canny(mat, options) end
|
|
|
467
450
|
**示例:**
|
|
468
451
|
|
|
469
452
|
```lua
|
|
470
|
-
local cv = require("cv")
|
|
471
453
|
local edges = cv.Canny(gray, { threshold1 = 50, threshold2 = 150 })
|
|
472
454
|
local sx = cv.Sobel(gray, { dx = 1, dy = 0, ksize = 3 })
|
|
473
455
|
local histEq = cv.equalizeHist(gray)
|
|
@@ -487,7 +469,6 @@ function resize(mat, options) end
|
|
|
487
469
|
**示例:**
|
|
488
470
|
|
|
489
471
|
```lua
|
|
490
|
-
local cv = require("cv")
|
|
491
472
|
local small = cv.resize(src, { width = 360, height = 640 })
|
|
492
473
|
local half = cv.resize(src, { fx = 0.5, fy = 0.5, interpolation = cv.INTER_AREA })
|
|
493
474
|
```
|
|
@@ -501,14 +482,13 @@ local half = cv.resize(src, { fx = 0.5, fy = 0.5, interpolation = cv.INTER_AREA
|
|
|
501
482
|
function crop(mat, options) end
|
|
502
483
|
```
|
|
503
484
|
|
|
504
|
-
参数与 `cv.capture` / `image.
|
|
485
|
+
参数与 `cv.capture` / `image.captureScreen` 一致,使用左上角与右下角。
|
|
505
486
|
|
|
506
487
|
参数为 `{ x, y, ex, ey }`。
|
|
507
488
|
|
|
508
489
|
**示例:**
|
|
509
490
|
|
|
510
491
|
```lua
|
|
511
|
-
local cv = require("cv")
|
|
512
492
|
local roi = cv.crop(src, { x = 10, y = 10, ex = 110, ey = 110 })
|
|
513
493
|
```
|
|
514
494
|
|
|
@@ -532,7 +512,6 @@ function getRotationMatrix2D(options) end
|
|
|
532
512
|
**示例:**
|
|
533
513
|
|
|
534
514
|
```lua
|
|
535
|
-
local cv = require("cv")
|
|
536
515
|
local M = cv.getRotationMatrix2D({ center = { x = 100, y = 100 }, angle = 30, scale = 1 })
|
|
537
516
|
local out = cv.warpAffine(src, { M, width = 200, height = 200 })
|
|
538
517
|
cv.release(M)
|
|
@@ -555,7 +534,6 @@ function rectangle(mat, options) end
|
|
|
555
534
|
**示例:**
|
|
556
535
|
|
|
557
536
|
```lua
|
|
558
|
-
local cv = require("cv")
|
|
559
537
|
cv.rectangle(src, {
|
|
560
538
|
pt1 = { x = 10, y = 10 },
|
|
561
539
|
pt2 = { x = 100, y = 80 },
|
|
@@ -588,7 +566,6 @@ function fillPoly(mat, options) end
|
|
|
588
566
|
**示例:**
|
|
589
567
|
|
|
590
568
|
```lua
|
|
591
|
-
local cv = require("cv")
|
|
592
569
|
cv.polylines(src, {
|
|
593
570
|
pts = { { x = 0, y = 0 }, { x = 100, y = 0 }, { x = 100, y = 80 }, { x = 0, y = 80 } },
|
|
594
571
|
isClosed = true,
|
|
@@ -622,7 +599,6 @@ function matchTemplate(image, templ, methodOrOptions) end
|
|
|
622
599
|
**示例:**
|
|
623
600
|
|
|
624
601
|
```lua
|
|
625
|
-
local cv = require("cv")
|
|
626
602
|
local loc = cv.matchTemplateLoc(src, templ, { method = cv.TM_CCOEFF_NORMED })
|
|
627
603
|
print(string.format("best=(%s,%s) max=%s", loc.x, loc.y, loc.maxVal))
|
|
628
604
|
cv.rectangle(src, {
|
|
@@ -655,7 +631,6 @@ function findContours(mat, options) end
|
|
|
655
631
|
**示例:**
|
|
656
632
|
|
|
657
633
|
```lua
|
|
658
|
-
local cv = require("cv")
|
|
659
634
|
local ret = cv.findContours(bin, { mode = cv.RETR_TREE, method = cv.CHAIN_APPROX_SIMPLE })
|
|
660
635
|
print("count=" .. tostring(#ret.contours))
|
|
661
636
|
```
|
|
@@ -671,7 +646,6 @@ function boundingRect(matOrPoints) end
|
|
|
671
646
|
**示例:**
|
|
672
647
|
|
|
673
648
|
```lua
|
|
674
|
-
local cv = require("cv")
|
|
675
649
|
for _, c in ipairs(contours) do
|
|
676
650
|
local area = cv.contourArea(c)
|
|
677
651
|
if (area < 100) continue
|
package/docs/apilua/paddleocr.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# PaddleOCR 模块 (PaddleOCR)
|
|
2
2
|
|
|
3
|
+
模块表是内置全局 `paddleocr`,直接调用即可。不要 `require` 宿主模块。
|
|
4
|
+
|
|
3
5
|
PaddleOCR 模块基于百度飞桨 PaddleOCR 技术,提供强大的光学字符识别(OCR)功能,支持中英文文本识别,可用于屏幕截图、图片文件等多种输入源的文字识别。
|
|
4
6
|
|
|
5
7
|
## 功能概览
|
|
6
8
|
|
|
7
|
-
- **自动加载**:
|
|
8
|
-
-
|
|
9
|
+
- **自动加载**: 识别和查找方法会自动加载所需模型,无需先手动加载
|
|
10
|
+
- **模型选择**: 同一时间只保留一个 active 模型,默认 `ppocr-v6-small`,可通过模型 ID 手动加载 `ppocr-v6-tiny` 或 `ppocr-v5`
|
|
11
|
+
- **长边设置**: 可单独调整检测阶段最大边长,不需要重新加载已加载模型
|
|
9
12
|
- **多源识别**: 支持屏幕截图、图片文件、URL 等多种输入源
|
|
10
13
|
- **区域识别**: 支持指定区域的精确文字识别
|
|
11
14
|
- **结构化结果**: 提供详细的文本位置、置信度和方向信息
|
|
@@ -49,40 +52,6 @@ PaddleOCR 模块基于百度飞桨 PaddleOCR 技术,提供强大的光学字
|
|
|
49
52
|
|
|
50
53
|
### 模型管理
|
|
51
54
|
|
|
52
|
-
#### loadV5 - 手动加载 PP-OCRv5 模型。
|
|
53
|
-
|
|
54
|
-
识别方法默认自动加载模型。只有需要切换到 PP-OCRv5 或指定 GPU 参数时才调用 `loadV5`。PaddleOCR 同一时间只保留一个 active 模型,`loadV5` 加载成功后会替换已加载模型。
|
|
55
|
-
|
|
56
|
-
```lua
|
|
57
|
-
---@param maxSideLen number?
|
|
58
|
-
---@param useGpu boolean?
|
|
59
|
-
---@return boolean
|
|
60
|
-
function loadV5(maxSideLen, useGpu) end
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**参数:**
|
|
64
|
-
|
|
65
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
66
|
-
| ------------ | ------- | -------- | ------ | ---------------------------- |
|
|
67
|
-
| `maxSideLen` | number | 否 | 640 | 检测阶段输入最大边长 |
|
|
68
|
-
| `useGpu` | boolean | 否 | false | 是否启用 GPU 加速 |
|
|
69
|
-
|
|
70
|
-
**返回值:**
|
|
71
|
-
|
|
72
|
-
| 类型 | 描述 |
|
|
73
|
-
| ------- | ----------------------------------------------------------- |
|
|
74
|
-
| boolean | 加载成功或模型已加载返回 `true`,失败返回 `false` |
|
|
75
|
-
|
|
76
|
-
**示例:**
|
|
77
|
-
|
|
78
|
-
```lua
|
|
79
|
-
local paddleocr = require("paddleocr")
|
|
80
|
-
|
|
81
|
-
-- 手动加载 PP-OCRv5 模型
|
|
82
|
-
local loaded = paddleocr.loadV5(640, false)
|
|
83
|
-
print("PP-OCRv5 加载结果: " .. tostring(loaded))
|
|
84
|
-
```
|
|
85
|
-
|
|
86
55
|
#### loadModel - 按模型 ID 手动加载内置 PaddleOCR 模型。
|
|
87
56
|
|
|
88
57
|
识别和查找方法默认自动加载 `ppocr-v6-small`。只有需要切换模型或指定 GPU 参数时才调用 `loadModel`。同一时间只保留一个 active 模型;检测长边请使用 `setMaxSideLen`。
|
|
@@ -110,7 +79,6 @@ function loadModel(modelId, useGpu) end
|
|
|
110
79
|
**示例:**
|
|
111
80
|
|
|
112
81
|
```lua
|
|
113
|
-
local paddleocr = require("paddleocr")
|
|
114
82
|
paddleocr.loadModel("ppocr-v6-tiny", false)
|
|
115
83
|
local loaded = paddleocr.loadModel("ppocr-v6-small", false)
|
|
116
84
|
print("PP-OCRv6 small 加载结果: " .. tostring(loaded))
|
|
@@ -141,56 +109,11 @@ function setMaxSideLen(maxSideLen) end
|
|
|
141
109
|
**示例:**
|
|
142
110
|
|
|
143
111
|
```lua
|
|
144
|
-
local paddleocr = require("paddleocr")
|
|
145
112
|
paddleocr.setMaxSideLen(960)
|
|
146
113
|
```
|
|
147
114
|
|
|
148
115
|
### 文字识别
|
|
149
116
|
|
|
150
|
-
#### recognize - 执行 OCR 识别。
|
|
151
|
-
|
|
152
|
-
传入裁剪区域时,返回坐标相对于裁剪区域。全屏识别时 `x/y/ex/ey` 传 `0`。
|
|
153
|
-
|
|
154
|
-
```lua
|
|
155
|
-
---@param input string
|
|
156
|
-
---@param x number?
|
|
157
|
-
---@param y number?
|
|
158
|
-
---@param ex number?
|
|
159
|
-
---@param ey number?
|
|
160
|
-
---@param confidenceThreshold number?
|
|
161
|
-
---@return OCRResult[]
|
|
162
|
-
function recognize(input, x, y, ex, ey, confidenceThreshold) end
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
**参数:**
|
|
166
|
-
|
|
167
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
168
|
-
| --------------------- | ------ | -------- | ------ | ----------------------------------------------------------- |
|
|
169
|
-
| `input` | string | 是 | | 输入源,支持 imageId、URL 字符串、文件路径或 `"screen"` |
|
|
170
|
-
| `x` | number | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
|
|
171
|
-
| `y` | number | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
|
|
172
|
-
| `ex` | number | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
|
|
173
|
-
| `ey` | number | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
|
|
174
|
-
| `confidenceThreshold` | number | 否 | 0.6 | 置信度阈值,低于该值的识别结果会被过滤 |
|
|
175
|
-
|
|
176
|
-
**返回值:**
|
|
177
|
-
|
|
178
|
-
| 类型 | 描述 |
|
|
179
|
-
| ------------- | ---------------------------------- |
|
|
180
|
-
| `OCRResult[]` | 识别结果数组,坐标相对于裁剪区域 |
|
|
181
|
-
|
|
182
|
-
**示例:**
|
|
183
|
-
|
|
184
|
-
```lua
|
|
185
|
-
local paddleocr = require("paddleocr")
|
|
186
|
-
local action = require("action")
|
|
187
|
-
|
|
188
|
-
local results = paddleocr.recognize("screen", 100, 100, 500, 300)
|
|
189
|
-
if #results > 0 then
|
|
190
|
-
action.click(results[1].centerX, results[1].centerY)
|
|
191
|
-
end
|
|
192
|
-
```
|
|
193
|
-
|
|
194
117
|
#### recognizeAbs - 执行 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标。
|
|
195
118
|
|
|
196
119
|
传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。
|
|
@@ -226,17 +149,15 @@ function recognizeAbs(input, x, y, ex, ey, confidenceThreshold) end
|
|
|
226
149
|
**示例:**
|
|
227
150
|
|
|
228
151
|
```lua
|
|
229
|
-
local paddleocr = require("paddleocr")
|
|
230
|
-
local action = require("action")
|
|
231
152
|
local absResults = paddleocr.recognizeAbs("screen", 100, 100, 500, 300)
|
|
232
153
|
if #absResults > 0 then
|
|
233
154
|
action.click(absResults[1].centerX, absResults[1].centerY)
|
|
234
155
|
end
|
|
235
156
|
```
|
|
236
157
|
|
|
237
|
-
####
|
|
158
|
+
#### findTextAbs - 查找目标文本,并将结果坐标映射为原图/全屏绝对坐标。
|
|
238
159
|
|
|
239
|
-
|
|
160
|
+
传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。`targets` 也可以是逗号分隔字符串。
|
|
240
161
|
|
|
241
162
|
```lua
|
|
242
163
|
---@param input string
|
|
@@ -248,57 +169,31 @@ end
|
|
|
248
169
|
---@param confidenceThreshold number?
|
|
249
170
|
---@param exactMatch boolean?
|
|
250
171
|
---@return OCRResult[]
|
|
251
|
-
function
|
|
172
|
+
function findTextAbs(input, targets, x, y, ex, ey, confidenceThreshold, exactMatch) end
|
|
252
173
|
```
|
|
253
174
|
|
|
254
175
|
**参数:**
|
|
255
176
|
|
|
256
|
-
| 参数名 | 类型
|
|
257
|
-
| --------------------- |
|
|
258
|
-
| `input` | string
|
|
177
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
178
|
+
| --------------------- | ------------------ | -------- | ------ | ------------------------------------------------------------------------ |
|
|
179
|
+
| `input` | string | 是 | | 输入源,支持 imageId、URL 字符串、文件路径或 `"screen"` |
|
|
259
180
|
| `targets` | string[] \| string | 是 | | 目标文本数组或逗号分隔字符串 |
|
|
260
|
-
| `x` | number
|
|
261
|
-
| `y` | number
|
|
262
|
-
| `ex` | number
|
|
263
|
-
| `ey` | number
|
|
264
|
-
| `confidenceThreshold` | number
|
|
265
|
-
| `exactMatch` | boolean
|
|
181
|
+
| `x` | number | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
|
|
182
|
+
| `y` | number | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
|
|
183
|
+
| `ex` | number | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
|
|
184
|
+
| `ey` | number | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
|
|
185
|
+
| `confidenceThreshold` | number | 否 | 0.6 | 置信度阈值,低于该值的识别结果会被过滤 |
|
|
186
|
+
| `exactMatch` | boolean | 否 | false | 是否完整匹配;`false` 表示包含匹配,`true` 要求整条 OCR 文本等于目标文本 |
|
|
266
187
|
|
|
267
188
|
**返回值:**
|
|
268
189
|
|
|
269
|
-
| 类型 | 描述
|
|
270
|
-
| ------------- |
|
|
271
|
-
| `OCRResult[]` |
|
|
272
|
-
|
|
273
|
-
**示例:**
|
|
274
|
-
|
|
275
|
-
```lua
|
|
276
|
-
local paddleocr = require("paddleocr")
|
|
277
|
-
local hits = paddleocr.findText("screen", { "确定" }, 100, 100, 500, 400, 0.6, false)
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
#### findTextAbs - 查找目标文本,并将结果坐标映射为原图/全屏绝对坐标。
|
|
281
|
-
|
|
282
|
-
```lua
|
|
283
|
-
---@param input string
|
|
284
|
-
---@param targets string[]|string
|
|
285
|
-
---@param x number?
|
|
286
|
-
---@param y number?
|
|
287
|
-
---@param ex number?
|
|
288
|
-
---@param ey number?
|
|
289
|
-
---@param confidenceThreshold number?
|
|
290
|
-
---@param exactMatch boolean?
|
|
291
|
-
---@return OCRResult[]
|
|
292
|
-
function findTextAbs(input, targets, x, y, ex, ey, confidenceThreshold, exactMatch) end
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
**参数:** 与 `findText` 相同;返回坐标为原图或全屏绝对坐标。
|
|
190
|
+
| 类型 | 描述 |
|
|
191
|
+
| ------------- | ---------------------------------------------- |
|
|
192
|
+
| `OCRResult[]` | 匹配到的子串结果数组,坐标为原图或全屏绝对坐标 |
|
|
296
193
|
|
|
297
194
|
**示例:**
|
|
298
195
|
|
|
299
196
|
```lua
|
|
300
|
-
local paddleocr = require("paddleocr")
|
|
301
|
-
local action = require("action")
|
|
302
197
|
local absHits = paddleocr.findTextAbs("screen", { "确定" }, 100, 100, 500, 400, 0.6, false)
|
|
303
198
|
if #absHits > 0 then
|
|
304
199
|
action.click(absHits[1].centerX, absHits[1].centerY)
|
|
@@ -316,7 +211,6 @@ function free() end
|
|
|
316
211
|
**示例:**
|
|
317
212
|
|
|
318
213
|
```lua
|
|
319
|
-
local paddleocr = require("paddleocr")
|
|
320
214
|
|
|
321
215
|
-- 使用完毕后释放资源
|
|
322
216
|
paddleocr.free()
|
package/docs/apilua/pip.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# 悬浮窗模块 (PIP)
|
|
2
2
|
|
|
3
|
+
模块表是内置全局 `pip`,直接调用即可。不要 `require` 宿主模块。
|
|
4
|
+
|
|
3
5
|
悬浮窗模块提供 iOS 画中画(Picture in Picture)悬浮窗能力,可用于显示脚本日志、保活提示或脚本自定义文本。
|
|
4
6
|
|
|
5
7
|
## 功能特性
|
|
@@ -31,7 +33,6 @@ function isPipActive() end
|
|
|
31
33
|
**示例:**
|
|
32
34
|
|
|
33
35
|
```lua
|
|
34
|
-
local pip = require("pip")
|
|
35
36
|
local isActive = pip.isPipActive()
|
|
36
37
|
if isActive then
|
|
37
38
|
print("悬浮窗当前已打开")
|
|
@@ -56,7 +57,6 @@ function switchToLogMode() end
|
|
|
56
57
|
**示例:**
|
|
57
58
|
|
|
58
59
|
```lua
|
|
59
|
-
local pip = require("pip")
|
|
60
60
|
takeMeToFront()
|
|
61
61
|
local success = pip.switchToLogMode()
|
|
62
62
|
pip.setLogFontSize(10)
|
|
@@ -80,7 +80,6 @@ function switchToKeepAliveMode() end
|
|
|
80
80
|
**示例:**
|
|
81
81
|
|
|
82
82
|
```lua
|
|
83
|
-
local pip = require("pip")
|
|
84
83
|
takeMeToFront()
|
|
85
84
|
local success = pip.switchToKeepAliveMode()
|
|
86
85
|
```
|
|
@@ -103,7 +102,6 @@ function switchToCustomMode() end
|
|
|
103
102
|
**示例:**
|
|
104
103
|
|
|
105
104
|
```lua
|
|
106
|
-
local pip = require("pip")
|
|
107
105
|
takeMeToFront()
|
|
108
106
|
pip.switchToCustomMode()
|
|
109
107
|
pip.setCustomText("运行中\n进度 1/3")
|
|
@@ -129,7 +127,6 @@ function closeWindow() end
|
|
|
129
127
|
**示例:**
|
|
130
128
|
|
|
131
129
|
```lua
|
|
132
|
-
local pip = require("pip")
|
|
133
130
|
local success = pip.closeWindow()
|
|
134
131
|
```
|
|
135
132
|
|
|
@@ -160,7 +157,6 @@ function setContentSize(width, height) end
|
|
|
160
157
|
**示例:**
|
|
161
158
|
|
|
162
159
|
```lua
|
|
163
|
-
local pip = require("pip")
|
|
164
160
|
pip.switchToLogMode()
|
|
165
161
|
pip.setContentSize(280, 120)
|
|
166
162
|
|
|
@@ -193,7 +189,6 @@ function setLogFontSize(fontSize) end
|
|
|
193
189
|
**示例:**
|
|
194
190
|
|
|
195
191
|
```lua
|
|
196
|
-
local pip = require("pip")
|
|
197
192
|
pip.setLogFontSize(10)
|
|
198
193
|
pip.switchToLogMode()
|
|
199
194
|
```
|
|
@@ -223,7 +218,6 @@ function setCustomText(text) end
|
|
|
223
218
|
**示例:**
|
|
224
219
|
|
|
225
220
|
```lua
|
|
226
|
-
local pip = require("pip")
|
|
227
221
|
pip.setCustomText("运行中\n进度 1/3")
|
|
228
222
|
pip.switchToCustomMode()
|
|
229
223
|
```
|
|
@@ -253,7 +247,6 @@ function setCustomTextColor(color) end
|
|
|
253
247
|
**示例:**
|
|
254
248
|
|
|
255
249
|
```lua
|
|
256
|
-
local pip = require("pip")
|
|
257
250
|
pip.setCustomTextColor("#34c759")
|
|
258
251
|
pip.switchToCustomMode()
|
|
259
252
|
```
|
|
@@ -283,7 +276,6 @@ function setCustomTextSize(fontSize) end
|
|
|
283
276
|
**示例:**
|
|
284
277
|
|
|
285
278
|
```lua
|
|
286
|
-
local pip = require("pip")
|
|
287
279
|
pip.setCustomTextSize(18)
|
|
288
280
|
pip.switchToCustomMode()
|
|
289
281
|
```
|
|
@@ -313,7 +305,6 @@ function setCustomBackgroundColor(color) end
|
|
|
313
305
|
**示例:**
|
|
314
306
|
|
|
315
307
|
```lua
|
|
316
|
-
local pip = require("pip")
|
|
317
308
|
pip.setCustomBackgroundColor("#111111")
|
|
318
309
|
pip.switchToCustomMode()
|
|
319
310
|
```
|
|
@@ -321,7 +312,6 @@ pip.switchToCustomMode()
|
|
|
321
312
|
## 完整使用示例
|
|
322
313
|
|
|
323
314
|
```lua
|
|
324
|
-
local pip = require("pip")
|
|
325
315
|
takeMeToFront()
|
|
326
316
|
|
|
327
317
|
pip.switchToLogMode()
|