@jaak.ai/stamps 2.0.0-beta.3 → 2.0.0-dev.17
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 +19 -104
- package/dist/cjs/{index-BfhtOB0D.js → index-DGM9-FNg.js} +2 -5
- package/dist/cjs/index-DGM9-FNg.js.map +1 -0
- package/dist/cjs/jaak-stamps-webcomponent.cjs.js +2 -2
- package/dist/cjs/jaak-stamps.cjs.entry.js +39 -749
- 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 +7 -237
- package/dist/collection/components/my-component/my-component.js +38 -886
- package/dist/collection/components/my-component/my-component.js.map +1 -1
- package/dist/components/index.js +0 -3
- package/dist/components/index.js.map +1 -1
- package/dist/components/jaak-stamps.js +39 -760
- package/dist/components/jaak-stamps.js.map +1 -1
- package/dist/esm/{index-BP1Q4KOg.js → index-DqoVMnc7.js} +2 -5
- package/dist/esm/index-DqoVMnc7.js.map +1 -0
- package/dist/esm/jaak-stamps-webcomponent.js +3 -3
- package/dist/esm/jaak-stamps.entry.js +39 -749
- 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-45dcdc80.entry.js +2 -0
- package/dist/jaak-stamps-webcomponent/p-45dcdc80.entry.js.map +1 -0
- package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js +3 -0
- package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js.map +1 -0
- package/dist/types/components/my-component/my-component.d.ts +2 -56
- package/dist/types/components.d.ts +0 -36
- package/package.json +1 -1
- package/dist/cjs/index-BfhtOB0D.js.map +0 -1
- package/dist/esm/index-BP1Q4KOg.js.map +0 -1
- package/dist/jaak-stamps-webcomponent/p-14eb13d8.entry.js +0 -2
- package/dist/jaak-stamps-webcomponent/p-14eb13d8.entry.js.map +0 -1
- package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js +0 -3
- package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js.map +0 -1
|
@@ -3,12 +3,7 @@ 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)
|
|
10
6
|
captureCompleted;
|
|
11
|
-
isReady;
|
|
12
7
|
isVideoActive = false;
|
|
13
8
|
statusMessage = 'Presione el botón para activar la cámara';
|
|
14
9
|
statusColor = '#aaa';
|
|
@@ -31,11 +26,6 @@ export class JaakStamps {
|
|
|
31
26
|
isDetectionPaused = false;
|
|
32
27
|
isLoading = false;
|
|
33
28
|
isModelPreloaded = false;
|
|
34
|
-
isMaskReady = false;
|
|
35
|
-
availableCameras = [];
|
|
36
|
-
selectedCameraId = null;
|
|
37
|
-
showCameraSelector = false;
|
|
38
|
-
isMultipleCamerasAvailable = false;
|
|
39
29
|
videoRef;
|
|
40
30
|
canvasRef;
|
|
41
31
|
session;
|
|
@@ -44,11 +34,6 @@ export class JaakStamps {
|
|
|
44
34
|
animationId;
|
|
45
35
|
hasScreenshotTaken = false;
|
|
46
36
|
lastDetectedBox;
|
|
47
|
-
mobileNetSession;
|
|
48
|
-
mobileNetClassMap;
|
|
49
|
-
// Camera management properties
|
|
50
|
-
deviceType = 'desktop';
|
|
51
|
-
preferredCameraFacing = null;
|
|
52
37
|
// Performance optimization properties
|
|
53
38
|
frameSkipCounter = 0;
|
|
54
39
|
FRAME_SKIP = 2; // Process every 3rd frame (reduces CPU by ~66%)
|
|
@@ -61,42 +46,16 @@ export class JaakStamps {
|
|
|
61
46
|
preprocessCtx;
|
|
62
47
|
captureCanvas;
|
|
63
48
|
captureCtx;
|
|
64
|
-
MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/
|
|
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";
|
|
49
|
+
MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/detector-nano.onnx";
|
|
67
50
|
INPUT_SIZE = 320;
|
|
68
51
|
CONFIDENCE_THRESHOLD = 0.6;
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
MASK_WIDTH = 280;
|
|
53
|
+
MASK_HEIGHT = 176;
|
|
71
54
|
debugLog(...args) {
|
|
72
55
|
if (this.debug) {
|
|
73
56
|
console.log(...args);
|
|
74
57
|
}
|
|
75
58
|
}
|
|
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
|
-
}
|
|
95
|
-
emitReadyEvent() {
|
|
96
|
-
const isDocumentReady = !!window.ort && this.isModelPreloaded;
|
|
97
|
-
this.isReady.emit(isDocumentReady);
|
|
98
|
-
this.debugLog('🟢 isReady event emitted:', isDocumentReady);
|
|
99
|
-
}
|
|
100
59
|
isRearCamera(stream) {
|
|
101
60
|
const videoTrack = stream.getVideoTracks()[0];
|
|
102
61
|
if (!videoTrack)
|
|
@@ -104,368 +63,14 @@ export class JaakStamps {
|
|
|
104
63
|
const settings = videoTrack.getSettings();
|
|
105
64
|
return settings.facingMode === 'environment';
|
|
106
65
|
}
|
|
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
|
-
}
|
|
363
66
|
async componentDidLoad() {
|
|
364
|
-
this.validateMaskSize();
|
|
365
|
-
this.validateCropMargin();
|
|
366
|
-
this.validatePreferredCamera();
|
|
367
|
-
await this.detectDeviceTypeAndCameras();
|
|
368
67
|
if (!window.ort) {
|
|
369
68
|
const script = document.createElement('script');
|
|
370
69
|
script.src = 'https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js';
|
|
371
70
|
document.head.appendChild(script);
|
|
372
|
-
// Wait for ONNX runtime to load before emitting ready event
|
|
373
|
-
script.onload = () => {
|
|
374
|
-
this.emitReadyEvent();
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
// ONNX runtime already loaded
|
|
379
|
-
this.emitReadyEvent();
|
|
380
71
|
}
|
|
381
72
|
// Initialize canvas pool for better performance
|
|
382
73
|
this.initializeCanvasPool();
|
|
383
|
-
this.setupResizeObserver();
|
|
384
|
-
}
|
|
385
|
-
setupResizeObserver() {
|
|
386
|
-
if ('ResizeObserver' in window && this.canvasRef) {
|
|
387
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
388
|
-
this.handleResize();
|
|
389
|
-
});
|
|
390
|
-
resizeObserver.observe(this.canvasRef.parentElement);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
handleResize() {
|
|
394
|
-
if (this.canvasRef) {
|
|
395
|
-
const container = this.canvasRef.parentElement;
|
|
396
|
-
const rect = container.getBoundingClientRect();
|
|
397
|
-
// Set canvas size to match container
|
|
398
|
-
this.canvasRef.width = rect.width;
|
|
399
|
-
this.canvasRef.height = rect.height;
|
|
400
|
-
// Update mask positioning based on container and video dimensions
|
|
401
|
-
this.updateMaskDimensions(rect);
|
|
402
|
-
this.debugLog('📐 Canvas resized:', { width: rect.width, height: rect.height });
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
updateMaskDimensions(containerRect) {
|
|
406
|
-
if (!this.videoRef)
|
|
407
|
-
return;
|
|
408
|
-
const videoWidth = this.videoRef.videoWidth;
|
|
409
|
-
const videoHeight = this.videoRef.videoHeight;
|
|
410
|
-
if (videoWidth === 0 || videoHeight === 0)
|
|
411
|
-
return;
|
|
412
|
-
// Calculate video aspect ratio and container aspect ratio
|
|
413
|
-
const videoAspectRatio = videoWidth / videoHeight;
|
|
414
|
-
const containerAspectRatio = containerRect.width / containerRect.height;
|
|
415
|
-
// Determine how video fits in container (letterboxed or pillarboxed)
|
|
416
|
-
let displayedVideoWidth, displayedVideoHeight;
|
|
417
|
-
let videoOffsetX = 0, videoOffsetY = 0;
|
|
418
|
-
if (videoAspectRatio > containerAspectRatio) {
|
|
419
|
-
// Video is wider - letterboxed (black bars top/bottom)
|
|
420
|
-
displayedVideoWidth = containerRect.width;
|
|
421
|
-
displayedVideoHeight = containerRect.width / videoAspectRatio;
|
|
422
|
-
videoOffsetY = (containerRect.height - displayedVideoHeight) / 2;
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
// Video is taller - pillarboxed (black bars left/right)
|
|
426
|
-
displayedVideoHeight = containerRect.height;
|
|
427
|
-
displayedVideoWidth = containerRect.height * videoAspectRatio;
|
|
428
|
-
videoOffsetX = (containerRect.width - displayedVideoWidth) / 2;
|
|
429
|
-
}
|
|
430
|
-
// Calculate maximum possible mask size while preserving exact ID-1 aspect ratio
|
|
431
|
-
// Determine the limiting dimension based on video orientation and ID-1 proportions
|
|
432
|
-
// Calculate what would be the max width if limited by video height
|
|
433
|
-
const maxWidthByHeight = displayedVideoHeight * this.ID1_ASPECT_RATIO;
|
|
434
|
-
let maskWidthInVideo, maskHeightInVideo;
|
|
435
|
-
const sizeRatio = this.maskSize / 100;
|
|
436
|
-
if (maxWidthByHeight <= displayedVideoWidth) {
|
|
437
|
-
// Video height is the limiting factor
|
|
438
|
-
maskHeightInVideo = displayedVideoHeight * sizeRatio;
|
|
439
|
-
maskWidthInVideo = maskHeightInVideo * this.ID1_ASPECT_RATIO;
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
442
|
-
// Video width is the limiting factor
|
|
443
|
-
maskWidthInVideo = displayedVideoWidth * sizeRatio;
|
|
444
|
-
maskHeightInVideo = maskWidthInVideo / this.ID1_ASPECT_RATIO;
|
|
445
|
-
}
|
|
446
|
-
// Convert to percentages of the container
|
|
447
|
-
const maskWidthPercent = (maskWidthInVideo / containerRect.width) * 100;
|
|
448
|
-
const maskHeightPercent = (maskHeightInVideo / containerRect.height) * 100;
|
|
449
|
-
// Calculate the center position of the displayed video area
|
|
450
|
-
const videoCenterX = videoOffsetX + (displayedVideoWidth / 2);
|
|
451
|
-
const videoCenterY = videoOffsetY + (displayedVideoHeight / 2);
|
|
452
|
-
// Convert to percentages of the container
|
|
453
|
-
const videoCenterXPercent = (videoCenterX / containerRect.width) * 100;
|
|
454
|
-
const videoCenterYPercent = (videoCenterY / containerRect.height) * 100;
|
|
455
|
-
// Update CSS custom properties for mask sizing and positioning
|
|
456
|
-
this.el.style.setProperty('--mask-width', `${maskWidthPercent}%`);
|
|
457
|
-
this.el.style.setProperty('--mask-height', `${maskHeightPercent}%`);
|
|
458
|
-
this.el.style.setProperty('--mask-center-x', `${videoCenterXPercent}%`);
|
|
459
|
-
this.el.style.setProperty('--mask-center-y', `${videoCenterYPercent}%`);
|
|
460
|
-
// Mark mask as ready now that dimensions are calculated
|
|
461
|
-
this.isMaskReady = true;
|
|
462
|
-
this.debugLog('🎯 Mask dimensions updated:', {
|
|
463
|
-
video: { width: videoWidth, height: videoHeight },
|
|
464
|
-
displayed: { width: displayedVideoWidth, height: displayedVideoHeight },
|
|
465
|
-
mask: { widthPercent: maskWidthPercent, heightPercent: maskHeightPercent },
|
|
466
|
-
center: { x: videoCenterXPercent, y: videoCenterYPercent },
|
|
467
|
-
offset: { x: videoOffsetX, y: videoOffsetY }
|
|
468
|
-
});
|
|
469
74
|
}
|
|
470
75
|
initializeCanvasPool() {
|
|
471
76
|
// Preprocess canvas - reused for every inference
|
|
@@ -534,29 +139,24 @@ export class JaakStamps {
|
|
|
534
139
|
}
|
|
535
140
|
try {
|
|
536
141
|
this.isLoading = true;
|
|
537
|
-
this.statusMessage = "Precargando
|
|
142
|
+
this.statusMessage = "Precargando modelo de detección...";
|
|
538
143
|
this.statusColor = "#007bff";
|
|
539
144
|
const modelPath = this.MODEL_PATH;
|
|
540
|
-
this.debugLog('🤖 Preloading
|
|
145
|
+
this.debugLog('🤖 Preloading model:', modelPath);
|
|
541
146
|
// Configure ONNX Runtime with device-specific optimizations
|
|
542
147
|
const sessionOptions = this.getSessionOptions();
|
|
543
148
|
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
|
-
}
|
|
548
149
|
this.isModelPreloaded = true;
|
|
549
150
|
this.isLoading = false;
|
|
550
|
-
this.statusMessage = "
|
|
151
|
+
this.statusMessage = "Modelo precargado. Listo para comenzar detección";
|
|
551
152
|
this.statusColor = "#28a745";
|
|
552
|
-
this.
|
|
553
|
-
|
|
554
|
-
return { success: true, message: 'Models preloaded successfully' };
|
|
153
|
+
this.debugLog('✅ Model preloaded successfully');
|
|
154
|
+
return { success: true, message: 'Model preloaded successfully' };
|
|
555
155
|
}
|
|
556
156
|
catch (error) {
|
|
557
|
-
this.debugLog('❌ Error preloading
|
|
157
|
+
this.debugLog('❌ Error preloading model:', error);
|
|
558
158
|
this.isLoading = false;
|
|
559
|
-
this.statusMessage = "Error al precargar
|
|
159
|
+
this.statusMessage = "Error al precargar el modelo";
|
|
560
160
|
this.statusColor = "#ff6b6b";
|
|
561
161
|
return { success: false, error: error.message };
|
|
562
162
|
}
|
|
@@ -566,109 +166,6 @@ export class JaakStamps {
|
|
|
566
166
|
this.completeProcess(true);
|
|
567
167
|
}
|
|
568
168
|
}
|
|
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
|
-
}
|
|
672
169
|
cleanup() {
|
|
673
170
|
if (this.animationId) {
|
|
674
171
|
cancelAnimationFrame(this.animationId);
|
|
@@ -696,103 +193,22 @@ export class JaakStamps {
|
|
|
696
193
|
this.captureCtx = undefined;
|
|
697
194
|
this.captureCanvas = undefined;
|
|
698
195
|
}
|
|
699
|
-
// Disposed ONNX
|
|
196
|
+
// Disposed ONNX session
|
|
700
197
|
if (this.session) {
|
|
701
198
|
this.session.release?.();
|
|
702
199
|
this.session = undefined;
|
|
703
200
|
}
|
|
704
|
-
if (this.mobileNetSession) {
|
|
705
|
-
this.mobileNetSession.release?.();
|
|
706
|
-
this.mobileNetSession = undefined;
|
|
707
|
-
}
|
|
708
|
-
this.mobileNetClassMap = undefined;
|
|
709
201
|
this.isModelPreloaded = false;
|
|
710
202
|
this.debugLog('🧹 Canvas pool cleaned up');
|
|
711
203
|
}
|
|
712
|
-
async getMaxResolution() {
|
|
713
|
-
try {
|
|
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
|
|
726
|
-
const tempStream = await navigator.mediaDevices.getUserMedia({
|
|
727
|
-
video: videoConstraints
|
|
728
|
-
});
|
|
729
|
-
const videoTrack = tempStream.getVideoTracks()[0];
|
|
730
|
-
const capabilities = videoTrack.getCapabilities();
|
|
731
|
-
// Detener el stream temporal
|
|
732
|
-
tempStream.getTracks().forEach(track => track.stop());
|
|
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
|
-
;
|
|
746
|
-
if (capabilities.width && capabilities.height) {
|
|
747
|
-
// Limitar resolución máxima para tablets para evitar problemas de rendimiento
|
|
748
|
-
const maxWidth = Math.min(capabilities.width.max, 1920);
|
|
749
|
-
const maxHeight = Math.min(capabilities.height.max, 1080);
|
|
750
|
-
// Para tablets, usar resolución moderada en lugar de máxima
|
|
751
|
-
const isTablet = /iPad|Android/i.test(navigator.userAgent) && window.innerWidth >= 768;
|
|
752
|
-
if (isTablet) {
|
|
753
|
-
constraints.width = { ideal: Math.min(maxWidth, 1280) };
|
|
754
|
-
constraints.height = { ideal: Math.min(maxHeight, 720) };
|
|
755
|
-
}
|
|
756
|
-
else {
|
|
757
|
-
constraints.width = { ideal: maxWidth };
|
|
758
|
-
constraints.height = { ideal: maxHeight };
|
|
759
|
-
}
|
|
760
|
-
this.debugLog('📐 Resolution capabilities:', {
|
|
761
|
-
maxWidth: capabilities.width.max,
|
|
762
|
-
maxHeight: capabilities.height.max,
|
|
763
|
-
selectedWidth: constraints.width.ideal,
|
|
764
|
-
selectedHeight: constraints.height.ideal,
|
|
765
|
-
isTablet
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
return constraints;
|
|
769
|
-
}
|
|
770
|
-
catch (err) {
|
|
771
|
-
this.debugLog('⚠️ Could not get capabilities, using fallback');
|
|
772
|
-
// Optimized fallback for tablets
|
|
773
|
-
const isTablet = /iPad|Android/i.test(navigator.userAgent) && window.innerWidth >= 768;
|
|
774
|
-
const fallbackConstraints = {
|
|
775
|
-
width: { ideal: isTablet ? 1280 : 1920 },
|
|
776
|
-
height: { ideal: isTablet ? 720 : 1080 }
|
|
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;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
204
|
async setupCamera() {
|
|
792
205
|
try {
|
|
793
|
-
const constraints = await this.getMaxResolution();
|
|
794
206
|
const stream = await navigator.mediaDevices.getUserMedia({
|
|
795
|
-
video:
|
|
207
|
+
video: {
|
|
208
|
+
width: { exact: 640 },
|
|
209
|
+
height: { exact: 640 },
|
|
210
|
+
facingMode: "environment"
|
|
211
|
+
},
|
|
796
212
|
audio: false
|
|
797
213
|
});
|
|
798
214
|
if (this.videoRef) {
|
|
@@ -807,12 +223,6 @@ export class JaakStamps {
|
|
|
807
223
|
this.videoRef.onloadedmetadata = async () => {
|
|
808
224
|
await this.videoRef.play();
|
|
809
225
|
this.isVideoActive = true;
|
|
810
|
-
// Update mask dimensions once video is loaded
|
|
811
|
-
if (this.canvasRef) {
|
|
812
|
-
const container = this.canvasRef.parentElement;
|
|
813
|
-
const rect = container.getBoundingClientRect();
|
|
814
|
-
this.updateMaskDimensions(rect);
|
|
815
|
-
}
|
|
816
226
|
resolve();
|
|
817
227
|
};
|
|
818
228
|
});
|
|
@@ -820,7 +230,8 @@ export class JaakStamps {
|
|
|
820
230
|
}
|
|
821
231
|
catch (err) {
|
|
822
232
|
this.debugLog("❌ No se pudo acceder a la cámara:", err);
|
|
823
|
-
this.
|
|
233
|
+
this.statusMessage = "Error: No se pudo acceder a la cámara.";
|
|
234
|
+
this.statusColor = "#ff6b6b";
|
|
824
235
|
}
|
|
825
236
|
}
|
|
826
237
|
preprocess(video) {
|
|
@@ -865,22 +276,17 @@ export class JaakStamps {
|
|
|
865
276
|
// Check if model is already preloaded
|
|
866
277
|
if (!this.session) {
|
|
867
278
|
this.isLoading = true;
|
|
868
|
-
this.statusMessage = "Cargando
|
|
279
|
+
this.statusMessage = "Cargando modelo de detección...";
|
|
869
280
|
this.statusColor = "#007bff";
|
|
870
281
|
const modelPath = this.MODEL_PATH;
|
|
871
|
-
this.debugLog('🤖 Loading
|
|
282
|
+
this.debugLog('🤖 Loading model:', modelPath);
|
|
872
283
|
const sessionOptions = this.getSessionOptions();
|
|
873
284
|
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
|
-
}
|
|
878
285
|
this.isModelPreloaded = true;
|
|
879
|
-
this.emitReadyEvent();
|
|
880
286
|
}
|
|
881
287
|
else {
|
|
882
|
-
this.debugLog('🚀 Using preloaded
|
|
883
|
-
this.statusMessage = "Usando
|
|
288
|
+
this.debugLog('🚀 Using preloaded model');
|
|
289
|
+
this.statusMessage = "Usando modelo precargado...";
|
|
884
290
|
this.statusColor = "#007bff";
|
|
885
291
|
}
|
|
886
292
|
this.statusMessage = "Configurando cámara...";
|
|
@@ -993,58 +399,13 @@ export class JaakStamps {
|
|
|
993
399
|
return isCentered && isGoodSize;
|
|
994
400
|
}
|
|
995
401
|
checkSideAlignment(box) {
|
|
996
|
-
|
|
997
|
-
return { top: false, right: false, bottom: false, left: false };
|
|
998
|
-
// Get video dimensions to calculate actual mask boundaries in model space
|
|
999
|
-
const videoWidth = this.videoRef.videoWidth;
|
|
1000
|
-
const videoHeight = this.videoRef.videoHeight;
|
|
1001
|
-
if (videoWidth === 0 || videoHeight === 0) {
|
|
1002
|
-
return { top: false, right: false, bottom: false, left: false };
|
|
1003
|
-
}
|
|
1004
|
-
// Calculate video aspect ratio
|
|
1005
|
-
const videoAspectRatio = videoWidth / videoHeight;
|
|
1006
|
-
// The model sees video stretched to 320x320, but we need to calculate where
|
|
1007
|
-
// the mask should be in this distorted space to match the visual mask
|
|
1008
|
-
// In the visual display, we calculate mask size based on the limiting dimension
|
|
1009
|
-
// We need to replicate this logic but account for the distortion in model space
|
|
1010
|
-
// Calculate the "display" dimensions (what the visual mask calculations use)
|
|
1011
|
-
const containerAspectRatio = 1; // Assume square container for simplicity
|
|
1012
|
-
let displayedVideoWidth, displayedVideoHeight;
|
|
1013
|
-
if (videoAspectRatio > containerAspectRatio) {
|
|
1014
|
-
// Video is wider - letterboxed in display
|
|
1015
|
-
displayedVideoWidth = this.INPUT_SIZE;
|
|
1016
|
-
displayedVideoHeight = this.INPUT_SIZE / videoAspectRatio;
|
|
1017
|
-
}
|
|
1018
|
-
else {
|
|
1019
|
-
// Video is taller - pillarboxed in display
|
|
1020
|
-
displayedVideoHeight = this.INPUT_SIZE;
|
|
1021
|
-
displayedVideoWidth = this.INPUT_SIZE * videoAspectRatio;
|
|
1022
|
-
}
|
|
1023
|
-
// Calculate mask dimensions using the same logic as updateMaskDimensions
|
|
1024
|
-
const maxWidthByHeight = displayedVideoHeight * this.ID1_ASPECT_RATIO;
|
|
1025
|
-
let visualMaskWidth, visualMaskHeight;
|
|
1026
|
-
const sizeRatio = this.maskSize / 100;
|
|
1027
|
-
if (maxWidthByHeight <= displayedVideoWidth) {
|
|
1028
|
-
// Video height is the limiting factor
|
|
1029
|
-
visualMaskHeight = displayedVideoHeight * sizeRatio;
|
|
1030
|
-
visualMaskWidth = visualMaskHeight * this.ID1_ASPECT_RATIO;
|
|
1031
|
-
}
|
|
1032
|
-
else {
|
|
1033
|
-
// Video width is the limiting factor
|
|
1034
|
-
visualMaskWidth = displayedVideoWidth * sizeRatio;
|
|
1035
|
-
visualMaskHeight = visualMaskWidth / this.ID1_ASPECT_RATIO;
|
|
1036
|
-
}
|
|
1037
|
-
// Now map these visual mask dimensions to the distorted model space
|
|
1038
|
-
// The model stretches video to 320x320, so we need to apply the inverse transformation
|
|
1039
|
-
const modelMaskWidth = visualMaskWidth * (this.INPUT_SIZE / displayedVideoWidth);
|
|
1040
|
-
const modelMaskHeight = visualMaskHeight * (this.INPUT_SIZE / displayedVideoHeight);
|
|
1041
|
-
// Calculate mask boundaries in model coordinate system (always centered in 320x320)
|
|
402
|
+
// Obtener las coordenadas del marco de referencia (máscara)
|
|
1042
403
|
const maskCenterX = this.INPUT_SIZE / 2;
|
|
1043
404
|
const maskCenterY = this.INPUT_SIZE / 2;
|
|
1044
|
-
const maskLeft = maskCenterX - (
|
|
1045
|
-
const maskRight = maskCenterX + (
|
|
1046
|
-
const maskTop = maskCenterY - (
|
|
1047
|
-
const maskBottom = maskCenterY + (
|
|
405
|
+
const maskLeft = maskCenterX - (this.MASK_WIDTH / 2);
|
|
406
|
+
const maskRight = maskCenterX + (this.MASK_WIDTH / 2);
|
|
407
|
+
const maskTop = maskCenterY - (this.MASK_HEIGHT / 2);
|
|
408
|
+
const maskBottom = maskCenterY + (this.MASK_HEIGHT / 2);
|
|
1048
409
|
// Obtener las coordenadas del documento detectado
|
|
1049
410
|
let docLeft = box.x;
|
|
1050
411
|
let docRight = box.x + box.w;
|
|
@@ -1099,9 +460,7 @@ export class JaakStamps {
|
|
|
1099
460
|
corners?.forEach(corner => corner.classList.add('perfect-match'));
|
|
1100
461
|
if (!this.hasScreenshotTaken) {
|
|
1101
462
|
this.lastDetectedBox = bestBox;
|
|
1102
|
-
this.takeScreenshot()
|
|
1103
|
-
this.debugLog('❌ Error taking screenshot:', error);
|
|
1104
|
-
});
|
|
463
|
+
this.takeScreenshot();
|
|
1105
464
|
this.hasScreenshotTaken = true;
|
|
1106
465
|
// Reset para permitir segunda captura
|
|
1107
466
|
setTimeout(() => {
|
|
@@ -1143,48 +502,15 @@ export class JaakStamps {
|
|
|
1143
502
|
}
|
|
1144
503
|
}
|
|
1145
504
|
drawDetections(ctx, boxes) {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
// Get video and container dimensions
|
|
1149
|
-
const videoWidth = this.videoRef.videoWidth;
|
|
1150
|
-
const videoHeight = this.videoRef.videoHeight;
|
|
1151
|
-
const containerWidth = this.canvasRef.width;
|
|
1152
|
-
const containerHeight = this.canvasRef.height;
|
|
1153
|
-
if (videoWidth === 0 || videoHeight === 0)
|
|
1154
|
-
return;
|
|
1155
|
-
// Calculate video aspect ratio and container aspect ratio
|
|
1156
|
-
const videoAspectRatio = videoWidth / videoHeight;
|
|
1157
|
-
const containerAspectRatio = containerWidth / containerHeight;
|
|
1158
|
-
// Determine how video fits in container (same logic as updateMaskDimensions)
|
|
1159
|
-
let displayedVideoWidth, displayedVideoHeight;
|
|
1160
|
-
let videoOffsetX = 0, videoOffsetY = 0;
|
|
1161
|
-
if (videoAspectRatio > containerAspectRatio) {
|
|
1162
|
-
// Video is wider - letterboxed (black bars top/bottom)
|
|
1163
|
-
displayedVideoWidth = containerWidth;
|
|
1164
|
-
displayedVideoHeight = containerWidth / videoAspectRatio;
|
|
1165
|
-
videoOffsetY = (containerHeight - displayedVideoHeight) / 2;
|
|
1166
|
-
}
|
|
1167
|
-
else {
|
|
1168
|
-
// Video is taller - pillarboxed (black bars left/right)
|
|
1169
|
-
displayedVideoHeight = containerHeight;
|
|
1170
|
-
displayedVideoWidth = containerHeight * videoAspectRatio;
|
|
1171
|
-
videoOffsetX = (containerWidth - displayedVideoWidth) / 2;
|
|
1172
|
-
}
|
|
1173
|
-
// Scale factor from model coordinates (320x320) to displayed video area
|
|
1174
|
-
const scaleX = displayedVideoWidth / this.INPUT_SIZE;
|
|
1175
|
-
const scaleY = displayedVideoHeight / this.INPUT_SIZE;
|
|
505
|
+
// Scale factor to convert from model coordinates (320x320) to canvas coordinates (640x640)
|
|
506
|
+
const scale = this.canvasRef.width / this.INPUT_SIZE;
|
|
1176
507
|
boxes.forEach(det => {
|
|
1177
|
-
// Convert model coordinates to displayed video coordinates
|
|
1178
|
-
const x = det.x * scaleX + videoOffsetX;
|
|
1179
|
-
const y = det.y * scaleY + videoOffsetY;
|
|
1180
|
-
const w = det.w * scaleX;
|
|
1181
|
-
const h = det.h * scaleY;
|
|
1182
508
|
ctx.strokeStyle = "#32406C";
|
|
1183
509
|
ctx.lineWidth = 2;
|
|
1184
|
-
ctx.strokeRect(x, y, w, h);
|
|
510
|
+
ctx.strokeRect(det.x * scale, det.y * scale, det.w * scale, det.h * scale);
|
|
1185
511
|
});
|
|
1186
512
|
}
|
|
1187
|
-
|
|
513
|
+
takeScreenshot() {
|
|
1188
514
|
if (!this.videoRef || !this.lastDetectedBox)
|
|
1189
515
|
return;
|
|
1190
516
|
// Activar animación
|
|
@@ -1200,10 +526,10 @@ export class JaakStamps {
|
|
|
1200
526
|
// Calcular las coordenadas de recorte basadas en la detección
|
|
1201
527
|
const scaleX = this.videoRef.videoWidth / this.INPUT_SIZE;
|
|
1202
528
|
const scaleY = this.videoRef.videoHeight / this.INPUT_SIZE;
|
|
1203
|
-
const cropX = Math.max(0,
|
|
1204
|
-
const cropY = Math.max(0,
|
|
1205
|
-
const cropWidth = Math.min(
|
|
1206
|
-
const cropHeight = Math.min(
|
|
529
|
+
const cropX = Math.max(0, this.lastDetectedBox.x * scaleX);
|
|
530
|
+
const cropY = Math.max(0, this.lastDetectedBox.y * scaleY);
|
|
531
|
+
const cropWidth = Math.min(this.lastDetectedBox.w * scaleX, this.videoRef.videoWidth - cropX);
|
|
532
|
+
const cropHeight = Math.min(this.lastDetectedBox.h * scaleY, this.videoRef.videoHeight - cropY);
|
|
1207
533
|
// OPTIMIZATION: Create temporary canvas only for cropped version
|
|
1208
534
|
// (We reuse main capture canvas for full frame)
|
|
1209
535
|
const croppedCanvas = document.createElement('canvas');
|
|
@@ -1218,29 +544,6 @@ export class JaakStamps {
|
|
|
1218
544
|
// Captura del frente usando canvas reutilizado
|
|
1219
545
|
this.capturedFullFrame = this.captureCanvas.toDataURL('image/png');
|
|
1220
546
|
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)
|
|
1244
547
|
this.captureStep = 'back';
|
|
1245
548
|
this.statusMessage = "Voltee la identificación y muestre la parte trasera";
|
|
1246
549
|
this.statusColor = "#007bff";
|
|
@@ -1370,20 +673,7 @@ export class JaakStamps {
|
|
|
1370
673
|
this.cleanup();
|
|
1371
674
|
}
|
|
1372
675
|
render() {
|
|
1373
|
-
return (h("div", { key: '
|
|
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" })))));
|
|
676
|
+
return (h("div", { key: 'a1036d3867a4f5c40a942e47a30992a6c56e5240', class: "detector-container" }, h("div", { key: 'dada4edb4cc690e4e73d616e8eb22fa8fb6b2817', class: "video-container" }, h("video", { key: '16b43f5efdd0c32dbfab49a86e6904baabfdc220', ref: el => this.videoRef = el, width: "640", height: "640", autoplay: true, muted: true, playsinline: true, class: this.shouldMirrorVideo ? 'mirror' : '', style: { display: this.isVideoActive ? 'block' : 'none' } }), h("canvas", { key: 'e89cf0292df3bef51d9e9ed650b4f68493506314', ref: el => this.canvasRef = el, width: "640", height: "640", class: this.shouldMirrorVideo ? 'mirror' : '' }), h("div", { key: '3740295495466519be1b4b95891dd06d8272a7d6', class: "overlay-mask" }, h("div", { key: 'ac61b03420ae83d06ec8e5095a11665a8b5a4cd1', class: "card-outline" }, h("div", { key: '7190506e4803ccde1f6c95e6238b05271e7e01a5', class: "side side-top" }), h("div", { key: 'e383f023305021cdd5a02ccaf6a2bb2c775b28be', class: "side side-right" }), h("div", { key: '733f572b80c5f0050c21aa4cf5efd5b499859c23', class: "side side-bottom" }), h("div", { key: 'dbf175597a0d0790b9cc54f737693e418f1500f2', class: "side side-left" }), h("div", { key: '657375f468fc83444e6157c5308fca7237e85f22', class: "corner corner-tl" }), h("div", { key: '0491bf2ed49322cba5220a82016bb9a77c102386', class: "corner corner-tr" }), h("div", { key: 'eb7d153a47dfb1f0c98229752aabfe71181d6c3b', class: "corner corner-bl" }), h("div", { key: '7d57726a70864f9c2590395f6dc89918558fbc87', class: "corner corner-br" }), !this.showFlipAnimation && !this.showSuccessAnimation && (h("div", { key: '8deff6975766142bae69fb7596f0097b1319bc5f', class: "guide-text" }, this.statusMessage))), this.captureStep === 'back' && !this.showFlipAnimation && !this.showSuccessAnimation && (h("button", { key: '471fae3b2c48302d474a7e7186cbe21e1260288f', class: "skip-button", onClick: () => this.skipBackCapture(), type: "button" }, "Saltar reverso"))), this.isCapturing && (h("div", { key: '83fa0133b072f982c9d861632525a64068271833', class: "capture-animation" })), this.showFlipAnimation && (h("div", { key: '0cdcabf20a263067a3fb120ec112a7c688eaece1', class: "flip-animation" }, h("div", { key: 'c7fd5c4211aa67cdc37be882617120cfb3afcfad', class: "id-card-icon" }), h("div", { key: '1c8e889d1de4867887fc25ac221b780154da59dd', class: "flip-text" }, "\u00A1Voltea tu identificaci\u00F3n!"))), this.showSuccessAnimation && (h("div", { key: '7fcf315cb26c2c860d06dcdb7da6f58524ef4474', class: "success-animation" }, h("div", { key: '5ea1a6aa4368cd154189db166af531abe2e0029e', class: "check-icon" }), h("div", { key: 'deb064b437a664ea5dfdb9b3883ee83bc85b939e', class: "success-text" }, "\u00A1Proceso completado!"))), this.isLoading && (h("div", { key: '7a28906555b0e5b891e1f8516a318ec540a83320', class: "loading-overlay" }, h("div", { key: '6f0778d156648405dd385f95c5e9bad0c4112eda', class: "loading-spinner" }), h("div", { key: 'b1cd4ddee0e282e8353bf8ed298fbd1c8498fb5e', class: "loading-text" }, this.statusMessage))), h("div", { key: '1e74b90a10ef2e2e71505160accb0ea83672c5de', class: "watermark" }, h("img", { key: '352fee0189ac25f59724e69e317b28859c86476e', src: "https://storage.googleapis.com/jaak-static/commons/powered-by-jaak.png", alt: "Powered by Jaak" })))));
|
|
1387
677
|
}
|
|
1388
678
|
static get is() { return "jaak-stamps"; }
|
|
1389
679
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1438,86 +728,6 @@ export class JaakStamps {
|
|
|
1438
728
|
"setter": false,
|
|
1439
729
|
"reflect": false,
|
|
1440
730
|
"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'"
|
|
1521
731
|
}
|
|
1522
732
|
};
|
|
1523
733
|
}
|
|
@@ -1539,12 +749,7 @@ export class JaakStamps {
|
|
|
1539
749
|
"sideAlignment": {},
|
|
1540
750
|
"isDetectionPaused": {},
|
|
1541
751
|
"isLoading": {},
|
|
1542
|
-
"isModelPreloaded": {}
|
|
1543
|
-
"isMaskReady": {},
|
|
1544
|
-
"availableCameras": {},
|
|
1545
|
-
"selectedCameraId": {},
|
|
1546
|
-
"showCameraSelector": {},
|
|
1547
|
-
"isMultipleCamerasAvailable": {}
|
|
752
|
+
"isModelPreloaded": {}
|
|
1548
753
|
};
|
|
1549
754
|
}
|
|
1550
755
|
static get events() {
|
|
@@ -1563,21 +768,6 @@ export class JaakStamps {
|
|
|
1563
768
|
"resolved": "any",
|
|
1564
769
|
"references": {}
|
|
1565
770
|
}
|
|
1566
|
-
}, {
|
|
1567
|
-
"method": "isReady",
|
|
1568
|
-
"name": "isReady",
|
|
1569
|
-
"bubbles": true,
|
|
1570
|
-
"cancelable": true,
|
|
1571
|
-
"composed": true,
|
|
1572
|
-
"docs": {
|
|
1573
|
-
"tags": [],
|
|
1574
|
-
"text": ""
|
|
1575
|
-
},
|
|
1576
|
-
"complexType": {
|
|
1577
|
-
"original": "boolean",
|
|
1578
|
-
"resolved": "boolean",
|
|
1579
|
-
"references": {}
|
|
1580
|
-
}
|
|
1581
771
|
}];
|
|
1582
772
|
}
|
|
1583
773
|
static get methods() {
|
|
@@ -1717,44 +907,6 @@ export class JaakStamps {
|
|
|
1717
907
|
"text": "",
|
|
1718
908
|
"tags": []
|
|
1719
909
|
}
|
|
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
|
-
}
|
|
1758
910
|
}
|
|
1759
911
|
};
|
|
1760
912
|
}
|