dytools-capture-engine 1.2.2 → 1.2.4
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.cjs +18 -40
- package/dist/index.js +18 -40
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -492,6 +492,8 @@ var SimpleZone = class extends CaptureZoneBase {
|
|
|
492
492
|
this.primaryCanvasRectangleId = this.canvasManager.addRectangle(this.rect, this.name, "blue", true, true);
|
|
493
493
|
}
|
|
494
494
|
if (type === CaptureZoneEventType.ZoneHiddenChanged) {
|
|
495
|
+
const zoneHiddenChangedPayload = payload;
|
|
496
|
+
this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
|
|
495
497
|
}
|
|
496
498
|
if (type === CaptureZoneEventType.ZoneOcrMatchesChanged) {
|
|
497
499
|
const zoneOcrMatchesChangedPayload = payload;
|
|
@@ -504,11 +506,10 @@ var SimpleZone = class extends CaptureZoneBase {
|
|
|
504
506
|
let isFirstMatch = true;
|
|
505
507
|
for (const match of ocrMatches) {
|
|
506
508
|
if (match.templateZoneId != this.id) continue;
|
|
507
|
-
|
|
508
|
-
this.ocrOverlayIds.push(this.canvasManager?.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 0, 0.25)", false));
|
|
509
|
-
}
|
|
509
|
+
this.ocrOverlayIds.push(this.canvasManager?.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 0, 0.25)", false));
|
|
510
510
|
break;
|
|
511
511
|
}
|
|
512
|
+
this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !this.hidden));
|
|
512
513
|
}
|
|
513
514
|
}
|
|
514
515
|
handleEvent(id, type, payload) {
|
|
@@ -532,35 +533,6 @@ var SimpleZone = class extends CaptureZoneBase {
|
|
|
532
533
|
}
|
|
533
534
|
}
|
|
534
535
|
}
|
|
535
|
-
update(ocrRead, ocrMatches, canvas, flags) {
|
|
536
|
-
if (!this.primaryCanvasRectangleId) {
|
|
537
|
-
this.primaryCanvasRectangleId = canvas.addRectangle(this.rect, this.name, "blue", true, true);
|
|
538
|
-
} else {
|
|
539
|
-
canvas.setName(this.primaryCanvasRectangleId, this.name);
|
|
540
|
-
canvas.setColor(this.primaryCanvasRectangleId, "blue");
|
|
541
|
-
canvas.setVisibility(this.primaryCanvasRectangleId, !this.hidden);
|
|
542
|
-
canvas.setSelectable(this.primaryCanvasRectangleId, true);
|
|
543
|
-
canvas.setResizable(this.primaryCanvasRectangleId, true);
|
|
544
|
-
canvas.setRectangleSize(this.primaryCanvasRectangleId, this.rect);
|
|
545
|
-
}
|
|
546
|
-
if (!ocrMatches || ocrMatches.length == 0) {
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
549
|
-
let thisOcrMatches = ocrMatches?.filter((e) => e.templateZoneId == this.id) ?? [];
|
|
550
|
-
let matchHash = this.hidden + "|" + thisOcrMatches.map((e) => `${e.ocrTextResultIds.sort().join(",")}`).join(",");
|
|
551
|
-
if (matchHash === this.lastMatchHash) {
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
this.ocrOverlayIds.forEach((id) => canvas.removeObject(id));
|
|
555
|
-
this.lastMatchHash = matchHash;
|
|
556
|
-
let isFirstMatch = true;
|
|
557
|
-
for (const match of thisOcrMatches) {
|
|
558
|
-
if (!this.hidden) {
|
|
559
|
-
this.ocrOverlayIds.push(canvas.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 0, 0.25)", false));
|
|
560
|
-
}
|
|
561
|
-
break;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
536
|
toExternal(docWidth, docHeight) {
|
|
565
537
|
return {
|
|
566
538
|
TemplateZoneId: this.id,
|
|
@@ -716,6 +688,10 @@ var AnchorZone = class extends CaptureZoneBase {
|
|
|
716
688
|
});
|
|
717
689
|
this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["groupChildren"] });
|
|
718
690
|
}
|
|
691
|
+
if (type === CaptureZoneEventType.ZoneHiddenChanged) {
|
|
692
|
+
const zoneHiddenChangedPayload = payload;
|
|
693
|
+
this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
|
|
694
|
+
}
|
|
719
695
|
if (type === CaptureZoneEventType.ZoneOcrMatchesChanged) {
|
|
720
696
|
const zoneOcrMatchesChangedPayload = payload;
|
|
721
697
|
let ocrMatches = zoneOcrMatchesChangedPayload.matches;
|
|
@@ -728,13 +704,9 @@ var AnchorZone = class extends CaptureZoneBase {
|
|
|
728
704
|
let cycle = this.cycle;
|
|
729
705
|
for (const match of ocrMatches) {
|
|
730
706
|
if (match.templateZoneId != this.id) continue;
|
|
731
|
-
|
|
732
|
-
this.ocrOverlayIds.push(this.canvasManager?.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 255, 0.25)", false));
|
|
733
|
-
}
|
|
707
|
+
this.ocrOverlayIds.push(this.canvasManager?.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 255, 0.25)", false));
|
|
734
708
|
if (match.anchorPointAbsolute) {
|
|
735
|
-
|
|
736
|
-
this.ocrOverlayIds.push(this.canvasManager?.addCircle(match.anchorPointAbsolute, 2, "rgba(0, 0, 255, 0.25)", false, false));
|
|
737
|
-
}
|
|
709
|
+
this.ocrOverlayIds.push(this.canvasManager?.addCircle(match.anchorPointAbsolute, 2, "rgba(0, 0, 255, 0.25)", false, false));
|
|
738
710
|
if (isFirstMatch) {
|
|
739
711
|
for (const child of this.children.filter((e) => e.needsAnchorReposition)) {
|
|
740
712
|
let currentAnchorPoint = this.currentAnchorPoint ?? this.rect.origin;
|
|
@@ -743,10 +715,15 @@ var AnchorZone = class extends CaptureZoneBase {
|
|
|
743
715
|
child.needsAnchorReposition = false;
|
|
744
716
|
}
|
|
745
717
|
} else {
|
|
746
|
-
for (
|
|
718
|
+
for (let i = 0; i < this.children.length; i++) {
|
|
719
|
+
const child = this.children[i];
|
|
747
720
|
if (child.hidden == false) {
|
|
748
721
|
let vector = this.currentAnchorPoint ? match.anchorPointAbsolute.getDeltaFromPoint(this.currentAnchorPoint) : new import_dytools_geometry.Vector(0, 0);
|
|
749
|
-
let
|
|
722
|
+
let maxOpacity = 0.5;
|
|
723
|
+
let minOpacity = 0.25;
|
|
724
|
+
let percentThroughArray = (i + 1) / this.children.length;
|
|
725
|
+
let opacity = maxOpacity - (maxOpacity - minOpacity) * percentThroughArray;
|
|
726
|
+
let color = `rgba(" + cycle + ", 128, 255, ${opacity.toFixed(2)})`;
|
|
750
727
|
const polygon = child.rect.move(vector).toPolygon().points;
|
|
751
728
|
this.ocrOverlayIds.push(this.canvasManager?.addPolygon(polygon, color, false));
|
|
752
729
|
}
|
|
@@ -758,6 +735,7 @@ var AnchorZone = class extends CaptureZoneBase {
|
|
|
758
735
|
}
|
|
759
736
|
isFirstMatch = false;
|
|
760
737
|
}
|
|
738
|
+
this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !this.hidden));
|
|
761
739
|
}
|
|
762
740
|
}
|
|
763
741
|
get cycle() {
|
package/dist/index.js
CHANGED
|
@@ -476,6 +476,8 @@ var SimpleZone = class extends CaptureZoneBase {
|
|
|
476
476
|
this.primaryCanvasRectangleId = this.canvasManager.addRectangle(this.rect, this.name, "blue", true, true);
|
|
477
477
|
}
|
|
478
478
|
if (type === CaptureZoneEventType.ZoneHiddenChanged) {
|
|
479
|
+
const zoneHiddenChangedPayload = payload;
|
|
480
|
+
this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
|
|
479
481
|
}
|
|
480
482
|
if (type === CaptureZoneEventType.ZoneOcrMatchesChanged) {
|
|
481
483
|
const zoneOcrMatchesChangedPayload = payload;
|
|
@@ -488,11 +490,10 @@ var SimpleZone = class extends CaptureZoneBase {
|
|
|
488
490
|
let isFirstMatch = true;
|
|
489
491
|
for (const match of ocrMatches) {
|
|
490
492
|
if (match.templateZoneId != this.id) continue;
|
|
491
|
-
|
|
492
|
-
this.ocrOverlayIds.push(this.canvasManager?.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 0, 0.25)", false));
|
|
493
|
-
}
|
|
493
|
+
this.ocrOverlayIds.push(this.canvasManager?.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 0, 0.25)", false));
|
|
494
494
|
break;
|
|
495
495
|
}
|
|
496
|
+
this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !this.hidden));
|
|
496
497
|
}
|
|
497
498
|
}
|
|
498
499
|
handleEvent(id, type, payload) {
|
|
@@ -516,35 +517,6 @@ var SimpleZone = class extends CaptureZoneBase {
|
|
|
516
517
|
}
|
|
517
518
|
}
|
|
518
519
|
}
|
|
519
|
-
update(ocrRead, ocrMatches, canvas, flags) {
|
|
520
|
-
if (!this.primaryCanvasRectangleId) {
|
|
521
|
-
this.primaryCanvasRectangleId = canvas.addRectangle(this.rect, this.name, "blue", true, true);
|
|
522
|
-
} else {
|
|
523
|
-
canvas.setName(this.primaryCanvasRectangleId, this.name);
|
|
524
|
-
canvas.setColor(this.primaryCanvasRectangleId, "blue");
|
|
525
|
-
canvas.setVisibility(this.primaryCanvasRectangleId, !this.hidden);
|
|
526
|
-
canvas.setSelectable(this.primaryCanvasRectangleId, true);
|
|
527
|
-
canvas.setResizable(this.primaryCanvasRectangleId, true);
|
|
528
|
-
canvas.setRectangleSize(this.primaryCanvasRectangleId, this.rect);
|
|
529
|
-
}
|
|
530
|
-
if (!ocrMatches || ocrMatches.length == 0) {
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
let thisOcrMatches = ocrMatches?.filter((e) => e.templateZoneId == this.id) ?? [];
|
|
534
|
-
let matchHash = this.hidden + "|" + thisOcrMatches.map((e) => `${e.ocrTextResultIds.sort().join(",")}`).join(",");
|
|
535
|
-
if (matchHash === this.lastMatchHash) {
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
this.ocrOverlayIds.forEach((id) => canvas.removeObject(id));
|
|
539
|
-
this.lastMatchHash = matchHash;
|
|
540
|
-
let isFirstMatch = true;
|
|
541
|
-
for (const match of thisOcrMatches) {
|
|
542
|
-
if (!this.hidden) {
|
|
543
|
-
this.ocrOverlayIds.push(canvas.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 0, 0.25)", false));
|
|
544
|
-
}
|
|
545
|
-
break;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
520
|
toExternal(docWidth, docHeight) {
|
|
549
521
|
return {
|
|
550
522
|
TemplateZoneId: this.id,
|
|
@@ -700,6 +672,10 @@ var AnchorZone = class extends CaptureZoneBase {
|
|
|
700
672
|
});
|
|
701
673
|
this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["groupChildren"] });
|
|
702
674
|
}
|
|
675
|
+
if (type === CaptureZoneEventType.ZoneHiddenChanged) {
|
|
676
|
+
const zoneHiddenChangedPayload = payload;
|
|
677
|
+
this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
|
|
678
|
+
}
|
|
703
679
|
if (type === CaptureZoneEventType.ZoneOcrMatchesChanged) {
|
|
704
680
|
const zoneOcrMatchesChangedPayload = payload;
|
|
705
681
|
let ocrMatches = zoneOcrMatchesChangedPayload.matches;
|
|
@@ -712,13 +688,9 @@ var AnchorZone = class extends CaptureZoneBase {
|
|
|
712
688
|
let cycle = this.cycle;
|
|
713
689
|
for (const match of ocrMatches) {
|
|
714
690
|
if (match.templateZoneId != this.id) continue;
|
|
715
|
-
|
|
716
|
-
this.ocrOverlayIds.push(this.canvasManager?.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 255, 0.25)", false));
|
|
717
|
-
}
|
|
691
|
+
this.ocrOverlayIds.push(this.canvasManager?.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 255, 0.25)", false));
|
|
718
692
|
if (match.anchorPointAbsolute) {
|
|
719
|
-
|
|
720
|
-
this.ocrOverlayIds.push(this.canvasManager?.addCircle(match.anchorPointAbsolute, 2, "rgba(0, 0, 255, 0.25)", false, false));
|
|
721
|
-
}
|
|
693
|
+
this.ocrOverlayIds.push(this.canvasManager?.addCircle(match.anchorPointAbsolute, 2, "rgba(0, 0, 255, 0.25)", false, false));
|
|
722
694
|
if (isFirstMatch) {
|
|
723
695
|
for (const child of this.children.filter((e) => e.needsAnchorReposition)) {
|
|
724
696
|
let currentAnchorPoint = this.currentAnchorPoint ?? this.rect.origin;
|
|
@@ -727,10 +699,15 @@ var AnchorZone = class extends CaptureZoneBase {
|
|
|
727
699
|
child.needsAnchorReposition = false;
|
|
728
700
|
}
|
|
729
701
|
} else {
|
|
730
|
-
for (
|
|
702
|
+
for (let i = 0; i < this.children.length; i++) {
|
|
703
|
+
const child = this.children[i];
|
|
731
704
|
if (child.hidden == false) {
|
|
732
705
|
let vector = this.currentAnchorPoint ? match.anchorPointAbsolute.getDeltaFromPoint(this.currentAnchorPoint) : new Vector(0, 0);
|
|
733
|
-
let
|
|
706
|
+
let maxOpacity = 0.5;
|
|
707
|
+
let minOpacity = 0.25;
|
|
708
|
+
let percentThroughArray = (i + 1) / this.children.length;
|
|
709
|
+
let opacity = maxOpacity - (maxOpacity - minOpacity) * percentThroughArray;
|
|
710
|
+
let color = `rgba(" + cycle + ", 128, 255, ${opacity.toFixed(2)})`;
|
|
734
711
|
const polygon = child.rect.move(vector).toPolygon().points;
|
|
735
712
|
this.ocrOverlayIds.push(this.canvasManager?.addPolygon(polygon, color, false));
|
|
736
713
|
}
|
|
@@ -742,6 +719,7 @@ var AnchorZone = class extends CaptureZoneBase {
|
|
|
742
719
|
}
|
|
743
720
|
isFirstMatch = false;
|
|
744
721
|
}
|
|
722
|
+
this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !this.hidden));
|
|
745
723
|
}
|
|
746
724
|
}
|
|
747
725
|
get cycle() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dytools-capture-engine",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "An editor allowing the creation of templates for ocr capture.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"typescript": "^5.9.3"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"dytools-canvas-engine": "^1.1.
|
|
27
|
+
"dytools-canvas-engine": "^1.1.2",
|
|
28
28
|
"dytools-geometry": "^1.0.0",
|
|
29
29
|
"dytools-result": "^1.0.1"
|
|
30
30
|
}
|