@solazah/solazah-runtime 0.2.29 → 0.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/types/SystemScreen.d.ts +16 -7
package/package.json
CHANGED
package/types/SystemScreen.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { default as IpcRenderer } from './IpcRenderer';
|
|
2
2
|
import { Point } from '@computer-use/nut-js';
|
|
3
|
+
/** 原始位图:BGRA、自顶向下、每像素 4 字节,与截图流 raw 帧同一格式。手里已经是像素时直接给它,省掉编码与解码。 */
|
|
4
|
+
export interface RawImage {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
data: Uint8Array;
|
|
8
|
+
}
|
|
9
|
+
/** 一张图:Data URL、本机绝对路径,或原始位图。 */
|
|
10
|
+
export type ImageSource = string | RawImage;
|
|
3
11
|
/** 屏幕原生坐标系里的矩形。 */
|
|
4
12
|
export interface ScreenRect {
|
|
5
13
|
x: number;
|
|
@@ -364,12 +372,12 @@ export default class SystemScreen {
|
|
|
364
372
|
/**
|
|
365
373
|
* 在一张给定图片(而不是当前屏幕)里做模板匹配,给「用采集时的截图验证模板唯一性」用。
|
|
366
374
|
*
|
|
367
|
-
* @param haystack
|
|
368
|
-
* @param needle
|
|
375
|
+
* @param haystack 被搜索的图片:Data URL、本机绝对路径或原始位图。
|
|
376
|
+
* @param needle 模板图片:Data URL、本机绝对路径或原始位图。
|
|
369
377
|
* @param options `{maxResults?, scale?, minScore?, region?}`。
|
|
370
378
|
* @returns `[{x, y, width, height, score, scale}]`,按分数降序,第一个是全图最佳。
|
|
371
379
|
*/
|
|
372
|
-
matchTemplate: (haystack:
|
|
380
|
+
matchTemplate: (haystack: ImageSource, needle: ImageSource, options?: {
|
|
373
381
|
maxResults?: number;
|
|
374
382
|
scale?: number;
|
|
375
383
|
minScore?: number;
|
|
@@ -382,15 +390,16 @@ export default class SystemScreen {
|
|
|
382
390
|
* 对一帧给定图片做一批分析:若干模板各自匹配、若干区域各自 OCR,图片只解码一次,同一区域只 OCR 一次。
|
|
383
391
|
* 每一拍截一帧、拿这一帧判断全部条件的循环靠它把 IPC 压到每拍一次。
|
|
384
392
|
*
|
|
385
|
-
* @param frame
|
|
393
|
+
* @param frame 被分析的图片(通常是一帧截图)。
|
|
386
394
|
* @param request `{templates?: [{id, image, region?, scale?, minScore?, maxResults?}], texts?: [{id, region?, detRatio?, zoom?}]}`,region 相对图片左上角。
|
|
387
|
-
* frame 与 templates[].image 都可以给 Data URL
|
|
395
|
+
* frame 与 templates[].image 都可以给 Data URL、本机绝对路径或原始位图;反复分析同一批图时给路径,同一张只解码一次;
|
|
396
|
+
* 手里已经是像素的(截图流 raw 帧)给原始位图。
|
|
388
397
|
* @returns `{templates: {id: [{x, y, width, height, score, scale}]}, texts: {id: [{text, score, x, y, width, height}]}}`,坐标相对图片左上角。
|
|
389
398
|
*/
|
|
390
|
-
analyzeFrame: (frame:
|
|
399
|
+
analyzeFrame: (frame: ImageSource, request?: {
|
|
391
400
|
templates?: Array<{
|
|
392
401
|
id: string;
|
|
393
|
-
image:
|
|
402
|
+
image: ImageSource;
|
|
394
403
|
region?: ScreenRect;
|
|
395
404
|
scale?: number;
|
|
396
405
|
minScore?: number;
|