@ekyc_qoobiss/qbs-ect-cmp 4.7.24 → 4.7.25

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.
@@ -592,88 +592,93 @@ const IdAutoCapture = class {
592
592
  // Method for continuous video frame processing with OpenCV
593
593
  this.processVideoFrame = () => {
594
594
  if (this.videoElement && this.processingCanvasElement && this.opencvReady && this.isDetecting) {
595
- console.log('Processing frame. cv.Mat is a constructor:', typeof cv.Mat === 'function');
596
- const video = this.videoElement;
597
- const processingCanvas = this.processingCanvasElement;
598
- const context = processingCanvas.getContext('2d');
599
- processingCanvas.width = video.videoWidth;
600
- processingCanvas.height = video.videoHeight;
601
- context.drawImage(video, 0, 0, processingCanvas.width, processingCanvas.height);
602
- const imageData = context.getImageData(0, 0, processingCanvas.width, processingCanvas.height);
603
- // --- OpenCV.js processing starts here ---
604
- let src = new cv.Mat(processingCanvas.height, processingCanvas.width, cv.CV_8UC4);
605
- src.data.set(imageData.data);
606
- let gray = new cv.Mat();
607
- let blurred = new cv.Mat();
608
- let edges = new cv.Mat();
609
- let contours = new cv.MatVector();
610
- let hierarchy = new cv.Mat();
611
595
  try {
612
- cv.cvtColor(src, gray, cv.COLOR_RGBA2GRAY, 0);
613
- cv.GaussianBlur(gray, blurred, new cv.Size(5, 5), 0, 0, cv.BORDER_DEFAULT);
614
- cv.Canny(blurred, edges, 75, 200, 3, false);
615
- cv.findContours(edges, contours, hierarchy, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE);
616
- let idDetected = false;
617
- let maxArea = 0;
618
- //let bestRect = null;
619
- for (let i = 0; i < contours.size(); ++i) {
620
- let contour = contours.get(i);
621
- let area = cv.contourArea(contour);
622
- if (area > 1000 && area > maxArea) {
623
- let peri = cv.arcLength(contour, true);
624
- let approx = new cv.Mat();
625
- cv.approxPolyDP(contour, approx, 0.02 * peri, true);
626
- if (approx.rows === 4) {
627
- let rect = cv.boundingRect(approx);
628
- const aspectRatio = rect.width / rect.height;
629
- if (aspectRatio > 1.4 && aspectRatio < 1.8) {
630
- if (rect.width > video.videoWidth * 0.3 && rect.height > video.videoHeight * 0.3) {
631
- idDetected = true;
632
- maxArea = area;
633
- //bestRect = rect;
596
+ console.log('Processing frame. cv.Mat is a constructor:', typeof cv.Mat === 'function');
597
+ const video = this.videoElement;
598
+ const processingCanvas = this.processingCanvasElement;
599
+ const context = processingCanvas.getContext('2d');
600
+ processingCanvas.width = video.videoWidth;
601
+ processingCanvas.height = video.videoHeight;
602
+ context.drawImage(video, 0, 0, processingCanvas.width, processingCanvas.height);
603
+ const imageData = context.getImageData(0, 0, processingCanvas.width, processingCanvas.height);
604
+ // --- OpenCV.js processing starts here ---
605
+ let src = new cv.Mat(processingCanvas.height, processingCanvas.width, cv.CV_8UC4);
606
+ src.data.set(imageData.data);
607
+ let gray = new cv.Mat();
608
+ let blurred = new cv.Mat();
609
+ let edges = new cv.Mat();
610
+ let contours = new cv.MatVector();
611
+ let hierarchy = new cv.Mat();
612
+ try {
613
+ cv.cvtColor(src, gray, cv.COLOR_RGBA2GRAY, 0);
614
+ cv.GaussianBlur(gray, blurred, new cv.Size(5, 5), 0, 0, cv.BORDER_DEFAULT);
615
+ cv.Canny(blurred, edges, 75, 200, 3, false);
616
+ cv.findContours(edges, contours, hierarchy, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE);
617
+ let idDetected = false;
618
+ let maxArea = 0;
619
+ //let bestRect = null;
620
+ for (let i = 0; i < contours.size(); ++i) {
621
+ let contour = contours.get(i);
622
+ let area = cv.contourArea(contour);
623
+ if (area > 1000 && area > maxArea) {
624
+ let peri = cv.arcLength(contour, true);
625
+ let approx = new cv.Mat();
626
+ cv.approxPolyDP(contour, approx, 0.02 * peri, true);
627
+ if (approx.rows === 4) {
628
+ let rect = cv.boundingRect(approx);
629
+ const aspectRatio = rect.width / rect.height;
630
+ if (aspectRatio > 1.4 && aspectRatio < 1.8) {
631
+ if (rect.width > video.videoWidth * 0.3 && rect.height > video.videoHeight * 0.3) {
632
+ idDetected = true;
633
+ maxArea = area;
634
+ //bestRect = rect;
635
+ }
634
636
  }
635
637
  }
638
+ approx.delete();
639
+ }
640
+ contour.delete();
641
+ }
642
+ if (idDetected) {
643
+ console.log('ID document detected! Starting countdown...');
644
+ this.countdown = 3;
645
+ if (this.animationFrameId !== null) {
646
+ cancelAnimationFrame(this.animationFrameId); // Stop continuous frame processing
647
+ this.animationFrameId = null;
636
648
  }
637
- approx.delete();
649
+ const timer = setInterval(() => {
650
+ this.countdown--;
651
+ if (this.countdown <= 0) {
652
+ clearInterval(timer);
653
+ this.capture();
654
+ this.stopRecording();
655
+ this.isDetecting = false;
656
+ console.log('Picture taken. You can now stop recording.');
657
+ this.countdown = 0; // Ensure countdown is 0
658
+ }
659
+ }, 1000);
638
660
  }
639
- contour.delete();
640
661
  }
641
- if (idDetected) {
642
- console.log('ID document detected! Starting countdown...');
643
- this.countdown = 3;
662
+ catch (error) {
663
+ console.error('OpenCV processing error:', error);
664
+ this.isDetecting = false; // Stop detection on error
644
665
  if (this.animationFrameId !== null) {
645
- cancelAnimationFrame(this.animationFrameId); // Stop continuous frame processing
666
+ cancelAnimationFrame(this.animationFrameId);
646
667
  this.animationFrameId = null;
647
668
  }
648
- const timer = setInterval(() => {
649
- this.countdown--;
650
- if (this.countdown <= 0) {
651
- clearInterval(timer);
652
- this.capture();
653
- this.stopRecording();
654
- this.isDetecting = false;
655
- console.log('Picture taken. You can now stop recording.');
656
- this.countdown = 0; // Ensure countdown is 0
657
- }
658
- }, 1000);
659
669
  }
660
- }
661
- catch (error) {
662
- console.error('OpenCV processing error:', error);
663
- this.isDetecting = false; // Stop detection on error
664
- if (this.animationFrameId !== null) {
665
- cancelAnimationFrame(this.animationFrameId);
666
- this.animationFrameId = null;
670
+ finally {
671
+ // Crucial: Release memory allocated by OpenCV Mat objects
672
+ src.delete();
673
+ gray.delete();
674
+ blurred.delete();
675
+ edges.delete();
676
+ contours.delete();
677
+ hierarchy.delete();
667
678
  }
668
679
  }
669
- finally {
670
- // Crucial: Release memory allocated by OpenCV Mat objects
671
- src.delete();
672
- gray.delete();
673
- blurred.delete();
674
- edges.delete();
675
- contours.delete();
676
- hierarchy.delete();
680
+ catch (error) {
681
+ console.error('Error processing video frame with OpenCV:', error);
677
682
  }
678
683
  // --- OpenCV.js processing ends here ---
679
684
  }
@@ -791,7 +796,7 @@ const IdAutoCapture = class {
791
796
  if (TranslationUtils.state.device.isDesktop) {
792
797
  cameraVideoClass = 'cameraVideoSelfieDesk';
793
798
  }
794
- return (index.h("div", { key: '0b0333b5c7b20a216319cf081a9f49111012596e', class: "container flex center" }, index.h("div", { key: 'e7980ea76bddf47ac73f865b3c4cb609d4597cbd', class: "px-2 w-100" }, index.h("h1", { key: 'd5a97b44269a80d3a3cee564ff48cf543d3bfc04', class: this.titleStyle, innerHTML: this.titleMesage }), index.h("div", { key: 'e52e5f59f446be42bba3ae25377fbbe7e2b87d87', hidden: this.verified }, index.h("div", { key: 'f680400952063d743350a607e2f503bc57fdcdff', class: "w-100 h-100 rounded" }, index.h("div", { key: '237debd548236f0a12c71ac73b61ff420bd91203', class: "camera rounded" }, index.h("video", { key: 'db25e8012fc4639d785a175a449ac4ec5130d113', id: "video", loop: true, autoplay: true, playsinline: true, muted: true, class: cameraVideoClass, ref: el => (this.videoElement = el) }), index.h("canvas", { key: 'd2c08faa9f71bf7c8b5f161fd76d49a99960a73e', id: "output", ref: el => (this.canvasElement = el), style: { display: 'none' } }), index.h("canvas", { key: '1882ca42f1716dd6573e28ffb289958000d8e23a', id: "processingCanvasElement", ref: el => (this.processingCanvasElement = el), style: { display: 'none' } }), index.h("div", { key: 'ed29e8ff7706909244dfc6ef8ef2a3529e010628', class: "id-guide-rectangle" }), this.isCapturing && index.h("div", { key: '4df9ad4556cd2d57b0a5e18d0fe18b10b61cd55b', class: "capture-flash-overlay" }), this.countdown > 0 && (index.h("div", { key: 'c06a98f7a785bdefeba161a39a701eb7257a90d6', class: "absolute inset-0 bg-black bg-opacity-50 flex items-center justify-center" }, index.h("span", { key: '63407cf0373b92248eef073d863b12536c6f9cfc', class: "text-white text-9xl font-bold animate-bounce" }, this.countdown)))))), index.h("div", { key: '047ebeeb0b61d05f95f51b23e48a14eed82dbb31', class: "footer text-center" }, index.h("img", { key: 'deeea20a5acf6618ee24fbfa6919b8a5a38bb1d0', src: Cameras.logoOntraceSvg })))));
799
+ return (index.h("div", { key: 'deb2d35a50823fa5c222c6049a4119a371194870', class: "container flex center" }, index.h("div", { key: '449a0fef911f14d3611a1d7e83ed1bfc02c0553f', class: "px-2 w-100" }, index.h("h1", { key: '8d9f8b3684e58ba57f4ec0467efa0d9af62c5a98', class: this.titleStyle, innerHTML: this.titleMesage }), index.h("div", { key: '701aeecc148bdd00ef9cd38b165f0628adfe827c', hidden: this.verified }, index.h("div", { key: 'cbe89cf4ddc15c46b595929ecaf4fb8cc20136b5', class: "w-100 h-100 rounded" }, index.h("div", { key: '78f52a0a77c3dd8218115253bbcb79ee0a9a6d4b', class: "camera rounded" }, index.h("video", { key: '6ee76764205ce855fedd7b8c86be4394b2cad7bb', id: "video", loop: true, autoplay: true, playsinline: true, muted: true, class: cameraVideoClass, ref: el => (this.videoElement = el) }), index.h("canvas", { key: '5574b79a997d3ca06afa99faa61cb9bace755e91', id: "output", ref: el => (this.canvasElement = el), style: { display: 'none' } }), index.h("canvas", { key: 'e25df7ef70206d5544adade008cd612f1fee550a', id: "processingCanvasElement", ref: el => (this.processingCanvasElement = el), style: { display: 'none' } }), index.h("div", { key: '8ac6db08f2d1e44d04f2827f29e08787b853812e', class: "id-guide-rectangle" }), this.isCapturing && index.h("div", { key: '900ddcc0d2bf371d7ad4e593eaf0e9b60b6d2810', class: "capture-flash-overlay" }), this.countdown > 0 && (index.h("div", { key: 'd5f05c1b3dcbd02977462c6b9d816c2835698c2f', class: "absolute inset-0 bg-black bg-opacity-50 flex items-center justify-center" }, index.h("span", { key: '7b85d36f1b609360c8214a29e220f6f80effffca', class: "text-white text-9xl font-bold animate-bounce" }, this.countdown)))))), index.h("div", { key: '9b653ebb92ce731ddb235d85db4a7fa99aaa4c64', class: "footer text-center" }, index.h("img", { key: 'f085d8f1698e66448cf749ec4cc45b496fbd55a1', src: Cameras.logoOntraceSvg })))));
795
800
  }
796
801
  get el() { return index.getElement(this); }
797
802
  };
@@ -856,7 +861,7 @@ const IdSelection = class {
856
861
  };
857
862
  IdSelection.style = idSelectionCss;
858
863
 
859
- const version$1 = "4.7.24";
864
+ const version$1 = "4.7.25";
860
865
  var packageJson = {
861
866
  version: version$1};
862
867