@aspiresys/visor 1.0.0 → 1.0.2
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/index.d.ts +0 -3
- package/dist/index.js +3 -6
- package/dist/matcher.d.ts +1 -1
- package/dist/matcher.js +8 -2
- package/dist/screen.js +7 -1
- package/package.json +1 -4
- package/readme.md +1 -19
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -162,7 +162,7 @@ class Visor {
|
|
|
162
162
|
*/
|
|
163
163
|
async find(image, confidence = 0.8) {
|
|
164
164
|
const screen = await (0, screen_1.captureScreen)();
|
|
165
|
-
const template = (0, matcher_1.loadTemplate)((0, path_1.resolveImagePath)(image));
|
|
165
|
+
const template = await (0, matcher_1.loadTemplate)((0, path_1.resolveImagePath)(image));
|
|
166
166
|
try {
|
|
167
167
|
return (0, matcher_1.matchTemplate)(screen, template, confidence);
|
|
168
168
|
}
|
|
@@ -217,7 +217,7 @@ class Visor {
|
|
|
217
217
|
*/
|
|
218
218
|
async findAll(image, confidence = 0.8) {
|
|
219
219
|
const screen = await (0, screen_1.captureScreen)();
|
|
220
|
-
const template = (0, matcher_1.loadTemplate)((0, path_1.resolveImagePath)(image));
|
|
220
|
+
const template = await (0, matcher_1.loadTemplate)((0, path_1.resolveImagePath)(image));
|
|
221
221
|
try {
|
|
222
222
|
return (0, matcher_1.findAllMatches)(screen, template, confidence);
|
|
223
223
|
}
|
|
@@ -914,7 +914,7 @@ CONF:${m.confidence.toFixed(3)}
|
|
|
914
914
|
const screen = await (0, screen_1.captureScreen)();
|
|
915
915
|
try {
|
|
916
916
|
for (const image of images) {
|
|
917
|
-
const template = (0, matcher_1.loadTemplate)((0, path_1.resolveImagePath)(image));
|
|
917
|
+
const template = await (0, matcher_1.loadTemplate)((0, path_1.resolveImagePath)(image));
|
|
918
918
|
try {
|
|
919
919
|
const region = (0, matcher_1.matchTemplate)(screen, template, confidence);
|
|
920
920
|
if (region) {
|
|
@@ -1049,9 +1049,6 @@ CONF:${m.confidence.toFixed(3)}
|
|
|
1049
1049
|
* Recommended range:
|
|
1050
1050
|
* 1000ms to 30000ms
|
|
1051
1051
|
*
|
|
1052
|
-
* @returns Object containing matched image
|
|
1053
|
-
* and region.
|
|
1054
|
-
*
|
|
1055
1052
|
* @throws Error if timeout occurs.
|
|
1056
1053
|
*
|
|
1057
1054
|
* @example
|
package/dist/matcher.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Region } from "./types";
|
|
2
|
-
export declare function loadTemplate(path: string): any
|
|
2
|
+
export declare function loadTemplate(path: string): Promise<any>;
|
|
3
3
|
export declare function matchTemplate(screen: any, template: any, confidence?: number): Region | null;
|
|
4
4
|
export declare function findAllMatches(screen: any, template: any, confidence?: number): Region[];
|
package/dist/matcher.js
CHANGED
|
@@ -9,9 +9,15 @@ exports.findAllMatches = findAllMatches;
|
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const pngjs_1 = require("pngjs");
|
|
11
11
|
const cv = require("@techstark/opencv-js");
|
|
12
|
-
|
|
12
|
+
const sharp_1 = __importDefault(require("sharp"));
|
|
13
|
+
async function loadTemplate(path) {
|
|
13
14
|
const buffer = fs_1.default.readFileSync(path);
|
|
14
|
-
const
|
|
15
|
+
const processed = await (0, sharp_1.default)(buffer)
|
|
16
|
+
.normalize()
|
|
17
|
+
.sharpen()
|
|
18
|
+
.png()
|
|
19
|
+
.toBuffer();
|
|
20
|
+
const png = pngjs_1.PNG.sync.read(processed);
|
|
15
21
|
return cv.matFromImageData({
|
|
16
22
|
data: png.data,
|
|
17
23
|
width: png.width,
|
package/dist/screen.js
CHANGED
|
@@ -8,12 +8,18 @@ exports.saveScreenshot = saveScreenshot;
|
|
|
8
8
|
const screenshot_desktop_1 = __importDefault(require("screenshot-desktop"));
|
|
9
9
|
const pngjs_1 = require("pngjs");
|
|
10
10
|
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const sharp_1 = __importDefault(require("sharp"));
|
|
11
12
|
const cv = require("@techstark/opencv-js");
|
|
12
13
|
async function captureScreen() {
|
|
13
14
|
const buffer = await (0, screenshot_desktop_1.default)({
|
|
14
15
|
format: "png"
|
|
15
16
|
});
|
|
16
|
-
const
|
|
17
|
+
const processed = await (0, sharp_1.default)(buffer)
|
|
18
|
+
.normalize()
|
|
19
|
+
.sharpen()
|
|
20
|
+
.png()
|
|
21
|
+
.toBuffer();
|
|
22
|
+
const png = pngjs_1.PNG.sync.read(processed);
|
|
17
23
|
return cv.matFromImageData({
|
|
18
24
|
data: png.data,
|
|
19
25
|
width: png.width,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aspiresys/visor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"typescript": "^5.9.0"
|
|
23
23
|
},
|
|
24
24
|
"description": "Desktop visual automation framework using OpenCV, OCR, and desktop interaction APIs.",
|
|
25
|
-
|
|
26
25
|
"keywords": [
|
|
27
26
|
"automation",
|
|
28
27
|
"desktop-automation",
|
|
@@ -32,9 +31,7 @@
|
|
|
32
31
|
"testing",
|
|
33
32
|
"computer-vision"
|
|
34
33
|
],
|
|
35
|
-
|
|
36
34
|
"license": "MIT",
|
|
37
|
-
|
|
38
35
|
"files": [
|
|
39
36
|
"dist"
|
|
40
37
|
]
|
package/readme.md
CHANGED
|
@@ -36,16 +36,7 @@ Visor is designed for automating desktop workflows using visual interactions ins
|
|
|
36
36
|
## Install from npm
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
npm install visor
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## Local Development
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
npm install
|
|
48
|
-
npm run build
|
|
39
|
+
npm install @aspiresys/visor
|
|
49
40
|
```
|
|
50
41
|
|
|
51
42
|
---
|
|
@@ -449,12 +440,6 @@ OCR speed depends on:
|
|
|
449
440
|
|
|
450
441
|
---
|
|
451
442
|
|
|
452
|
-
## Electron Applications
|
|
453
|
-
|
|
454
|
-
Electron-based applications may require additional startup stabilization time.
|
|
455
|
-
|
|
456
|
-
---
|
|
457
|
-
|
|
458
443
|
# Debug Logging
|
|
459
444
|
|
|
460
445
|
Enable debug logs:
|
|
@@ -543,9 +528,6 @@ Possible causes:
|
|
|
543
528
|
|
|
544
529
|
Planned features:
|
|
545
530
|
|
|
546
|
-
- Linux support
|
|
547
|
-
- Mac support
|
|
548
|
-
- Region caching
|
|
549
531
|
- Parallel image matching
|
|
550
532
|
- Advanced OCR tuning
|
|
551
533
|
- Electron recorder
|