scandoc-ai-components 0.0.59 → 0.0.61
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.js +85 -128
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11332,47 +11332,6 @@ class ExtractorVideo {
|
|
|
11332
11332
|
setTimeout(() => this.analyzeVideoStream(), ExtractorVideo.FREQUENCY_MS);
|
|
11333
11333
|
}
|
|
11334
11334
|
}
|
|
11335
|
-
async getCameraMargins() {
|
|
11336
|
-
const video = document.getElementById('ScanDocAIVideoElement');
|
|
11337
|
-
const canvas = document.createElement('canvas');
|
|
11338
|
-
const ctx = canvas.getContext('2d');
|
|
11339
|
-
canvas.width = video.videoWidth;
|
|
11340
|
-
canvas.height = video.videoHeight;
|
|
11341
|
-
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
11342
|
-
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
|
|
11343
|
-
const isColumnBlack = x => {
|
|
11344
|
-
const threshold = 16;
|
|
11345
|
-
for (let y = 0; y < canvas.height; y++) {
|
|
11346
|
-
const i = (y * canvas.width + x) * 4;
|
|
11347
|
-
const [r, g, b] = [imageData[i], imageData[i + 1], imageData[i + 2]];
|
|
11348
|
-
if (r > threshold || g > threshold || b > threshold) return false;
|
|
11349
|
-
}
|
|
11350
|
-
return true;
|
|
11351
|
-
};
|
|
11352
|
-
const isRowBlack = y => {
|
|
11353
|
-
const threshold = 16;
|
|
11354
|
-
for (let x = 0; x < canvas.width; x++) {
|
|
11355
|
-
const i = (y * canvas.width + x) * 4;
|
|
11356
|
-
const [r, g, b] = [imageData[i], imageData[i + 1], imageData[i + 2]];
|
|
11357
|
-
if (r > threshold || g > threshold || b > threshold) return false;
|
|
11358
|
-
}
|
|
11359
|
-
return true;
|
|
11360
|
-
};
|
|
11361
|
-
let left = 0,
|
|
11362
|
-
right = 0,
|
|
11363
|
-
top = 0,
|
|
11364
|
-
bottom = 0;
|
|
11365
|
-
while (left < canvas.width && isColumnBlack(left)) left++;
|
|
11366
|
-
while (right < canvas.width && isColumnBlack(canvas.width - 1 - right)) right++;
|
|
11367
|
-
while (top < canvas.height && isRowBlack(top)) top++;
|
|
11368
|
-
while (bottom < canvas.height && isRowBlack(canvas.height - 1 - bottom)) bottom++;
|
|
11369
|
-
return {
|
|
11370
|
-
leftPct: left / canvas.width,
|
|
11371
|
-
rightPct: right / canvas.width,
|
|
11372
|
-
topPct: top / canvas.height,
|
|
11373
|
-
bottomPct: bottom / canvas.height
|
|
11374
|
-
};
|
|
11375
|
-
}
|
|
11376
11335
|
async startVideo() {
|
|
11377
11336
|
try {
|
|
11378
11337
|
const serviceConfig = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getScanDocAIConfig)();
|
|
@@ -11405,16 +11364,6 @@ class ExtractorVideo {
|
|
|
11405
11364
|
await this.video.play().catch(e => {
|
|
11406
11365
|
console.warn(`Error on video play: ${e}`);
|
|
11407
11366
|
});
|
|
11408
|
-
setTimeout(async () => {
|
|
11409
|
-
const margins = await this.getCameraMargins();
|
|
11410
|
-
const rectangle = document.querySelector('.desktopRectangle');
|
|
11411
|
-
if (rectangle) {
|
|
11412
|
-
rectangle.style.top = `${margins.topPct * 100}%`;
|
|
11413
|
-
rectangle.style.bottom = `${margins.bottomPct * 100}%`;
|
|
11414
|
-
rectangle.style.left = `${margins.leftPct * 100}%`;
|
|
11415
|
-
rectangle.style.right = `${margins.rightPct * 100}%`;
|
|
11416
|
-
}
|
|
11417
|
-
}, 500);
|
|
11418
11367
|
this.scanStartTime = Date.now(); // Reset timer
|
|
11419
11368
|
setTimeout(() => this.analyzeVideoStream(), ExtractorVideo.FREQUENCY_MS);
|
|
11420
11369
|
this.showMessage("Starting scanning");
|
|
@@ -11449,83 +11398,91 @@ class ExtractorVideo {
|
|
|
11449
11398
|
}
|
|
11450
11399
|
getHTML() {
|
|
11451
11400
|
return `
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
11401
|
+
<div class="desktopFeedback" id="ScanDocAIMessage"></div>
|
|
11402
|
+
<div class="desktopVideoArea">
|
|
11403
|
+
<div class="desktopVideoHolder">
|
|
11404
|
+
<div class="videoWrapper">
|
|
11405
|
+
<video id="ScanDocAIVideoElement" class="desktopVideo" autoPlay muted playsInline></video>
|
|
11406
|
+
<div class="backgroundOverlay"></div>
|
|
11407
|
+
<div class="desktopRectangle dashedRectangle"></div>
|
|
11408
|
+
</div>
|
|
11409
|
+
</div>
|
|
11410
|
+
</div>
|
|
11411
|
+
|
|
11412
|
+
<style>
|
|
11413
|
+
.desktopVideoArea {
|
|
11414
|
+
display: flex;
|
|
11415
|
+
flex-direction: column;
|
|
11416
|
+
gap: 8px;
|
|
11417
|
+
padding: 16px;
|
|
11418
|
+
background-color: rgba(255, 255, 255, 0.05);
|
|
11419
|
+
border: 1px solid #5078bb;
|
|
11420
|
+
border-radius: 15px;
|
|
11421
|
+
margin-left: 20%;
|
|
11422
|
+
margin-right: 20%;
|
|
11423
|
+
}
|
|
11424
|
+
|
|
11425
|
+
.desktopVideoHolder {
|
|
11426
|
+
position: relative;
|
|
11427
|
+
max-width: 100%;
|
|
11428
|
+
overflow: hidden;
|
|
11429
|
+
}
|
|
11430
|
+
|
|
11431
|
+
.videoWrapper {
|
|
11432
|
+
position: relative;
|
|
11433
|
+
width: 100%;
|
|
11434
|
+
aspect-ratio: 16 / 9;
|
|
11435
|
+
}
|
|
11436
|
+
.desktopVideo {
|
|
11437
|
+
width: 100%;
|
|
11438
|
+
height: 100%;
|
|
11439
|
+
object-fit: cover;
|
|
11440
|
+
display: block;
|
|
11441
|
+
}
|
|
11442
|
+
.desktopRectangle {
|
|
11443
|
+
position: absolute;
|
|
11444
|
+
top: 5%;
|
|
11445
|
+
left: 5%;
|
|
11446
|
+
right: 5%;
|
|
11447
|
+
bottom: 5%;
|
|
11448
|
+
border-radius: 30px;
|
|
11449
|
+
display: flex;
|
|
11450
|
+
justify-content: center;
|
|
11451
|
+
align-items: center;
|
|
11452
|
+
z-index: 3;
|
|
11453
|
+
}
|
|
11454
|
+
|
|
11455
|
+
.dashedRectangle {
|
|
11456
|
+
border: 5px dashed #5078bb;
|
|
11457
|
+
}
|
|
11458
|
+
|
|
11459
|
+
.solidRectangle {
|
|
11460
|
+
border: 5px solid #5078bb;
|
|
11461
|
+
}
|
|
11462
|
+
|
|
11463
|
+
.backgroundOverlay {
|
|
11464
|
+
position: absolute;
|
|
11465
|
+
top: 0;
|
|
11466
|
+
left: 0;
|
|
11467
|
+
width: 100%;
|
|
11468
|
+
height: 100%;
|
|
11469
|
+
background-color: rgba(0, 0, 0, 0.051);
|
|
11470
|
+
z-index: 2;
|
|
11471
|
+
pointer-events: none;
|
|
11472
|
+
}
|
|
11473
|
+
|
|
11474
|
+
.desktopFeedback {
|
|
11475
|
+
position: relative;
|
|
11476
|
+
display: flex;
|
|
11477
|
+
font-size: 22px;
|
|
11478
|
+
font-weight: 600;
|
|
11479
|
+
min-height: 36px;
|
|
11480
|
+
justify-content: center;
|
|
11481
|
+
align-items: center;
|
|
11482
|
+
color: #5078bb;
|
|
11483
|
+
}
|
|
11484
|
+
</style>
|
|
11485
|
+
`;
|
|
11529
11486
|
}
|
|
11530
11487
|
}
|
|
11531
11488
|
let EXTRACTION_VIDEO = undefined;
|