@aspiresys/visor 1.2.10 → 1.3.0

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.
@@ -30,6 +30,8 @@ captureBtn.addEventListener("click",
30
30
  const scale = image.width > maxWidth ? maxWidth / image.width : 1;
31
31
  canvas.width = image.width * scale;
32
32
  canvas.height = image.height * scale;
33
+ matchResult.textContent = " No Match Tested ";
34
+ ctx.imageSmoothingEnabled = false;
33
35
  ctx.drawImage(
34
36
  image,
35
37
  0,
@@ -88,24 +90,14 @@ canvas.addEventListener("mousemove",
88
90
  canvas.addEventListener("mouseup",
89
91
  () => {
90
92
  selecting = false;
91
- console.log(
92
- startX,
93
- startY,
94
- endX,
95
- endY
96
- );
93
+ console.log(startX, startY, endX, endY);
97
94
  }
98
95
  );
99
96
 
100
97
 
101
98
  saveBtn.addEventListener("click",
102
99
  async () => {
103
- if (
104
- startX === undefined ||
105
- startY === undefined ||
106
- endX === undefined ||
107
- endY === undefined
108
- ) {
100
+ if (startX === undefined || startY === undefined || endX === undefined || endY === undefined) {
109
101
  alert("Please select an area first.");
110
102
  return;
111
103
  }
@@ -119,58 +111,103 @@ saveBtn.addEventListener("click",
119
111
  return;
120
112
  }
121
113
  await window.visor.saveTemplate({
122
- x: Math.min(startX, endX),
123
- y: Math.min(startY, endY),
124
- width: Math.abs(endX - startX),
125
- height: Math.abs(endY - startY),
126
- outputPath: filePath
127
- });
114
+ x: Math.min(startX, endX),
115
+ y: Math.min(startY, endY),
116
+ width: Math.abs(endX - startX),
117
+ height: Math.abs(endY - startY),
118
+ outputPath: filePath
119
+ });
120
+ const fileName = filePath.split(/[\\/]/).pop();
128
121
  selectedTemplatePath = filePath;
129
- currentTemplate.textContent = filePath;
122
+ currentTemplate.textContent = fileName;
123
+ currentTemplate.title = filePath;
124
+ matchResult.textContent = "<b>No Match Tested</b>";
125
+ ctx.drawImage(
126
+ image,
127
+ 0,
128
+ 0,
129
+ canvas.width,
130
+ canvas.height
131
+ );
130
132
  templatePreview.src = filePath + "?t=" + Date.now();
131
133
  alert("Template Saved");
132
134
  }
133
135
  );
134
136
 
135
- testMatchBtn.addEventListener("click", async () => {
136
- if (!selectedTemplatePath) {
137
- alert("Please load or save a template first.");
138
- return;
139
- }
140
-
141
- const confidence = parseFloat(confidenceInput.value);
142
- if (isNaN(confidence) || confidence < 0 || confidence > 1) {
143
- alert("Confidence must be between 0 and 1");
144
- return;
145
- }
146
-
147
- const result = await window.visor.testMatch({
148
- templatePath: selectedTemplatePath,
149
- confidence: confidence
150
- });
151
- console.log(
152
- "Match Result:",
153
- result
137
+ testMatchBtn.addEventListener("click",
138
+ async () => {
139
+ if (!selectedTemplatePath) {
140
+ alert("Please load or save a template first.");
141
+ return;
142
+ }
143
+ const confidence = parseFloat(confidenceInput.value);
144
+ if (isNaN(confidence) || confidence < 0 || confidence > 1) {
145
+ alert("Confidence must be between 0 and 1");
146
+ return;
147
+ }
148
+ matchResult.textContent = "🔍 Matching...";
149
+ await new Promise(resolve => setTimeout(resolve, 10));
150
+ const result = await window.visor.testMatch({
151
+ templatePath: selectedTemplatePath,
152
+ confidence: confidence,
153
+ //isMultiMatch: document.getElementById("multiScaleCheck").checked
154
+ });
155
+ console.log("Match Result:", result);
156
+ if (!result || result.length==0) {
157
+ matchResult.textContent = "✗ MATCH NOT FOUND";
158
+ ctx.drawImage(
159
+ image,
160
+ 0,
161
+ 0,
162
+ canvas.width,
163
+ canvas.height
164
+ );
165
+ return;
166
+ }
167
+ ctx.drawImage(
168
+ image,
169
+ 0,
170
+ 0,
171
+ canvas.width,
172
+ canvas.height
154
173
  );
155
-
156
- if (!result) {
157
- matchResult.textContent = "✗ MATCH NOT FOUND";
158
- return;
159
- }
160
- matchResult.textContent = `
161
- MATCH FOUND
162
-
163
- Confidence:
164
- ${result.confidence.toFixed(3)}
165
-
166
- Location:
167
- (${result.x}, ${result.y})
168
-
169
- Size:
170
- ${result.width} x ${result.height}
171
- `;
174
+ let matchR = "<b>✓ MATCH FOUND</b>\n";
175
+ let i = 1;
176
+ for(const match of result){
177
+ ctx.strokeStyle = "lime";
178
+ ctx.lineWidth = 2;
179
+ ctx.strokeRect(
180
+ match.x / imageScaleX,
181
+ match.y / imageScaleY,
182
+ match.width / imageScaleX,
183
+ match.height / imageScaleY
184
+ );
185
+ matchR += `<b>Match:</b> ${i}
186
+ <b>Confidence:</b>
187
+ ${match.confidence.toFixed(3)}
188
+ <b>Location:</b>
189
+ (${match.x}, ${match.y})
190
+ <b>Size:</b>
191
+ ${match.width} x ${match.height}
192
+ <hr>
193
+ `;
194
+ i += 1;
195
+ }
196
+ matchResult.innerHTML = matchR;
172
197
  });
173
198
 
199
+ templatePreview.addEventListener("click",
200
+ () => {
201
+ modalImage.src = templatePreview.src;
202
+ imageModal.style.display = "flex";
203
+ }
204
+ );
205
+
206
+ imageModal.addEventListener("click",
207
+ () => {
208
+ imageModal.style.display = "none";
209
+ }
210
+ );
174
211
 
175
212
  loadTemplateBtn.addEventListener("click",
176
213
  async () => {
@@ -178,8 +215,18 @@ loadTemplateBtn.addEventListener("click",
178
215
  if (!path) {
179
216
  return;
180
217
  }
218
+ const fileName = path.split(/[\\/]/).pop();
181
219
  selectedTemplatePath = path;
182
- currentTemplate.textContent = path;
220
+ currentTemplate.textContent = fileName;
221
+ currentTemplate.title = path;
222
+ matchResult.innerHTML = "<b>No Match Tested</b>";
223
+ ctx.drawImage(
224
+ image,
225
+ 0,
226
+ 0,
227
+ canvas.width,
228
+ canvas.height
229
+ );
183
230
  templatePreview.src = path + "?t=" + Date.now();
184
231
  }
185
232
  );
@@ -8,10 +8,7 @@ const electron = require("electron");
8
8
  spawn(
9
9
  electron,
10
10
  [
11
- path.join(
12
- __dirname,
13
- "main.js"
14
- )
11
+ path.join(__dirname, "main.js")
15
12
  ],
16
13
  {
17
14
  stdio: "inherit"
@@ -199,18 +199,29 @@ body {
199
199
  gap: 10px;
200
200
  }
201
201
 
202
- input[type="number"] {
202
+ input[type="range"] {
203
203
  background: rgba(37, 37, 38, 0.8);
204
204
  color: #00d4ff;
205
- border: 1px solid rgba(0, 212, 255, 0.3);
206
- padding: 5px 6px;
207
- border-radius: 6px;
208
- font-size: 0.8em;
209
- width: 60px;
205
+ width: 100px;
210
206
  transition: all 0.3s ease;
207
+ height: 5px;
211
208
  }
212
209
 
213
- input[type="number"]:focus {
210
+ input[type="number"] {
211
+ color: rgb(0, 212, 255);
212
+ font-size: 0.8em;
213
+ width: 60px;
214
+ background: rgba(37, 37, 38, 0.8);
215
+ border-width: 1px;
216
+ border-style: solid;
217
+ border-color: rgba(0, 212, 255, 0.3);
218
+ border-image: initial;
219
+ padding: 5px 6px;
220
+ border-radius: 6px;
221
+ transition: all 0.3s ease;
222
+ }
223
+
224
+ input[type="range"]:focus, input[type="number"]:focus {
214
225
  outline: none;
215
226
  border-color: #00d4ff;
216
227
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
@@ -238,6 +249,7 @@ input[type="number"]:focus {
238
249
  display: block;
239
250
  margin-top: 15px;
240
251
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.1);
252
+ width: stretch;
241
253
  }
242
254
 
243
255
  /* TEMPLATE SECTION */
@@ -268,26 +280,24 @@ input[type="number"]:focus {
268
280
  }
269
281
 
270
282
  .template-status {
271
- display: inline-block;
272
- padding: 4px 7px;
273
- background: rgba(76, 175, 80, 0.15);
274
- border: 1px solid rgba(76, 175, 80, 0.3);
275
- border-radius: 6px;
276
283
  color: #4caf50;
277
- font-weight: 500;
278
- width: fit-content;
284
+ font-size: small;
279
285
  }
280
286
 
281
287
  .template-preview {
282
288
  border: 2px solid #00d4ff;
283
289
  border-radius: 8px;
290
+ width: 130px;
284
291
  max-width: 100%;
285
- height: auto;
292
+ height: 130px;
286
293
  max-height: 150px;
287
294
  object-fit: contain;
288
295
  background: #0a0a0a;
289
296
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.1);
290
297
  display: none;
298
+ margin-top: 15px;
299
+ margin-bottom: 15px;
300
+ cursor: zoom-in;
291
301
  }
292
302
 
293
303
  .template-preview[src]:not([src=""]) {
@@ -346,22 +356,23 @@ input[type="number"]:focus {
346
356
  }
347
357
 
348
358
  #matchResult {
349
- margin-top: 15px;
350
- padding: 15px;
359
+ padding: 12px;
360
+ min-height: 157px;
361
+ max-height: 300px;
362
+ overflow-y: auto;
363
+ max-width: max-content;
364
+ background: rgba(255, 255, 255, 0.03);
365
+ border: 1px solid rgba(0, 212, 255, 0.2);
351
366
  border-radius: 8px;
352
- background: rgba(37, 37, 38, 0.6);
353
- border: 1px solid rgba(100, 150, 180, 0.2);
354
- min-height: 60px;
355
- display: inline-flex;
356
- align-items: center;
357
- justify-content: center;
358
- color: #888;
367
+ font-family: Consolas, monospace;
368
+ white-space: pre-line;
359
369
  font-size: 0.8em;
370
+ border-color: rgb(76, 175, 79);
360
371
  }
361
372
 
362
373
  #matchResult:not(:empty) {
363
374
  background: rgba(76, 175, 80, 0.1);
364
- border-color: rgba(76, 175, 80, 0.3);
375
+ border-color: rgb(76, 175, 79);
365
376
  color: #e0e0e0;
366
377
  }
367
378
 
@@ -426,22 +437,22 @@ input[type="number"]:focus {
426
437
 
427
438
  .result-panel {
428
439
  width: 250px;
429
-
430
440
  flex-shrink: 0;
431
441
  }
432
442
 
433
- #matchResult {
434
- padding: 12px;
435
443
 
436
- min-height: 157px;
437
-
438
- background: rgba(255, 255, 255, 0.03);
439
-
440
- border: 1px solid rgba(0, 212, 255, 0.2);
441
-
442
- border-radius: 8px;
443
-
444
- font-family: Consolas, monospace;
445
-
446
- white-space: pre-line;
444
+ .image-modal {
445
+ display: none;
446
+ position: fixed;
447
+ inset: 0;
448
+ background:
449
+ rgba(0,0,0,0.8);
450
+ justify-content: center;
451
+ align-items: center;
452
+ z-index: 9999;
447
453
  }
454
+
455
+ .image-modal img {
456
+ max-width: 90vw;
457
+ max-height: 90vh;
458
+ }
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "@aspiresys/visor",
3
- "version": "1.2.10",
3
+ "version": "1.3.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
7
7
  "build": "tsc",
8
8
  "start": "ts-node src/test.ts"
9
9
  },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
10
16
  "dependencies": {
11
17
  "@nut-tree-fork/nut-js": "^4.1.0",
12
18
  "@techstark/opencv-js": "^4.12.0-release.1",