@jaak.ai/stamps 2.0.0-beta.1 → 2.0.0-beta.3
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/README.md +76 -18
- package/dist/cjs/{index-DGM9-FNg.js → index-BfhtOB0D.js} +5 -2
- package/dist/cjs/index-BfhtOB0D.js.map +1 -0
- package/dist/cjs/jaak-stamps-webcomponent.cjs.js +2 -2
- package/dist/cjs/jaak-stamps.cjs.entry.js +515 -37
- package/dist/cjs/jaak-stamps.cjs.entry.js.map +1 -1
- package/dist/cjs/jaak-stamps.entry.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/my-component/my-component.css +227 -0
- package/dist/collection/components/my-component/my-component.js +637 -36
- package/dist/collection/components/my-component/my-component.js.map +1 -1
- package/dist/components/index.js +3 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/jaak-stamps.js +525 -37
- package/dist/components/jaak-stamps.js.map +1 -1
- package/dist/esm/{index-DqoVMnc7.js → index-BP1Q4KOg.js} +5 -2
- package/dist/esm/index-BP1Q4KOg.js.map +1 -0
- package/dist/esm/jaak-stamps-webcomponent.js +3 -3
- package/dist/esm/jaak-stamps.entry.js +515 -37
- package/dist/esm/jaak-stamps.entry.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js +1 -1
- package/dist/jaak-stamps-webcomponent/jaak-stamps.entry.esm.js.map +1 -1
- package/dist/jaak-stamps-webcomponent/p-14eb13d8.entry.js +2 -0
- package/dist/jaak-stamps-webcomponent/p-14eb13d8.entry.js.map +1 -0
- package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js +3 -0
- package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js.map +1 -0
- package/dist/types/components/my-component/my-component.d.ts +48 -0
- package/dist/types/components.d.ts +34 -0
- package/package.json +1 -1
- package/dist/cjs/index-DGM9-FNg.js.map +0 -1
- package/dist/esm/index-DqoVMnc7.js.map +0 -1
- package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js +0 -3
- package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js.map +0 -1
- package/dist/jaak-stamps-webcomponent/p-dd6cc14e.entry.js +0 -2
- package/dist/jaak-stamps-webcomponent/p-dd6cc14e.entry.js.map +0 -1
|
@@ -3,6 +3,10 @@ export class JaakStamps {
|
|
|
3
3
|
el;
|
|
4
4
|
debug = false;
|
|
5
5
|
alignmentTolerance = 10; // Tolerancia en píxeles para considerar un lado alineado (escalado para 320x320)
|
|
6
|
+
maskSize = 90; // Porcentaje del video que ocupará la máscara (default 90%)
|
|
7
|
+
cropMargin = 0; // Margen en píxeles para el recorte del documento (default 0)
|
|
8
|
+
useDocumentClassification = false; // Habilita la clasificación automática de documentos para determinar si solicitar reverso
|
|
9
|
+
preferredCamera = 'auto'; // Define qué cámara usar: 'auto' (automático según dispositivo), 'front' (frontal), 'back' (trasera)
|
|
6
10
|
captureCompleted;
|
|
7
11
|
isReady;
|
|
8
12
|
isVideoActive = false;
|
|
@@ -28,6 +32,10 @@ export class JaakStamps {
|
|
|
28
32
|
isLoading = false;
|
|
29
33
|
isModelPreloaded = false;
|
|
30
34
|
isMaskReady = false;
|
|
35
|
+
availableCameras = [];
|
|
36
|
+
selectedCameraId = null;
|
|
37
|
+
showCameraSelector = false;
|
|
38
|
+
isMultipleCamerasAvailable = false;
|
|
31
39
|
videoRef;
|
|
32
40
|
canvasRef;
|
|
33
41
|
session;
|
|
@@ -36,6 +44,11 @@ export class JaakStamps {
|
|
|
36
44
|
animationId;
|
|
37
45
|
hasScreenshotTaken = false;
|
|
38
46
|
lastDetectedBox;
|
|
47
|
+
mobileNetSession;
|
|
48
|
+
mobileNetClassMap;
|
|
49
|
+
// Camera management properties
|
|
50
|
+
deviceType = 'desktop';
|
|
51
|
+
preferredCameraFacing = null;
|
|
39
52
|
// Performance optimization properties
|
|
40
53
|
frameSkipCounter = 0;
|
|
41
54
|
FRAME_SKIP = 2; // Process every 3rd frame (reduces CPU by ~66%)
|
|
@@ -48,7 +61,9 @@ export class JaakStamps {
|
|
|
48
61
|
preprocessCtx;
|
|
49
62
|
captureCanvas;
|
|
50
63
|
captureCtx;
|
|
51
|
-
MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/
|
|
64
|
+
MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/ddmyp-v1.onnx";
|
|
65
|
+
MOBILENET_MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/cdmmp-v1.onnx";
|
|
66
|
+
MOBILENET_CLASSES_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/cdmmp-v1.json";
|
|
52
67
|
INPUT_SIZE = 320;
|
|
53
68
|
CONFIDENCE_THRESHOLD = 0.6;
|
|
54
69
|
// ISO/IEC 7810 ID-1 standard dimensions (85.60mm x 53.98mm)
|
|
@@ -58,6 +73,25 @@ export class JaakStamps {
|
|
|
58
73
|
console.log(...args);
|
|
59
74
|
}
|
|
60
75
|
}
|
|
76
|
+
validateMaskSize() {
|
|
77
|
+
if (this.maskSize < 50 || this.maskSize > 100) {
|
|
78
|
+
console.warn(`maskSize debe estar entre 50 y 100. Valor actual: ${this.maskSize}. Usando valor por defecto: 90`);
|
|
79
|
+
this.maskSize = 90;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
validateCropMargin() {
|
|
83
|
+
if (this.cropMargin < 0 || this.cropMargin > 100) {
|
|
84
|
+
console.warn(`cropMargin debe estar entre 0 y 100. Valor actual: ${this.cropMargin}. Usando valor por defecto: 0`);
|
|
85
|
+
this.cropMargin = 0;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
validatePreferredCamera() {
|
|
89
|
+
const validOptions = ['auto', 'front', 'back'];
|
|
90
|
+
if (!validOptions.includes(this.preferredCamera)) {
|
|
91
|
+
console.warn(`preferredCamera debe ser uno de: ${validOptions.join(', ')}. Valor actual: ${this.preferredCamera}. Usando valor por defecto: 'auto'`);
|
|
92
|
+
this.preferredCamera = 'auto';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
61
95
|
emitReadyEvent() {
|
|
62
96
|
const isDocumentReady = !!window.ort && this.isModelPreloaded;
|
|
63
97
|
this.isReady.emit(isDocumentReady);
|
|
@@ -70,7 +104,267 @@ export class JaakStamps {
|
|
|
70
104
|
const settings = videoTrack.getSettings();
|
|
71
105
|
return settings.facingMode === 'environment';
|
|
72
106
|
}
|
|
107
|
+
async detectDeviceTypeAndCameras() {
|
|
108
|
+
// Detect device type
|
|
109
|
+
const userAgent = navigator.userAgent;
|
|
110
|
+
const isMobile = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent);
|
|
111
|
+
const isTablet = /iPad|Android/i.test(userAgent) && window.innerWidth >= 768;
|
|
112
|
+
if (isTablet) {
|
|
113
|
+
this.deviceType = 'tablet';
|
|
114
|
+
}
|
|
115
|
+
else if (isMobile) {
|
|
116
|
+
this.deviceType = 'mobile';
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this.deviceType = 'desktop';
|
|
120
|
+
}
|
|
121
|
+
this.debugLog('📱 Device type detected:', this.deviceType);
|
|
122
|
+
// Enumerate available cameras
|
|
123
|
+
await this.enumerateAndDetectCameras();
|
|
124
|
+
// Load user preference
|
|
125
|
+
this.loadCameraPreference();
|
|
126
|
+
}
|
|
127
|
+
async enumerateAndDetectCameras() {
|
|
128
|
+
try {
|
|
129
|
+
// First, check if we have permission to enumerate devices
|
|
130
|
+
const permissionStatus = await this.checkCameraPermission();
|
|
131
|
+
if (permissionStatus === 'denied') {
|
|
132
|
+
this.debugLog('❌ Camera permission denied');
|
|
133
|
+
this.statusMessage = "Permiso de cámara denegado";
|
|
134
|
+
this.statusColor = "#ff6b6b";
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
// Request minimal permission to get device labels
|
|
138
|
+
if (permissionStatus === 'prompt') {
|
|
139
|
+
const tempStream = await navigator.mediaDevices.getUserMedia({ video: true });
|
|
140
|
+
tempStream.getTracks().forEach(track => track.stop());
|
|
141
|
+
}
|
|
142
|
+
// Now enumerate devices with labels
|
|
143
|
+
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
144
|
+
this.availableCameras = devices.filter(device => device.kind === 'videoinput');
|
|
145
|
+
this.isMultipleCamerasAvailable = this.availableCameras.length > 1;
|
|
146
|
+
this.debugLog('📹 Available cameras:', {
|
|
147
|
+
count: this.availableCameras.length,
|
|
148
|
+
isMultipleCamerasAvailable: this.isMultipleCamerasAvailable,
|
|
149
|
+
cameras: this.availableCameras.map(cam => ({
|
|
150
|
+
id: cam.deviceId,
|
|
151
|
+
label: cam.label || 'Unknown Camera'
|
|
152
|
+
}))
|
|
153
|
+
});
|
|
154
|
+
// Set initial camera preference based on device type
|
|
155
|
+
this.setInitialCameraPreference();
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
this.debugLog('❌ Error enumerating cameras:', error);
|
|
159
|
+
this.handleCameraPermissionError(error);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async checkCameraPermission() {
|
|
163
|
+
try {
|
|
164
|
+
if (!navigator.permissions) {
|
|
165
|
+
return 'prompt'; // Assume we need to prompt on older browsers
|
|
166
|
+
}
|
|
167
|
+
const permission = await navigator.permissions.query({ name: 'camera' });
|
|
168
|
+
return permission.state;
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
this.debugLog('⚠️ Could not check camera permission:', error);
|
|
172
|
+
return 'prompt';
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
handleCameraPermissionError(error) {
|
|
176
|
+
if (error.name === 'NotAllowedError') {
|
|
177
|
+
this.statusMessage = "Permiso de cámara denegado. Active el permiso en configuración.";
|
|
178
|
+
this.statusColor = "#ff6b6b";
|
|
179
|
+
this.availableCameras = [];
|
|
180
|
+
this.isMultipleCamerasAvailable = false;
|
|
181
|
+
}
|
|
182
|
+
else if (error.name === 'NotFoundError') {
|
|
183
|
+
this.statusMessage = "No se encontraron cámaras disponibles.";
|
|
184
|
+
this.statusColor = "#ff6b6b";
|
|
185
|
+
this.availableCameras = [];
|
|
186
|
+
this.isMultipleCamerasAvailable = false;
|
|
187
|
+
}
|
|
188
|
+
else if (error.name === 'NotReadableError') {
|
|
189
|
+
this.statusMessage = "Cámara en uso por otra aplicación.";
|
|
190
|
+
this.statusColor = "#ff6b6b";
|
|
191
|
+
this.availableCameras = [];
|
|
192
|
+
this.isMultipleCamerasAvailable = false;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
this.statusMessage = "Error al acceder a las cámaras.";
|
|
196
|
+
this.statusColor = "#ff6b6b";
|
|
197
|
+
this.availableCameras = [];
|
|
198
|
+
this.isMultipleCamerasAvailable = false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
setInitialCameraPreference() {
|
|
202
|
+
if (this.availableCameras.length === 0)
|
|
203
|
+
return;
|
|
204
|
+
// Apply user preference for camera selection
|
|
205
|
+
if (this.preferredCamera === 'front') {
|
|
206
|
+
// User explicitly wants front camera
|
|
207
|
+
this.preferredCameraFacing = 'user';
|
|
208
|
+
const frontCamera = this.availableCameras.find(camera => camera.label.toLowerCase().includes('front') ||
|
|
209
|
+
camera.label.toLowerCase().includes('user') ||
|
|
210
|
+
camera.label.toLowerCase().includes('selfie') ||
|
|
211
|
+
!camera.label.toLowerCase().includes('back') && !camera.label.toLowerCase().includes('rear'));
|
|
212
|
+
if (frontCamera) {
|
|
213
|
+
this.selectedCameraId = frontCamera.deviceId;
|
|
214
|
+
this.debugLog('👤 User selected front camera:', frontCamera.label);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
this.selectedCameraId = this.availableCameras[0].deviceId;
|
|
218
|
+
this.debugLog('⚠️ Front camera not found, using first available:', this.availableCameras[0].label);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else if (this.preferredCamera === 'back') {
|
|
222
|
+
// User explicitly wants back camera
|
|
223
|
+
this.preferredCameraFacing = 'environment';
|
|
224
|
+
const backCamera = this.availableCameras.find(camera => camera.label.toLowerCase().includes('back') ||
|
|
225
|
+
camera.label.toLowerCase().includes('rear') ||
|
|
226
|
+
camera.label.toLowerCase().includes('environment'));
|
|
227
|
+
if (backCamera) {
|
|
228
|
+
this.selectedCameraId = backCamera.deviceId;
|
|
229
|
+
this.debugLog('📷 User selected back camera:', backCamera.label);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
this.selectedCameraId = this.availableCameras[0].deviceId;
|
|
233
|
+
this.debugLog('⚠️ Back camera not found, using first available:', this.availableCameras[0].label);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
// Auto mode - use device type to determine best camera
|
|
238
|
+
if (this.deviceType === 'mobile' || this.deviceType === 'tablet') {
|
|
239
|
+
// For mobile/tablet, prefer rear camera for document scanning
|
|
240
|
+
this.preferredCameraFacing = 'environment';
|
|
241
|
+
const rearCamera = this.availableCameras.find(camera => camera.label.toLowerCase().includes('back') ||
|
|
242
|
+
camera.label.toLowerCase().includes('rear') ||
|
|
243
|
+
camera.label.toLowerCase().includes('environment'));
|
|
244
|
+
if (rearCamera) {
|
|
245
|
+
this.selectedCameraId = rearCamera.deviceId;
|
|
246
|
+
this.debugLog('📱 Auto-selected rear camera for mobile:', rearCamera.label);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
this.selectedCameraId = this.availableCameras[0].deviceId;
|
|
250
|
+
this.debugLog('📱 Rear camera not found, using first available:', this.availableCameras[0].label);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
// For desktop, use first available camera (usually the only one)
|
|
255
|
+
this.selectedCameraId = this.availableCameras[0].deviceId;
|
|
256
|
+
this.debugLog('💻 Auto-selected desktop camera:', this.availableCameras[0].label);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
loadCameraPreference() {
|
|
261
|
+
try {
|
|
262
|
+
const saved = localStorage.getItem('jaak-stamps-camera-preference');
|
|
263
|
+
if (saved) {
|
|
264
|
+
const preference = JSON.parse(saved);
|
|
265
|
+
// Validate that the saved camera is still available
|
|
266
|
+
const isStillAvailable = this.availableCameras.some(camera => camera.deviceId === preference.cameraId);
|
|
267
|
+
if (isStillAvailable) {
|
|
268
|
+
this.selectedCameraId = preference.cameraId;
|
|
269
|
+
this.preferredCameraFacing = preference.facing;
|
|
270
|
+
this.debugLog('💾 Loaded camera preference:', preference);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
this.debugLog('⚠️ Error loading camera preference:', error);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
saveCameraPreference() {
|
|
279
|
+
try {
|
|
280
|
+
const preference = {
|
|
281
|
+
cameraId: this.selectedCameraId,
|
|
282
|
+
facing: this.preferredCameraFacing,
|
|
283
|
+
timestamp: Date.now()
|
|
284
|
+
};
|
|
285
|
+
localStorage.setItem('jaak-stamps-camera-preference', JSON.stringify(preference));
|
|
286
|
+
this.debugLog('💾 Saved camera preference:', preference);
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
this.debugLog('⚠️ Error saving camera preference:', error);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
async switchCamera(cameraId) {
|
|
293
|
+
if (!this.isVideoActive || this.selectedCameraId === cameraId)
|
|
294
|
+
return;
|
|
295
|
+
try {
|
|
296
|
+
// Check if the selected camera is still available
|
|
297
|
+
const selectedCamera = this.availableCameras.find(cam => cam.deviceId === cameraId);
|
|
298
|
+
if (!selectedCamera) {
|
|
299
|
+
this.debugLog('❌ Selected camera not found, re-enumerating...');
|
|
300
|
+
await this.enumerateAndDetectCameras();
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
// Show loading state
|
|
304
|
+
this.statusMessage = "Cambiando cámara...";
|
|
305
|
+
this.statusColor = "#007bff";
|
|
306
|
+
// Stop current stream
|
|
307
|
+
if (this.videoStream) {
|
|
308
|
+
this.videoStream.getTracks().forEach(track => track.stop());
|
|
309
|
+
}
|
|
310
|
+
// Update selected camera
|
|
311
|
+
this.selectedCameraId = cameraId;
|
|
312
|
+
// Update facing mode preference
|
|
313
|
+
const isRearCamera = selectedCamera.label.toLowerCase().includes('back') ||
|
|
314
|
+
selectedCamera.label.toLowerCase().includes('rear') ||
|
|
315
|
+
selectedCamera.label.toLowerCase().includes('environment');
|
|
316
|
+
this.preferredCameraFacing = isRearCamera ? 'environment' : 'user';
|
|
317
|
+
// Save preference
|
|
318
|
+
this.saveCameraPreference();
|
|
319
|
+
// Setup new camera with error handling
|
|
320
|
+
await this.setupCameraWithRetry();
|
|
321
|
+
this.debugLog('🔄 Switched to camera:', selectedCamera.label);
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
this.debugLog('❌ Error switching camera:', error);
|
|
325
|
+
this.handleCameraPermissionError(error);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
async setupCameraWithRetry(maxRetries = 3) {
|
|
329
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
330
|
+
try {
|
|
331
|
+
await this.setupCamera();
|
|
332
|
+
return; // Success
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
this.debugLog(`❌ Camera setup attempt ${attempt} failed:`, error);
|
|
336
|
+
if (attempt === maxRetries) {
|
|
337
|
+
// Last attempt failed, handle the error
|
|
338
|
+
this.handleCameraPermissionError(error);
|
|
339
|
+
throw error;
|
|
340
|
+
}
|
|
341
|
+
// Wait before retrying
|
|
342
|
+
await new Promise(resolve => setTimeout(resolve, 500 * attempt));
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
toggleCameraSelector() {
|
|
347
|
+
this.showCameraSelector = !this.showCameraSelector;
|
|
348
|
+
this.debugLog('📹 Camera selector toggled:', {
|
|
349
|
+
showCameraSelector: this.showCameraSelector,
|
|
350
|
+
isMultipleCamerasAvailable: this.isMultipleCamerasAvailable,
|
|
351
|
+
availableCameras: this.availableCameras.length,
|
|
352
|
+
isVideoActive: this.isVideoActive
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
async flipCamera() {
|
|
356
|
+
if (!this.isMultipleCamerasAvailable)
|
|
357
|
+
return;
|
|
358
|
+
const currentIndex = this.availableCameras.findIndex(camera => camera.deviceId === this.selectedCameraId);
|
|
359
|
+
const nextIndex = (currentIndex + 1) % this.availableCameras.length;
|
|
360
|
+
const nextCamera = this.availableCameras[nextIndex];
|
|
361
|
+
await this.switchCamera(nextCamera.deviceId);
|
|
362
|
+
}
|
|
73
363
|
async componentDidLoad() {
|
|
364
|
+
this.validateMaskSize();
|
|
365
|
+
this.validateCropMargin();
|
|
366
|
+
this.validatePreferredCamera();
|
|
367
|
+
await this.detectDeviceTypeAndCameras();
|
|
74
368
|
if (!window.ort) {
|
|
75
369
|
const script = document.createElement('script');
|
|
76
370
|
script.src = 'https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js';
|
|
@@ -138,14 +432,15 @@ export class JaakStamps {
|
|
|
138
432
|
// Calculate what would be the max width if limited by video height
|
|
139
433
|
const maxWidthByHeight = displayedVideoHeight * this.ID1_ASPECT_RATIO;
|
|
140
434
|
let maskWidthInVideo, maskHeightInVideo;
|
|
435
|
+
const sizeRatio = this.maskSize / 100;
|
|
141
436
|
if (maxWidthByHeight <= displayedVideoWidth) {
|
|
142
437
|
// Video height is the limiting factor
|
|
143
|
-
maskHeightInVideo = displayedVideoHeight *
|
|
438
|
+
maskHeightInVideo = displayedVideoHeight * sizeRatio;
|
|
144
439
|
maskWidthInVideo = maskHeightInVideo * this.ID1_ASPECT_RATIO;
|
|
145
440
|
}
|
|
146
441
|
else {
|
|
147
442
|
// Video width is the limiting factor
|
|
148
|
-
maskWidthInVideo = displayedVideoWidth *
|
|
443
|
+
maskWidthInVideo = displayedVideoWidth * sizeRatio;
|
|
149
444
|
maskHeightInVideo = maskWidthInVideo / this.ID1_ASPECT_RATIO;
|
|
150
445
|
}
|
|
151
446
|
// Convert to percentages of the container
|
|
@@ -239,25 +534,29 @@ export class JaakStamps {
|
|
|
239
534
|
}
|
|
240
535
|
try {
|
|
241
536
|
this.isLoading = true;
|
|
242
|
-
this.statusMessage = "Precargando
|
|
537
|
+
this.statusMessage = "Precargando modelos...";
|
|
243
538
|
this.statusColor = "#007bff";
|
|
244
539
|
const modelPath = this.MODEL_PATH;
|
|
245
|
-
this.debugLog('🤖 Preloading model:', modelPath);
|
|
540
|
+
this.debugLog('🤖 Preloading detection model:', modelPath);
|
|
246
541
|
// Configure ONNX Runtime with device-specific optimizations
|
|
247
542
|
const sessionOptions = this.getSessionOptions();
|
|
248
543
|
this.session = await window.ort.InferenceSession.create(modelPath, sessionOptions);
|
|
544
|
+
// Preload MobileNet model and classes only if classification is enabled
|
|
545
|
+
if (this.useDocumentClassification) {
|
|
546
|
+
await this.loadMobileNetModel();
|
|
547
|
+
}
|
|
249
548
|
this.isModelPreloaded = true;
|
|
250
549
|
this.isLoading = false;
|
|
251
|
-
this.statusMessage = "
|
|
550
|
+
this.statusMessage = "Modelos precargados. Listo para comenzar detección";
|
|
252
551
|
this.statusColor = "#28a745";
|
|
253
552
|
this.emitReadyEvent();
|
|
254
|
-
this.debugLog('✅
|
|
255
|
-
return { success: true, message: '
|
|
553
|
+
this.debugLog('✅ Models preloaded successfully');
|
|
554
|
+
return { success: true, message: 'Models preloaded successfully' };
|
|
256
555
|
}
|
|
257
556
|
catch (error) {
|
|
258
|
-
this.debugLog('❌ Error preloading
|
|
557
|
+
this.debugLog('❌ Error preloading models:', error);
|
|
259
558
|
this.isLoading = false;
|
|
260
|
-
this.statusMessage = "Error al precargar
|
|
559
|
+
this.statusMessage = "Error al precargar los modelos";
|
|
261
560
|
this.statusColor = "#ff6b6b";
|
|
262
561
|
return { success: false, error: error.message };
|
|
263
562
|
}
|
|
@@ -267,6 +566,109 @@ export class JaakStamps {
|
|
|
267
566
|
this.completeProcess(true);
|
|
268
567
|
}
|
|
269
568
|
}
|
|
569
|
+
async getCameraInfo() {
|
|
570
|
+
return {
|
|
571
|
+
availableCameras: this.availableCameras.map(camera => ({
|
|
572
|
+
id: camera.deviceId,
|
|
573
|
+
label: camera.label || 'Unknown Camera',
|
|
574
|
+
selected: camera.deviceId === this.selectedCameraId
|
|
575
|
+
})),
|
|
576
|
+
selectedCameraId: this.selectedCameraId,
|
|
577
|
+
deviceType: this.deviceType,
|
|
578
|
+
isMultipleCamerasAvailable: this.isMultipleCamerasAvailable,
|
|
579
|
+
preferredFacing: this.preferredCameraFacing,
|
|
580
|
+
userPreferredCamera: this.preferredCamera
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
async setPreferredCamera(camera) {
|
|
584
|
+
this.preferredCamera = camera;
|
|
585
|
+
this.debugLog('🎯 Camera preference changed to:', camera);
|
|
586
|
+
// Re-detect and apply new camera preference
|
|
587
|
+
await this.enumerateAndDetectCameras();
|
|
588
|
+
// If video is active, switch to the new preferred camera
|
|
589
|
+
if (this.isVideoActive && this.selectedCameraId) {
|
|
590
|
+
await this.switchCamera(this.selectedCameraId);
|
|
591
|
+
}
|
|
592
|
+
return {
|
|
593
|
+
success: true,
|
|
594
|
+
selectedCamera: this.selectedCameraId,
|
|
595
|
+
availableCameras: this.availableCameras.length
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
async loadMobileNetModel() {
|
|
599
|
+
try {
|
|
600
|
+
this.debugLog('🤖 Loading MobileNet model...');
|
|
601
|
+
// Load class map
|
|
602
|
+
const classResponse = await fetch(this.MOBILENET_CLASSES_PATH);
|
|
603
|
+
if (!classResponse.ok) {
|
|
604
|
+
throw new Error(`Failed to load class map: ${this.MOBILENET_CLASSES_PATH}`);
|
|
605
|
+
}
|
|
606
|
+
this.mobileNetClassMap = await classResponse.json();
|
|
607
|
+
this.debugLog('📋 MobileNet classes loaded:', this.mobileNetClassMap);
|
|
608
|
+
// Load model
|
|
609
|
+
const sessionOptions = this.getSessionOptions();
|
|
610
|
+
this.mobileNetSession = await window.ort.InferenceSession.create(this.MOBILENET_MODEL_PATH, sessionOptions);
|
|
611
|
+
this.debugLog('✅ MobileNet model loaded successfully');
|
|
612
|
+
}
|
|
613
|
+
catch (error) {
|
|
614
|
+
this.debugLog('❌ Error loading MobileNet model:', error);
|
|
615
|
+
throw error;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
preprocessMobileNet(canvas) {
|
|
619
|
+
// Create a temporary canvas for MobileNet preprocessing (224x224)
|
|
620
|
+
const tempCanvas = document.createElement('canvas');
|
|
621
|
+
tempCanvas.width = 224;
|
|
622
|
+
tempCanvas.height = 224;
|
|
623
|
+
const tempCtx = tempCanvas.getContext('2d');
|
|
624
|
+
// Draw the cropped image onto the 224x224 canvas
|
|
625
|
+
tempCtx.drawImage(canvas, 0, 0, 224, 224);
|
|
626
|
+
// Get image data and preprocess for MobileNet
|
|
627
|
+
const imageData = tempCtx.getImageData(0, 0, 224, 224);
|
|
628
|
+
const data = imageData.data;
|
|
629
|
+
const hw = 224 * 224;
|
|
630
|
+
const arr = new Float32Array(3 * hw);
|
|
631
|
+
// Normalize pixels: (pixel/255 - 0.5) / 0.5 = (pixel - 127.5) / 127.5
|
|
632
|
+
for (let i = 0; i < hw; i++) {
|
|
633
|
+
arr[i] = (data[i * 4 + 0] / 255 - 0.5) / 0.5; // R
|
|
634
|
+
arr[hw + i] = (data[i * 4 + 1] / 255 - 0.5) / 0.5; // G
|
|
635
|
+
arr[2 * hw + i] = (data[i * 4 + 2] / 255 - 0.5) / 0.5; // B
|
|
636
|
+
}
|
|
637
|
+
return new window.ort.Tensor('float32', arr, [1, 3, 224, 224]);
|
|
638
|
+
}
|
|
639
|
+
async classifyDocument(canvas) {
|
|
640
|
+
if (!this.mobileNetSession || !this.mobileNetClassMap) {
|
|
641
|
+
this.debugLog('⚠️ MobileNet model not loaded');
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
try {
|
|
645
|
+
this.debugLog('🔍 Classifying document...');
|
|
646
|
+
// Preprocess image for MobileNet
|
|
647
|
+
const inputTensor = this.preprocessMobileNet(canvas);
|
|
648
|
+
// Run inference
|
|
649
|
+
const feeds = { input: inputTensor };
|
|
650
|
+
const results = await this.mobileNetSession.run(feeds);
|
|
651
|
+
const output = results[Object.keys(results)[0]].data;
|
|
652
|
+
// Find the class with highest confidence
|
|
653
|
+
const maxIdx = output.reduce((bestIdx, val, idx, arr) => val > arr[bestIdx] ? idx : bestIdx, 0);
|
|
654
|
+
const confidence = output[maxIdx];
|
|
655
|
+
const className = this.mobileNetClassMap[maxIdx.toString()] || "unknown";
|
|
656
|
+
this.debugLog('📄 Document classification result:', {
|
|
657
|
+
class: className,
|
|
658
|
+
confidence: confidence.toFixed(3),
|
|
659
|
+
classIndex: maxIdx
|
|
660
|
+
});
|
|
661
|
+
return {
|
|
662
|
+
class: className,
|
|
663
|
+
confidence: confidence,
|
|
664
|
+
classIndex: maxIdx
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
catch (error) {
|
|
668
|
+
this.debugLog('❌ Error classifying document:', error);
|
|
669
|
+
return null;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
270
672
|
cleanup() {
|
|
271
673
|
if (this.animationId) {
|
|
272
674
|
cancelAnimationFrame(this.animationId);
|
|
@@ -294,28 +696,53 @@ export class JaakStamps {
|
|
|
294
696
|
this.captureCtx = undefined;
|
|
295
697
|
this.captureCanvas = undefined;
|
|
296
698
|
}
|
|
297
|
-
// Disposed ONNX
|
|
699
|
+
// Disposed ONNX sessions
|
|
298
700
|
if (this.session) {
|
|
299
701
|
this.session.release?.();
|
|
300
702
|
this.session = undefined;
|
|
301
703
|
}
|
|
704
|
+
if (this.mobileNetSession) {
|
|
705
|
+
this.mobileNetSession.release?.();
|
|
706
|
+
this.mobileNetSession = undefined;
|
|
707
|
+
}
|
|
708
|
+
this.mobileNetClassMap = undefined;
|
|
302
709
|
this.isModelPreloaded = false;
|
|
303
710
|
this.debugLog('🧹 Canvas pool cleaned up');
|
|
304
711
|
}
|
|
305
712
|
async getMaxResolution() {
|
|
306
713
|
try {
|
|
307
|
-
//
|
|
714
|
+
// Build constraints with selected camera if available
|
|
715
|
+
const videoConstraints = {};
|
|
716
|
+
if (this.selectedCameraId) {
|
|
717
|
+
videoConstraints.deviceId = { exact: this.selectedCameraId };
|
|
718
|
+
}
|
|
719
|
+
else if (this.preferredCameraFacing) {
|
|
720
|
+
videoConstraints.facingMode = this.preferredCameraFacing;
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
videoConstraints.facingMode = "environment";
|
|
724
|
+
}
|
|
725
|
+
// Get temporary stream to access capabilities
|
|
308
726
|
const tempStream = await navigator.mediaDevices.getUserMedia({
|
|
309
|
-
video:
|
|
727
|
+
video: videoConstraints
|
|
310
728
|
});
|
|
311
729
|
const videoTrack = tempStream.getVideoTracks()[0];
|
|
312
730
|
const capabilities = videoTrack.getCapabilities();
|
|
313
731
|
// Detener el stream temporal
|
|
314
732
|
tempStream.getTracks().forEach(track => track.stop());
|
|
315
|
-
//
|
|
316
|
-
const constraints = {
|
|
317
|
-
|
|
318
|
-
|
|
733
|
+
// Build constraints with resolution optimized for tablets
|
|
734
|
+
const constraints = {};
|
|
735
|
+
// Set camera selection constraints
|
|
736
|
+
if (this.selectedCameraId) {
|
|
737
|
+
constraints.deviceId = { exact: this.selectedCameraId };
|
|
738
|
+
}
|
|
739
|
+
else if (this.preferredCameraFacing) {
|
|
740
|
+
constraints.facingMode = this.preferredCameraFacing;
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
constraints.facingMode = "environment";
|
|
744
|
+
}
|
|
745
|
+
;
|
|
319
746
|
if (capabilities.width && capabilities.height) {
|
|
320
747
|
// Limitar resolución máxima para tablets para evitar problemas de rendimiento
|
|
321
748
|
const maxWidth = Math.min(capabilities.width.max, 1920);
|
|
@@ -342,13 +769,23 @@ export class JaakStamps {
|
|
|
342
769
|
}
|
|
343
770
|
catch (err) {
|
|
344
771
|
this.debugLog('⚠️ Could not get capabilities, using fallback');
|
|
345
|
-
//
|
|
772
|
+
// Optimized fallback for tablets
|
|
346
773
|
const isTablet = /iPad|Android/i.test(navigator.userAgent) && window.innerWidth >= 768;
|
|
347
|
-
|
|
348
|
-
facingMode: "environment",
|
|
774
|
+
const fallbackConstraints = {
|
|
349
775
|
width: { ideal: isTablet ? 1280 : 1920 },
|
|
350
776
|
height: { ideal: isTablet ? 720 : 1080 }
|
|
351
777
|
};
|
|
778
|
+
// Add camera selection to fallback
|
|
779
|
+
if (this.selectedCameraId) {
|
|
780
|
+
fallbackConstraints.deviceId = { exact: this.selectedCameraId };
|
|
781
|
+
}
|
|
782
|
+
else if (this.preferredCameraFacing) {
|
|
783
|
+
fallbackConstraints.facingMode = this.preferredCameraFacing;
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
fallbackConstraints.facingMode = "environment";
|
|
787
|
+
}
|
|
788
|
+
return fallbackConstraints;
|
|
352
789
|
}
|
|
353
790
|
}
|
|
354
791
|
async setupCamera() {
|
|
@@ -383,8 +820,7 @@ export class JaakStamps {
|
|
|
383
820
|
}
|
|
384
821
|
catch (err) {
|
|
385
822
|
this.debugLog("❌ No se pudo acceder a la cámara:", err);
|
|
386
|
-
this.
|
|
387
|
-
this.statusColor = "#ff6b6b";
|
|
823
|
+
this.handleCameraPermissionError(err);
|
|
388
824
|
}
|
|
389
825
|
}
|
|
390
826
|
preprocess(video) {
|
|
@@ -429,18 +865,22 @@ export class JaakStamps {
|
|
|
429
865
|
// Check if model is already preloaded
|
|
430
866
|
if (!this.session) {
|
|
431
867
|
this.isLoading = true;
|
|
432
|
-
this.statusMessage = "Cargando
|
|
868
|
+
this.statusMessage = "Cargando modelos...";
|
|
433
869
|
this.statusColor = "#007bff";
|
|
434
870
|
const modelPath = this.MODEL_PATH;
|
|
435
|
-
this.debugLog('🤖 Loading model:', modelPath);
|
|
871
|
+
this.debugLog('🤖 Loading detection model:', modelPath);
|
|
436
872
|
const sessionOptions = this.getSessionOptions();
|
|
437
873
|
this.session = await window.ort.InferenceSession.create(modelPath, sessionOptions);
|
|
874
|
+
// Load MobileNet model if classification is enabled and not already loaded
|
|
875
|
+
if (this.useDocumentClassification && !this.mobileNetSession) {
|
|
876
|
+
await this.loadMobileNetModel();
|
|
877
|
+
}
|
|
438
878
|
this.isModelPreloaded = true;
|
|
439
879
|
this.emitReadyEvent();
|
|
440
880
|
}
|
|
441
881
|
else {
|
|
442
|
-
this.debugLog('🚀 Using preloaded
|
|
443
|
-
this.statusMessage = "Usando
|
|
882
|
+
this.debugLog('🚀 Using preloaded models');
|
|
883
|
+
this.statusMessage = "Usando modelos precargados...";
|
|
444
884
|
this.statusColor = "#007bff";
|
|
445
885
|
}
|
|
446
886
|
this.statusMessage = "Configurando cámara...";
|
|
@@ -583,14 +1023,15 @@ export class JaakStamps {
|
|
|
583
1023
|
// Calculate mask dimensions using the same logic as updateMaskDimensions
|
|
584
1024
|
const maxWidthByHeight = displayedVideoHeight * this.ID1_ASPECT_RATIO;
|
|
585
1025
|
let visualMaskWidth, visualMaskHeight;
|
|
1026
|
+
const sizeRatio = this.maskSize / 100;
|
|
586
1027
|
if (maxWidthByHeight <= displayedVideoWidth) {
|
|
587
1028
|
// Video height is the limiting factor
|
|
588
|
-
visualMaskHeight = displayedVideoHeight *
|
|
1029
|
+
visualMaskHeight = displayedVideoHeight * sizeRatio;
|
|
589
1030
|
visualMaskWidth = visualMaskHeight * this.ID1_ASPECT_RATIO;
|
|
590
1031
|
}
|
|
591
1032
|
else {
|
|
592
1033
|
// Video width is the limiting factor
|
|
593
|
-
visualMaskWidth = displayedVideoWidth *
|
|
1034
|
+
visualMaskWidth = displayedVideoWidth * sizeRatio;
|
|
594
1035
|
visualMaskHeight = visualMaskWidth / this.ID1_ASPECT_RATIO;
|
|
595
1036
|
}
|
|
596
1037
|
// Now map these visual mask dimensions to the distorted model space
|
|
@@ -658,7 +1099,9 @@ export class JaakStamps {
|
|
|
658
1099
|
corners?.forEach(corner => corner.classList.add('perfect-match'));
|
|
659
1100
|
if (!this.hasScreenshotTaken) {
|
|
660
1101
|
this.lastDetectedBox = bestBox;
|
|
661
|
-
this.takeScreenshot()
|
|
1102
|
+
this.takeScreenshot().catch(error => {
|
|
1103
|
+
this.debugLog('❌ Error taking screenshot:', error);
|
|
1104
|
+
});
|
|
662
1105
|
this.hasScreenshotTaken = true;
|
|
663
1106
|
// Reset para permitir segunda captura
|
|
664
1107
|
setTimeout(() => {
|
|
@@ -741,7 +1184,7 @@ export class JaakStamps {
|
|
|
741
1184
|
ctx.strokeRect(x, y, w, h);
|
|
742
1185
|
});
|
|
743
1186
|
}
|
|
744
|
-
takeScreenshot() {
|
|
1187
|
+
async takeScreenshot() {
|
|
745
1188
|
if (!this.videoRef || !this.lastDetectedBox)
|
|
746
1189
|
return;
|
|
747
1190
|
// Activar animación
|
|
@@ -757,10 +1200,10 @@ export class JaakStamps {
|
|
|
757
1200
|
// Calcular las coordenadas de recorte basadas en la detección
|
|
758
1201
|
const scaleX = this.videoRef.videoWidth / this.INPUT_SIZE;
|
|
759
1202
|
const scaleY = this.videoRef.videoHeight / this.INPUT_SIZE;
|
|
760
|
-
const cropX = Math.max(0, this.lastDetectedBox.x * scaleX);
|
|
761
|
-
const cropY = Math.max(0, this.lastDetectedBox.y * scaleY);
|
|
762
|
-
const cropWidth = Math.min(this.lastDetectedBox.w * scaleX, this.videoRef.videoWidth - cropX);
|
|
763
|
-
const cropHeight = Math.min(this.lastDetectedBox.h * scaleY, this.videoRef.videoHeight - cropY);
|
|
1203
|
+
const cropX = Math.max(0, (this.lastDetectedBox.x * scaleX) - this.cropMargin);
|
|
1204
|
+
const cropY = Math.max(0, (this.lastDetectedBox.y * scaleY) - this.cropMargin);
|
|
1205
|
+
const cropWidth = Math.min((this.lastDetectedBox.w * scaleX) + (2 * this.cropMargin), this.videoRef.videoWidth - cropX);
|
|
1206
|
+
const cropHeight = Math.min((this.lastDetectedBox.h * scaleY) + (2 * this.cropMargin), this.videoRef.videoHeight - cropY);
|
|
764
1207
|
// OPTIMIZATION: Create temporary canvas only for cropped version
|
|
765
1208
|
// (We reuse main capture canvas for full frame)
|
|
766
1209
|
const croppedCanvas = document.createElement('canvas');
|
|
@@ -775,6 +1218,29 @@ export class JaakStamps {
|
|
|
775
1218
|
// Captura del frente usando canvas reutilizado
|
|
776
1219
|
this.capturedFullFrame = this.captureCanvas.toDataURL('image/png');
|
|
777
1220
|
this.capturedCroppedId = croppedCanvas.toDataURL('image/png');
|
|
1221
|
+
// Check if document classification is enabled
|
|
1222
|
+
if (this.useDocumentClassification) {
|
|
1223
|
+
// Load MobileNet model if not loaded yet (lazy loading)
|
|
1224
|
+
if (!this.mobileNetSession) {
|
|
1225
|
+
try {
|
|
1226
|
+
await this.loadMobileNetModel();
|
|
1227
|
+
}
|
|
1228
|
+
catch (error) {
|
|
1229
|
+
this.debugLog('⚠️ Failed to load classification model, continuing without classification:', error);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
// Classify the cropped document if model is available
|
|
1233
|
+
if (this.mobileNetSession) {
|
|
1234
|
+
const classification = await this.classifyDocument(croppedCanvas);
|
|
1235
|
+
if (classification && classification.class === 'passport') {
|
|
1236
|
+
// If it's a passport, skip back capture since passports don't have a back side
|
|
1237
|
+
this.debugLog('📄 Passport detected - skipping back capture');
|
|
1238
|
+
this.completeProcess(true);
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
// For other IDs, continue with normal flow (back capture)
|
|
778
1244
|
this.captureStep = 'back';
|
|
779
1245
|
this.statusMessage = "Voltee la identificación y muestre la parte trasera";
|
|
780
1246
|
this.statusColor = "#007bff";
|
|
@@ -904,7 +1370,20 @@ export class JaakStamps {
|
|
|
904
1370
|
this.cleanup();
|
|
905
1371
|
}
|
|
906
1372
|
render() {
|
|
907
|
-
return (h("div", { key: '
|
|
1373
|
+
return (h("div", { key: 'b90673f523dbf112786eb7184f56415055765c0c', class: "detector-container" }, h("div", { key: '925c5c886e9af53b460281244958e722de670a70', class: "video-container" }, h("video", { key: '4a0074e33a81b4694c6c99e3ece256c1ac8fe1d5', ref: el => this.videoRef = el, autoplay: true, muted: true, playsinline: true, class: this.shouldMirrorVideo ? 'mirror' : '', style: { display: this.isVideoActive ? 'block' : 'none' } }), h("canvas", { key: 'a7b7f3b35c0535c11f6a4a155502dbe016f590b7', ref: el => this.canvasRef = el, class: this.shouldMirrorVideo ? 'mirror' : '' }), this.isMaskReady && (h("div", { key: '695b6a2f97e29b0b9c5b9d43682a951caff376a1', class: "overlay-mask" }, h("div", { key: '768875c39d5917c6a04306037d03d9e1aed114bd', class: "card-outline" }, h("div", { key: 'a56536deb7b8c99145d1bef6fee84e5801798644', class: "side side-top" }), h("div", { key: 'df413058c7e787f9c8a95a429a4f7186de07f5f6', class: "side side-right" }), h("div", { key: '37e074e3d4c914457f97720f9ab1f1ac2c70c4f1', class: "side side-bottom" }), h("div", { key: '772d3d40925c75ba5d39e2e7dd6405f7cc88d292', class: "side side-left" }), h("div", { key: 'd4e624782b3f4b4b8dbb8286b3acf003e433928c', class: "corner corner-tl" }), h("div", { key: '63f0ccfbbe3c1d413ca6912f36cab4afa6334bb2', class: "corner corner-tr" }), h("div", { key: '20012a50fe3d98ddfa669f5283a871c757522797', class: "corner corner-bl" }), h("div", { key: '9d82646bd08a6ca2b8c5782629fc68fd93cf1287', class: "corner corner-br" }), !this.showFlipAnimation && !this.showSuccessAnimation && (h("div", { key: '79fcbdb52e434a45aa6f2748d6d84500beb2e844', class: "guide-text" }, this.statusMessage))), this.captureStep === 'back' && !this.showFlipAnimation && !this.showSuccessAnimation && (h("button", { key: '16e587d645e2489a3410fe80bfc014738f08f02f', class: "skip-button", onClick: () => this.skipBackCapture(), type: "button" }, "Saltar reverso")), this.isVideoActive && (h("div", { key: 'd46d6881a9e1b63bdd849f5a8c6e96a2caefdefb', class: "camera-controls" }, this.isMultipleCamerasAvailable && (h("button", { key: 'afb4b44d691471f8af6e894e061aecb6c82259da', class: "flip-camera-button", onClick: () => this.flipCamera(), type: "button", title: "Cambiar c\u00E1mara" }, "Girar c\u00E1mara")), h("button", { key: '4e0680c2da9e6cc70b5880e8f5db9830c080acf9', class: "camera-selector-button", onClick: () => this.toggleCameraSelector(), type: "button", title: "Seleccionar c\u00E1mara" }, "C\u00E1maras"), this.debug && (h("div", { key: 'fc59922452a216273f742d3158559f6b2a1da43e', style: {
|
|
1374
|
+
position: 'absolute',
|
|
1375
|
+
top: '50px',
|
|
1376
|
+
right: '0',
|
|
1377
|
+
background: 'rgba(0,0,0,0.8)',
|
|
1378
|
+
color: 'white',
|
|
1379
|
+
padding: '8px',
|
|
1380
|
+
fontSize: '10px',
|
|
1381
|
+
borderRadius: '4px',
|
|
1382
|
+
whiteSpace: 'nowrap'
|
|
1383
|
+
} }, "C\u00E1maras: ", this.availableCameras.length, h("br", { key: '8f112283d1e0518a395dc6d94e1caa46fee0a86b' }), "M\u00FAltiples: ", this.isMultipleCamerasAvailable ? 'Sí' : 'No', h("br", { key: 'aacfd3ee868ee5d0819ce5ef693e3ef384867332' }), "Selector: ", this.showCameraSelector ? 'Visible' : 'Oculto', h("br", { key: '9927df7f56583c7388cee25e13526efc7e032eb1' }), "Video: ", this.isVideoActive ? 'Activo' : 'Inactivo')))), this.showCameraSelector && this.availableCameras.length > 0 && (h("div", { key: 'c2914bf7f3175b8f0ddab977abbdefe3022d7d29', class: "camera-selector-dropdown" }, h("div", { key: '0b5397e77ff33944f3620d78b1ab41275dffd7ac', class: "camera-selector-header" }, h("span", { key: '78f0fb8e34a0cf2d16138522a98cbdb9eefd671f' }, "Seleccionar C\u00E1mara"), h("button", { key: '0d4ea7b191d61d1d9b9c35462ce336148be73fcb', class: "close-selector", onClick: () => this.toggleCameraSelector(), type: "button" }, "\u00D7")), h("div", { key: 'c16c7a106493ef7633a4cd35b06a4f45327a2e23', class: "camera-list" }, this.availableCameras.map((camera) => (h("button", { key: camera.deviceId, class: `camera-option ${this.selectedCameraId === camera.deviceId ? 'selected' : ''}`, onClick: () => {
|
|
1384
|
+
this.switchCamera(camera.deviceId);
|
|
1385
|
+
this.toggleCameraSelector();
|
|
1386
|
+
}, type: "button" }, h("span", { class: "camera-label" }, camera.label || `Cámara ${this.availableCameras.indexOf(camera) + 1}`), this.selectedCameraId === camera.deviceId && (h("span", { class: "selected-indicator" }, "\u2713")))))), h("div", { key: '11d6f980c3995a8414da5f7e6921f963ca72aed4', class: "device-info" }, h("small", { key: '78f5ff030f9e6e5021234a246599eb459b05d9f7' }, "Dispositivo: ", this.deviceType)))))), this.isCapturing && (h("div", { key: 'ef7d32491d8bdb94b2d6456420c2ddbc80f03d81', class: "capture-animation" })), this.showFlipAnimation && (h("div", { key: 'cfb5868ee75a9d1d1604c52f6fce1241090e4ac2', class: "flip-animation" }, h("div", { key: '1b41035e63f88434aba6699d4e68e06bea2c1529', class: "id-card-icon" }), h("div", { key: '4e83af9d0d39ce37b7448c4a0783b60b42b858e2', class: "flip-text" }, "\u00A1Voltea tu identificaci\u00F3n!"))), this.showSuccessAnimation && (h("div", { key: 'c7911e8be74b0fc7d7d18d7dcb52374645ca5f12', class: "success-animation" }, h("div", { key: '18e5ea5cfa3eb35fe3b99c12e6fab8e27e09e85e', class: "check-icon" }), h("div", { key: '490d8fcd6540c3b4fdc95f7fb5e6f6697722c9ac', class: "success-text" }, "\u00A1Proceso completado!"))), this.isLoading && (h("div", { key: 'f7fbfec6be2d8e0dc4e522b85b7d67897575cf0e', class: "loading-overlay" }, h("div", { key: '8282b92f19da6a9c7d22a64a0929b2b4d67c46be', class: "loading-spinner" }), h("div", { key: '7880b689297eb9d80a9b0023ba7933148fd8710a', class: "loading-text" }, this.statusMessage))), h("div", { key: '887c951fb03097171d9bd466fe24e36d11a49954', class: "watermark" }, h("img", { key: '314c9c172a4c6795c825741ea6f02b0e1186e93d', src: "https://storage.googleapis.com/jaak-static/commons/powered-by-jaak.png", alt: "Powered by Jaak" })))));
|
|
908
1387
|
}
|
|
909
1388
|
static get is() { return "jaak-stamps"; }
|
|
910
1389
|
static get encapsulation() { return "shadow"; }
|
|
@@ -959,6 +1438,86 @@ export class JaakStamps {
|
|
|
959
1438
|
"setter": false,
|
|
960
1439
|
"reflect": false,
|
|
961
1440
|
"defaultValue": "10"
|
|
1441
|
+
},
|
|
1442
|
+
"maskSize": {
|
|
1443
|
+
"type": "number",
|
|
1444
|
+
"attribute": "mask-size",
|
|
1445
|
+
"mutable": false,
|
|
1446
|
+
"complexType": {
|
|
1447
|
+
"original": "number",
|
|
1448
|
+
"resolved": "number",
|
|
1449
|
+
"references": {}
|
|
1450
|
+
},
|
|
1451
|
+
"required": false,
|
|
1452
|
+
"optional": false,
|
|
1453
|
+
"docs": {
|
|
1454
|
+
"tags": [],
|
|
1455
|
+
"text": ""
|
|
1456
|
+
},
|
|
1457
|
+
"getter": false,
|
|
1458
|
+
"setter": false,
|
|
1459
|
+
"reflect": false,
|
|
1460
|
+
"defaultValue": "90"
|
|
1461
|
+
},
|
|
1462
|
+
"cropMargin": {
|
|
1463
|
+
"type": "number",
|
|
1464
|
+
"attribute": "crop-margin",
|
|
1465
|
+
"mutable": false,
|
|
1466
|
+
"complexType": {
|
|
1467
|
+
"original": "number",
|
|
1468
|
+
"resolved": "number",
|
|
1469
|
+
"references": {}
|
|
1470
|
+
},
|
|
1471
|
+
"required": false,
|
|
1472
|
+
"optional": false,
|
|
1473
|
+
"docs": {
|
|
1474
|
+
"tags": [],
|
|
1475
|
+
"text": ""
|
|
1476
|
+
},
|
|
1477
|
+
"getter": false,
|
|
1478
|
+
"setter": false,
|
|
1479
|
+
"reflect": false,
|
|
1480
|
+
"defaultValue": "0"
|
|
1481
|
+
},
|
|
1482
|
+
"useDocumentClassification": {
|
|
1483
|
+
"type": "boolean",
|
|
1484
|
+
"attribute": "use-document-classification",
|
|
1485
|
+
"mutable": false,
|
|
1486
|
+
"complexType": {
|
|
1487
|
+
"original": "boolean",
|
|
1488
|
+
"resolved": "boolean",
|
|
1489
|
+
"references": {}
|
|
1490
|
+
},
|
|
1491
|
+
"required": false,
|
|
1492
|
+
"optional": false,
|
|
1493
|
+
"docs": {
|
|
1494
|
+
"tags": [],
|
|
1495
|
+
"text": ""
|
|
1496
|
+
},
|
|
1497
|
+
"getter": false,
|
|
1498
|
+
"setter": false,
|
|
1499
|
+
"reflect": false,
|
|
1500
|
+
"defaultValue": "false"
|
|
1501
|
+
},
|
|
1502
|
+
"preferredCamera": {
|
|
1503
|
+
"type": "string",
|
|
1504
|
+
"attribute": "preferred-camera",
|
|
1505
|
+
"mutable": false,
|
|
1506
|
+
"complexType": {
|
|
1507
|
+
"original": "'auto' | 'front' | 'back'",
|
|
1508
|
+
"resolved": "\"auto\" | \"back\" | \"front\"",
|
|
1509
|
+
"references": {}
|
|
1510
|
+
},
|
|
1511
|
+
"required": false,
|
|
1512
|
+
"optional": false,
|
|
1513
|
+
"docs": {
|
|
1514
|
+
"tags": [],
|
|
1515
|
+
"text": ""
|
|
1516
|
+
},
|
|
1517
|
+
"getter": false,
|
|
1518
|
+
"setter": false,
|
|
1519
|
+
"reflect": false,
|
|
1520
|
+
"defaultValue": "'auto'"
|
|
962
1521
|
}
|
|
963
1522
|
};
|
|
964
1523
|
}
|
|
@@ -981,7 +1540,11 @@ export class JaakStamps {
|
|
|
981
1540
|
"isDetectionPaused": {},
|
|
982
1541
|
"isLoading": {},
|
|
983
1542
|
"isModelPreloaded": {},
|
|
984
|
-
"isMaskReady": {}
|
|
1543
|
+
"isMaskReady": {},
|
|
1544
|
+
"availableCameras": {},
|
|
1545
|
+
"selectedCameraId": {},
|
|
1546
|
+
"showCameraSelector": {},
|
|
1547
|
+
"isMultipleCamerasAvailable": {}
|
|
985
1548
|
};
|
|
986
1549
|
}
|
|
987
1550
|
static get events() {
|
|
@@ -1154,6 +1717,44 @@ export class JaakStamps {
|
|
|
1154
1717
|
"text": "",
|
|
1155
1718
|
"tags": []
|
|
1156
1719
|
}
|
|
1720
|
+
},
|
|
1721
|
+
"getCameraInfo": {
|
|
1722
|
+
"complexType": {
|
|
1723
|
+
"signature": "() => Promise<{ availableCameras: { id: string; label: string; selected: boolean; }[]; selectedCameraId: string; deviceType: \"mobile\" | \"desktop\" | \"tablet\"; isMultipleCamerasAvailable: boolean; preferredFacing: \"environment\" | \"user\"; userPreferredCamera: \"auto\" | \"front\" | \"back\"; }>",
|
|
1724
|
+
"parameters": [],
|
|
1725
|
+
"references": {
|
|
1726
|
+
"Promise": {
|
|
1727
|
+
"location": "global",
|
|
1728
|
+
"id": "global::Promise"
|
|
1729
|
+
}
|
|
1730
|
+
},
|
|
1731
|
+
"return": "Promise<{ availableCameras: { id: string; label: string; selected: boolean; }[]; selectedCameraId: string; deviceType: \"mobile\" | \"desktop\" | \"tablet\"; isMultipleCamerasAvailable: boolean; preferredFacing: \"environment\" | \"user\"; userPreferredCamera: \"auto\" | \"front\" | \"back\"; }>"
|
|
1732
|
+
},
|
|
1733
|
+
"docs": {
|
|
1734
|
+
"text": "",
|
|
1735
|
+
"tags": []
|
|
1736
|
+
}
|
|
1737
|
+
},
|
|
1738
|
+
"setPreferredCamera": {
|
|
1739
|
+
"complexType": {
|
|
1740
|
+
"signature": "(camera: \"auto\" | \"front\" | \"back\") => Promise<{ success: boolean; selectedCamera: string; availableCameras: number; }>",
|
|
1741
|
+
"parameters": [{
|
|
1742
|
+
"name": "camera",
|
|
1743
|
+
"type": "\"auto\" | \"front\" | \"back\"",
|
|
1744
|
+
"docs": ""
|
|
1745
|
+
}],
|
|
1746
|
+
"references": {
|
|
1747
|
+
"Promise": {
|
|
1748
|
+
"location": "global",
|
|
1749
|
+
"id": "global::Promise"
|
|
1750
|
+
}
|
|
1751
|
+
},
|
|
1752
|
+
"return": "Promise<{ success: boolean; selectedCamera: string; availableCameras: number; }>"
|
|
1753
|
+
},
|
|
1754
|
+
"docs": {
|
|
1755
|
+
"text": "",
|
|
1756
|
+
"tags": []
|
|
1757
|
+
}
|
|
1157
1758
|
}
|
|
1158
1759
|
};
|
|
1159
1760
|
}
|