@trustchex/react-native-sdk 1.374.0 → 1.381.0
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/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraView.kt +0 -9
- package/android/src/main/java/com/trustchex/reactnativesdk/opencv/OpenCVModule.kt +636 -301
- package/ios/Camera/TrustchexCameraView.swift +8 -8
- package/ios/OpenCV/OpenCVHelper.h +0 -7
- package/ios/OpenCV/OpenCVHelper.mm +0 -60
- package/ios/OpenCV/OpenCVModule.h +0 -4
- package/ios/OpenCV/OpenCVModule.mm +440 -358
- package/lib/module/Shared/Components/DebugOverlay.js +541 -0
- package/lib/module/Shared/Components/IdentityDocumentCamera.constants.js +44 -0
- package/lib/module/Shared/Components/IdentityDocumentCamera.flows.js +270 -0
- package/lib/module/Shared/Components/IdentityDocumentCamera.js +679 -1701
- package/lib/module/Shared/Components/IdentityDocumentCamera.types.js +3 -0
- package/lib/module/Shared/Components/IdentityDocumentCamera.utils.js +273 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/Shared/Components/DebugOverlay.d.ts +30 -0
- package/lib/typescript/src/Shared/Components/DebugOverlay.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.constants.d.ts +35 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.constants.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts +3 -56
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.flows.d.ts +88 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.flows.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.types.d.ts +116 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.types.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.utils.d.ts +93 -0
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.utils.d.ts.map +1 -0
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/Shared/Components/DebugOverlay.tsx +656 -0
- package/src/Shared/Components/IdentityDocumentCamera.constants.ts +44 -0
- package/src/Shared/Components/IdentityDocumentCamera.flows.ts +342 -0
- package/src/Shared/Components/IdentityDocumentCamera.tsx +1065 -2462
- package/src/Shared/Components/IdentityDocumentCamera.types.ts +136 -0
- package/src/Shared/Components/IdentityDocumentCamera.utils.ts +364 -0
- package/src/version.ts +1 -1
|
@@ -8,11 +8,8 @@ import {
|
|
|
8
8
|
StatusBar,
|
|
9
9
|
Vibration,
|
|
10
10
|
Linking,
|
|
11
|
-
Image,
|
|
12
11
|
ActivityIndicator,
|
|
13
12
|
PermissionsAndroid,
|
|
14
|
-
Dimensions,
|
|
15
|
-
ScrollView,
|
|
16
13
|
Animated,
|
|
17
14
|
type NativeSyntheticEvent,
|
|
18
15
|
type ViewStyle,
|
|
@@ -24,7 +21,6 @@ import {
|
|
|
24
21
|
type Frame,
|
|
25
22
|
} from './TrustchexCamera';
|
|
26
23
|
import { NativeModules } from 'react-native';
|
|
27
|
-
import type { MRZFields } from '../Types/mrzFields';
|
|
28
24
|
import mrzUtils from '../Libs/mrz.utils';
|
|
29
25
|
import { useKeepAwake } from '../Libs/native-keep-awake.utils';
|
|
30
26
|
import { useIsFocused } from '@react-navigation/native';
|
|
@@ -36,101 +32,60 @@ import { SafeAreaView } from 'react-native-safe-area-context';
|
|
|
36
32
|
import { speak, resetLastMessage } from '../Libs/tts.utils';
|
|
37
33
|
import AppContext from '../Contexts/AppContext';
|
|
38
34
|
import { useTheme } from '../Contexts/ThemeContext';
|
|
35
|
+
import DebugOverlay, { TestModePanel } from './DebugOverlay';
|
|
36
|
+
import {
|
|
37
|
+
getStatusMessage,
|
|
38
|
+
getFrameToScreenTransform,
|
|
39
|
+
transformBoundsToScreen,
|
|
40
|
+
getScanAreaBounds,
|
|
41
|
+
angleBetweenPoints,
|
|
42
|
+
detectDocumentType,
|
|
43
|
+
determineDocumentTypeToSet,
|
|
44
|
+
areMRZFieldsEqual,
|
|
45
|
+
hasRequiredMRZFields,
|
|
46
|
+
validateFacePosition,
|
|
47
|
+
} from './IdentityDocumentCamera.utils';
|
|
48
|
+
import {
|
|
49
|
+
handlePassportFlow,
|
|
50
|
+
handleIDFrontFlow,
|
|
51
|
+
handleIDBackFlow,
|
|
52
|
+
getNextStepAfterHologram,
|
|
53
|
+
} from './IdentityDocumentCamera.flows';
|
|
54
|
+
import {
|
|
55
|
+
HOLOGRAM_IMAGE_COUNT,
|
|
56
|
+
HOLOGRAM_DETECTION_THRESHOLD,
|
|
57
|
+
HOLOGRAM_DETECTION_RETRY_COUNT,
|
|
58
|
+
HOLOGRAM_CAPTURE_INTERVAL,
|
|
59
|
+
HOLOGRAM_MAX_FRAMES_WITHOUT_FACE,
|
|
60
|
+
MIN_BRIGHTNESS_THRESHOLD,
|
|
61
|
+
MAX_BRIGHTNESS_THRESHOLD,
|
|
62
|
+
FACE_EDGE_MARGIN_PERCENT,
|
|
63
|
+
MAX_CONSECUTIVE_QUALITY_FAILURES,
|
|
64
|
+
REQUIRED_CONSISTENT_MRZ_READS,
|
|
65
|
+
REQUIRED_CONSISTENT_DOCTYPE_DETECTIONS,
|
|
66
|
+
SIGNATURE_TEXT_REGEX,
|
|
67
|
+
MRZ_BLOCK_PATTERN,
|
|
68
|
+
PASSPORT_MRZ_PATTERN,
|
|
69
|
+
MIN_CARD_FACE_SIZE_PERCENT,
|
|
70
|
+
} from './IdentityDocumentCamera.constants';
|
|
71
|
+
import type {
|
|
72
|
+
DocumentScannedData,
|
|
73
|
+
BlockText,
|
|
74
|
+
IdentityDocumentCameraProps,
|
|
75
|
+
Face,
|
|
76
|
+
Barcode,
|
|
77
|
+
CornerPointsType,
|
|
78
|
+
LinesData,
|
|
79
|
+
} from './IdentityDocumentCamera.types';
|
|
80
|
+
|
|
81
|
+
// Re-export types for backward compatibility
|
|
82
|
+
export type { DocumentScannedData, BlockText, IdentityDocumentCameraProps };
|
|
83
|
+
export type { PhotoOptions } from './IdentityDocumentCamera.types';
|
|
39
84
|
|
|
40
85
|
const { OpenCVModule } = NativeModules;
|
|
41
86
|
|
|
42
87
|
const AnimatedText = Animated.createAnimatedComponent(TextView);
|
|
43
88
|
|
|
44
|
-
export type DocumentScannedData = {
|
|
45
|
-
documentType: 'ID_FRONT' | 'ID_BACK' | 'PASSPORT' | 'UNKNOWN';
|
|
46
|
-
image: string;
|
|
47
|
-
faceImage?: string;
|
|
48
|
-
secondaryFaceImage?: string;
|
|
49
|
-
hologramImage?: string;
|
|
50
|
-
barcodeValue?: string;
|
|
51
|
-
mrzText?: string;
|
|
52
|
-
mrzFields?: MRZFields;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export type BlockText = {
|
|
56
|
-
blocks: BlocksData[];
|
|
57
|
-
resultText: string;
|
|
58
|
-
mrzOnlyText?: string; // MRZ-specific text from detected MRZ blocks only
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
type BlocksData = {
|
|
62
|
-
blockFrame: FrameType;
|
|
63
|
-
blockCornerPoints: CornerPointsType;
|
|
64
|
-
lines: LinesData;
|
|
65
|
-
blockLanguages: string[] | [];
|
|
66
|
-
blockText: string;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
type CornerPointsType = [{ x: number; y: number }];
|
|
70
|
-
|
|
71
|
-
type FrameType = {
|
|
72
|
-
boundingCenterX: number;
|
|
73
|
-
boundingCenterY: number;
|
|
74
|
-
height: number;
|
|
75
|
-
width: number;
|
|
76
|
-
x: number;
|
|
77
|
-
y: number;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
type LinesData = [
|
|
81
|
-
lineCornerPoints: CornerPointsType,
|
|
82
|
-
elements: ElementsData,
|
|
83
|
-
lineFrame: FrameType,
|
|
84
|
-
lineLanguages: string[] | [],
|
|
85
|
-
lineText: string,
|
|
86
|
-
];
|
|
87
|
-
|
|
88
|
-
type ElementsData = [
|
|
89
|
-
elementCornerPoints: CornerPointsType,
|
|
90
|
-
elementFrame: FrameType,
|
|
91
|
-
elementText: string,
|
|
92
|
-
];
|
|
93
|
-
|
|
94
|
-
export type PhotoOptions = {
|
|
95
|
-
uri: string;
|
|
96
|
-
orientation?:
|
|
97
|
-
| 'landscapeRight'
|
|
98
|
-
| 'portrait'
|
|
99
|
-
| 'portraitUpsideDown'
|
|
100
|
-
| 'landscapeLeft';
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export interface IdentityDocumentCameraProps {
|
|
104
|
-
onlyMRZScan: boolean;
|
|
105
|
-
onIdentityDocumentScanned: (scannedData: DocumentScannedData) => void;
|
|
106
|
-
testMode?: boolean;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
interface Face {
|
|
110
|
-
bounds: { x: number; y: number; width: number; height: number };
|
|
111
|
-
rollAngle?: number;
|
|
112
|
-
pitchAngle?: number;
|
|
113
|
-
yawAngle?: number;
|
|
114
|
-
leftEyeOpenProbability?: number;
|
|
115
|
-
rightEyeOpenProbability?: number;
|
|
116
|
-
smilingProbability?: number;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
interface Barcode {
|
|
120
|
-
rawValue: string;
|
|
121
|
-
displayValue: string;
|
|
122
|
-
format: number;
|
|
123
|
-
boundingBox: { left: number; top: number; right: number; bottom: number };
|
|
124
|
-
cornerPoints: Array<{ x: number; y: number }>;
|
|
125
|
-
value?: string;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const HOLOGRAM_IMAGE_COUNT = 12;
|
|
129
|
-
const HOLOGRAM_DETECTION_THRESHOLD = 1000; // Lowered for better sensitivity while still filtering noise
|
|
130
|
-
const HOLOGRAM_DETECTION_RETRY_COUNT = 3; // More attempts but faster each (~1s per attempt)
|
|
131
|
-
const MIN_BRIGHTNESS_THRESHOLD = 45;
|
|
132
|
-
const MAX_CONSECUTIVE_QUALITY_FAILURES = 30;
|
|
133
|
-
|
|
134
89
|
const IdentityDocumentCamera = ({
|
|
135
90
|
onlyMRZScan,
|
|
136
91
|
onIdentityDocumentScanned,
|
|
@@ -151,7 +106,6 @@ const IdentityDocumentCamera = ({
|
|
|
151
106
|
isTorchOnRef.current = val;
|
|
152
107
|
_setIsTorchOn(val);
|
|
153
108
|
}, []);
|
|
154
|
-
const [_exposure, _setExposure] = useState(0);
|
|
155
109
|
const isCameraInitialized = useRef(false);
|
|
156
110
|
const [currentFaceImage, setCurrentFaceImage] = useState<string | undefined>(
|
|
157
111
|
undefined
|
|
@@ -174,7 +128,7 @@ const IdentityDocumentCamera = ({
|
|
|
174
128
|
const [nextStep, setNextStep] = useState<
|
|
175
129
|
'SCAN_ID_FRONT_OR_PASSPORT' | 'SCAN_ID_BACK' | 'SCAN_HOLOGRAM' | 'COMPLETED'
|
|
176
130
|
>('SCAN_ID_FRONT_OR_PASSPORT');
|
|
177
|
-
const [
|
|
131
|
+
const [_completedStep, setCompletedStep] = useState<
|
|
178
132
|
'SCAN_ID_FRONT_OR_PASSPORT' | 'SCAN_ID_BACK' | 'SCAN_HOLOGRAM' | null
|
|
179
133
|
>(null);
|
|
180
134
|
const [detectedDocumentType, setDetectedDocumentType] = useState<
|
|
@@ -189,14 +143,12 @@ const IdentityDocumentCamera = ({
|
|
|
189
143
|
const lastValidMRZText = useRef<string | null>(null);
|
|
190
144
|
const lastValidMRZFields = useRef<any>(null);
|
|
191
145
|
const validMRZConsecutiveCount = useRef(0);
|
|
192
|
-
const REQUIRED_CONSISTENT_MRZ_READS = 2; // Require 2 consistent valid reads
|
|
193
146
|
|
|
194
147
|
// Document type stability tracking - require consistent detections from good quality frames
|
|
195
148
|
const lastDetectedDocType = useRef<
|
|
196
149
|
'ID_FRONT' | 'ID_BACK' | 'PASSPORT' | 'UNKNOWN'
|
|
197
150
|
>('UNKNOWN');
|
|
198
151
|
const consistentDocTypeCount = useRef(0);
|
|
199
|
-
const REQUIRED_CONSISTENT_DOCTYPE_DETECTIONS = 3; // Require 3 consistent detections from quality frames
|
|
200
152
|
|
|
201
153
|
// Frame quality tracking - persist across callbacks
|
|
202
154
|
const lastFrameQuality = useRef({
|
|
@@ -217,121 +169,11 @@ const IdentityDocumentCamera = ({
|
|
|
217
169
|
timestamp: number;
|
|
218
170
|
} | null>(null);
|
|
219
171
|
|
|
220
|
-
// Helper to compare MRZ field values (ignore raw text variations)
|
|
221
|
-
const areMRZFieldsEqual = useCallback(
|
|
222
|
-
(fields1: any, fields2: any): boolean => {
|
|
223
|
-
if (!fields1 || !fields2) return false;
|
|
224
|
-
// Compare critical fields that define document identity
|
|
225
|
-
return (
|
|
226
|
-
fields1.documentNumber === fields2.documentNumber &&
|
|
227
|
-
fields1.birthDate === fields2.birthDate &&
|
|
228
|
-
fields1.expirationDate === fields2.expirationDate &&
|
|
229
|
-
fields1.firstName === fields2.firstName &&
|
|
230
|
-
fields1.lastName === fields2.lastName &&
|
|
231
|
-
fields1.issuingState === fields2.issuingState
|
|
232
|
-
);
|
|
233
|
-
},
|
|
234
|
-
[]
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
// Helper functions to reduce duplication
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Check if all required MRZ fields are present
|
|
241
|
-
*/
|
|
242
|
-
const hasRequiredMRZFields = useCallback(
|
|
243
|
-
(fields: any): boolean =>
|
|
244
|
-
!!fields?.firstName &&
|
|
245
|
-
!!fields?.lastName &&
|
|
246
|
-
!!fields?.documentNumber &&
|
|
247
|
-
!!fields?.birthDate,
|
|
248
|
-
[]
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Log detailed MRZ information for debugging and verification
|
|
253
|
-
*/
|
|
254
|
-
const logMRZDetails = useCallback(
|
|
255
|
-
(
|
|
256
|
-
stepName: string,
|
|
257
|
-
fields: any,
|
|
258
|
-
mrzText: string | null,
|
|
259
|
-
consecutiveReads: number,
|
|
260
|
-
isDebugMode: boolean
|
|
261
|
-
) => {
|
|
262
|
-
if (isDebugMode) {
|
|
263
|
-
debugLog(
|
|
264
|
-
'IdentityDocumentCamera',
|
|
265
|
-
`[${stepName}] MRZ validated successfully (consistent reads: ${consecutiveReads})`
|
|
266
|
-
);
|
|
267
|
-
debugLog('IdentityDocumentCamera', `[${stepName}] Final MRZ Fields:`, {
|
|
268
|
-
documentNumber: fields?.documentNumber,
|
|
269
|
-
name: `${fields?.lastName} ${fields?.firstName}`,
|
|
270
|
-
birthDate: fields?.birthDate,
|
|
271
|
-
expirationDate: fields?.expirationDate,
|
|
272
|
-
nationality: fields?.nationality || fields?.issuingState,
|
|
273
|
-
sex: fields?.sex,
|
|
274
|
-
personalId: fields?.optional1,
|
|
275
|
-
});
|
|
276
|
-
if (mrzText) {
|
|
277
|
-
const mrzLines = mrzText
|
|
278
|
-
.split('\n')
|
|
279
|
-
.map((l) => l.replace(/\s/g, ''))
|
|
280
|
-
.filter((l) => l.length >= 20 && /^[A-Z0-9<]+$/.test(l));
|
|
281
|
-
debugLog(
|
|
282
|
-
'IdentityDocumentCamera',
|
|
283
|
-
`[${stepName}] MRZ lines (${mrzLines.length}):`
|
|
284
|
-
);
|
|
285
|
-
mrzLines.forEach((line, idx) => {
|
|
286
|
-
debugLog('IdentityDocumentCamera', ` ${idx + 1}: ${line}`);
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
},
|
|
291
|
-
[]
|
|
292
|
-
);
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Log MRZ validation failure details for debugging
|
|
296
|
-
*/
|
|
297
|
-
const logMRZValidationFailure = useCallback(
|
|
298
|
-
(
|
|
299
|
-
stepName: string,
|
|
300
|
-
hasRequiredFields: boolean,
|
|
301
|
-
parsedData: any,
|
|
302
|
-
retryCount: number,
|
|
303
|
-
isDebugMode: boolean
|
|
304
|
-
) => {
|
|
305
|
-
if (isDebugMode) {
|
|
306
|
-
const debugInfo: any = {
|
|
307
|
-
hasRequiredFields,
|
|
308
|
-
isValid: parsedData?.valid,
|
|
309
|
-
retryCount,
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
if (parsedData?.valid) {
|
|
313
|
-
debugInfo.consistentReads = validMRZConsecutiveCount.current;
|
|
314
|
-
debugInfo.requiredReads = REQUIRED_CONSISTENT_MRZ_READS;
|
|
315
|
-
debugInfo.fieldsMatch = areMRZFieldsEqual(
|
|
316
|
-
lastValidMRZFields.current,
|
|
317
|
-
parsedData?.fields
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
debugLog(
|
|
322
|
-
'IdentityDocumentCamera',
|
|
323
|
-
`[${stepName}] MRZ detected but validation failed - retrying`,
|
|
324
|
-
debugInfo
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
[areMRZFieldsEqual]
|
|
329
|
-
);
|
|
330
|
-
|
|
331
172
|
const lastHologramCaptureTime = useRef(0);
|
|
332
|
-
const HOLOGRAM_CAPTURE_INTERVAL = 250; // ms between captures - allows flash to fully stabilize for accurate diff
|
|
333
173
|
const hologramFramesWithoutFace = useRef(0); // Track consecutive frames without face during hologram collection
|
|
334
|
-
const
|
|
174
|
+
const isHologramDetectionInProgress = useRef(false); // Prevent concurrent hologram detection calls
|
|
175
|
+
const isCompletionCallbackInvoked = useRef(false); // Prevent multiple callback invocations when COMPLETED
|
|
176
|
+
const isStepTransitionInProgress = useRef(false); // Prevent duplicate step transitions from rapid frames
|
|
335
177
|
|
|
336
178
|
const faceDetectionErrorCount = useRef(0);
|
|
337
179
|
const brightnessHistory = useRef<number[]>([]);
|
|
@@ -420,6 +262,8 @@ const IdentityDocumentCamera = ({
|
|
|
420
262
|
useEffect(() => {
|
|
421
263
|
if (isFocused && hasPermission && hasGuideShown) {
|
|
422
264
|
setIsActive(true);
|
|
265
|
+
isCompletionCallbackInvoked.current = false; // Reset callback flag when starting new scan
|
|
266
|
+
isStepTransitionInProgress.current = false;
|
|
423
267
|
} else {
|
|
424
268
|
setIsActive(false);
|
|
425
269
|
faceImages.current = [];
|
|
@@ -432,11 +276,14 @@ const IdentityDocumentCamera = ({
|
|
|
432
276
|
lastValidMRZText.current = null;
|
|
433
277
|
lastValidMRZFields.current = null;
|
|
434
278
|
validMRZConsecutiveCount.current = 0;
|
|
435
|
-
|
|
436
|
-
lastValidMRZFields.current = null;
|
|
437
|
-
validMRZConsecutiveCount.current = 0;
|
|
438
|
-
cachedBarcode.current = null; // Clear cached barcode on new scan
|
|
279
|
+
cachedBarcode.current = null;
|
|
439
280
|
lastVoiceGuidanceMessage.current = '';
|
|
281
|
+
isCompletionCallbackInvoked.current = false;
|
|
282
|
+
isStepTransitionInProgress.current = false;
|
|
283
|
+
// Clear all captured image states from previous scan
|
|
284
|
+
setCurrentFaceImage(undefined);
|
|
285
|
+
setCurrentHologramImage(undefined);
|
|
286
|
+
setCurrentSecondaryFaceImage(undefined);
|
|
440
287
|
resetLastMessage();
|
|
441
288
|
}
|
|
442
289
|
|
|
@@ -447,88 +294,37 @@ const IdentityDocumentCamera = ({
|
|
|
447
294
|
setHologramImageCount(0);
|
|
448
295
|
setLatestHologramFaceImage(undefined);
|
|
449
296
|
lastVoiceGuidanceMessage.current = '';
|
|
297
|
+
isCompletionCallbackInvoked.current = false; // Reset callback flag on unmount
|
|
298
|
+
isStepTransitionInProgress.current = false;
|
|
299
|
+
// Clear all captured image states on unmount
|
|
300
|
+
setCurrentFaceImage(undefined);
|
|
301
|
+
setCurrentHologramImage(undefined);
|
|
302
|
+
setCurrentSecondaryFaceImage(undefined);
|
|
450
303
|
resetLastMessage();
|
|
451
304
|
};
|
|
452
305
|
}, [isFocused, hasPermission, hasGuideShown]);
|
|
453
306
|
|
|
454
307
|
useEffect(() => {
|
|
455
|
-
if (
|
|
456
|
-
|
|
457
|
-
|
|
308
|
+
if (
|
|
309
|
+
!hasGuideShown ||
|
|
310
|
+
!appContext.currentWorkflowStep?.data?.voiceGuidanceActive
|
|
311
|
+
)
|
|
312
|
+
return;
|
|
458
313
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
: t('identityDocumentCamera.alignPhotoSide');
|
|
470
|
-
} else if (isBrightnessLow) {
|
|
471
|
-
message = t('identityDocumentCamera.lowBrightness');
|
|
472
|
-
} else if (isFrameBlurry) {
|
|
473
|
-
message = t('identityDocumentCamera.avoidBlur');
|
|
474
|
-
} else if (
|
|
475
|
-
status === 'SCANNING' &&
|
|
476
|
-
allElementsDetected &&
|
|
477
|
-
elementsOutsideScanArea.length === 0
|
|
478
|
-
) {
|
|
479
|
-
message =
|
|
480
|
-
nextStep === 'SCAN_ID_BACK'
|
|
481
|
-
? t('identityDocumentCamera.idCardBackDetected')
|
|
482
|
-
: detectedDocumentType === 'PASSPORT'
|
|
483
|
-
? t('identityDocumentCamera.passportDetected')
|
|
484
|
-
: detectedDocumentType === 'ID_FRONT'
|
|
485
|
-
? t('identityDocumentCamera.idCardFrontDetected')
|
|
486
|
-
: nextStep === 'SCAN_HOLOGRAM'
|
|
487
|
-
? t('identityDocumentCamera.alignHologram')
|
|
488
|
-
: t('identityDocumentCamera.readingDocument');
|
|
489
|
-
} else if (elementsOutsideScanArea.length > 0) {
|
|
490
|
-
message = t('identityDocumentCamera.centerDocument');
|
|
491
|
-
} else if (
|
|
492
|
-
(status === 'SCANNING' || status === 'SEARCHING') &&
|
|
493
|
-
!allElementsDetected
|
|
494
|
-
) {
|
|
495
|
-
message =
|
|
496
|
-
nextStep === 'SCAN_ID_BACK'
|
|
497
|
-
? t('identityDocumentCamera.alignIDBack')
|
|
498
|
-
: nextStep === 'SCAN_ID_FRONT_OR_PASSPORT'
|
|
499
|
-
? detectedDocumentType === 'PASSPORT'
|
|
500
|
-
? t('identityDocumentCamera.alignPassport')
|
|
501
|
-
: detectedDocumentType === 'ID_FRONT'
|
|
502
|
-
? t('identityDocumentCamera.alignIDFront')
|
|
503
|
-
: t('identityDocumentCamera.alignPhotoSide')
|
|
504
|
-
: nextStep === 'SCAN_HOLOGRAM'
|
|
505
|
-
? t('identityDocumentCamera.alignHologram')
|
|
506
|
-
: t('identityDocumentCamera.readingDocument');
|
|
507
|
-
} else {
|
|
508
|
-
message =
|
|
509
|
-
nextStep === 'SCAN_ID_FRONT_OR_PASSPORT'
|
|
510
|
-
? status === 'SCANNING'
|
|
511
|
-
? t('identityDocumentCamera.readingDocument')
|
|
512
|
-
: t('identityDocumentCamera.alignPhotoSide')
|
|
513
|
-
: nextStep === 'SCAN_HOLOGRAM'
|
|
514
|
-
? t('identityDocumentCamera.alignHologram')
|
|
515
|
-
: nextStep === 'SCAN_ID_BACK'
|
|
516
|
-
? status === 'SCANNING'
|
|
517
|
-
? t('identityDocumentCamera.readingDocument')
|
|
518
|
-
: t('identityDocumentCamera.alignIDBackSide')
|
|
519
|
-
: nextStep === 'COMPLETED'
|
|
520
|
-
? t('identityDocumentCamera.scanCompleted')
|
|
521
|
-
: '';
|
|
522
|
-
}
|
|
314
|
+
const message = getStatusMessage(
|
|
315
|
+
nextStep,
|
|
316
|
+
status,
|
|
317
|
+
detectedDocumentType,
|
|
318
|
+
isBrightnessLow,
|
|
319
|
+
isFrameBlurry,
|
|
320
|
+
allElementsDetected,
|
|
321
|
+
elementsOutsideScanArea,
|
|
322
|
+
t
|
|
323
|
+
);
|
|
523
324
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
message !== lastVoiceGuidanceMessage.current
|
|
528
|
-
) {
|
|
529
|
-
lastVoiceGuidanceMessage.current = message;
|
|
530
|
-
speak(message, true);
|
|
531
|
-
}
|
|
325
|
+
if (message && message !== lastVoiceGuidanceMessage.current) {
|
|
326
|
+
lastVoiceGuidanceMessage.current = message;
|
|
327
|
+
speak(message, true);
|
|
532
328
|
}
|
|
533
329
|
}, [
|
|
534
330
|
appContext.currentWorkflowStep?.data?.voiceGuidanceActive,
|
|
@@ -537,8 +333,6 @@ const IdentityDocumentCamera = ({
|
|
|
537
333
|
isFrameBlurry,
|
|
538
334
|
nextStep,
|
|
539
335
|
status,
|
|
540
|
-
completedStep,
|
|
541
|
-
currentFaceImage,
|
|
542
336
|
detectedDocumentType,
|
|
543
337
|
allElementsDetected,
|
|
544
338
|
elementsOutsideScanArea,
|
|
@@ -563,6 +357,14 @@ const IdentityDocumentCamera = ({
|
|
|
563
357
|
}
|
|
564
358
|
}, [nextStep]);
|
|
565
359
|
|
|
360
|
+
// Reset completion callback flag when transitioning away from COMPLETED
|
|
361
|
+
useEffect(() => {
|
|
362
|
+
if (nextStep !== 'COMPLETED') {
|
|
363
|
+
isCompletionCallbackInvoked.current = false;
|
|
364
|
+
}
|
|
365
|
+
isStepTransitionInProgress.current = false;
|
|
366
|
+
}, [nextStep]);
|
|
367
|
+
|
|
566
368
|
// Error flash animation - flash red text when wrong side detected
|
|
567
369
|
useEffect(() => {
|
|
568
370
|
if (status === 'INCORRECT') {
|
|
@@ -611,17 +413,22 @@ const IdentityDocumentCamera = ({
|
|
|
611
413
|
[]
|
|
612
414
|
);
|
|
613
415
|
|
|
614
|
-
// Native OpenCV: compare
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
): Promise<boolean> => {
|
|
416
|
+
// Native OpenCV: compare face visual similarity (device-side validation before backend FaceNet)
|
|
417
|
+
const compareFaceVisualSimilarityNative = async (
|
|
418
|
+
faceImage1: string,
|
|
419
|
+
faceImage2: string
|
|
420
|
+
): Promise<{ similarity: number } | null> => {
|
|
620
421
|
try {
|
|
621
|
-
if (!
|
|
622
|
-
return await OpenCVModule.
|
|
422
|
+
if (!faceImage1 || !faceImage2) return null;
|
|
423
|
+
return await OpenCVModule.compareFaceVisualSimilarity(
|
|
424
|
+
faceImage1,
|
|
425
|
+
faceImage2
|
|
426
|
+
);
|
|
623
427
|
} catch (error) {
|
|
624
|
-
|
|
428
|
+
if (isDebugEnabled()) {
|
|
429
|
+
logError('[Face Visual Similarity] Comparison error:', error);
|
|
430
|
+
}
|
|
431
|
+
return null;
|
|
625
432
|
}
|
|
626
433
|
};
|
|
627
434
|
|
|
@@ -630,7 +437,8 @@ const IdentityDocumentCamera = ({
|
|
|
630
437
|
facesToDetect: Face[],
|
|
631
438
|
image: string,
|
|
632
439
|
width: number,
|
|
633
|
-
height: number
|
|
440
|
+
height: number,
|
|
441
|
+
widerRightPadding = false
|
|
634
442
|
): Promise<string[]> => {
|
|
635
443
|
if (!facesToDetect.length || !image || width <= 0 || height <= 0) {
|
|
636
444
|
return [];
|
|
@@ -646,7 +454,8 @@ const IdentityDocumentCamera = ({
|
|
|
646
454
|
image,
|
|
647
455
|
faceBounds,
|
|
648
456
|
width,
|
|
649
|
-
height
|
|
457
|
+
height,
|
|
458
|
+
widerRightPadding
|
|
650
459
|
);
|
|
651
460
|
return croppedFaces ?? [];
|
|
652
461
|
} catch (error) {
|
|
@@ -655,6 +464,62 @@ const IdentityDocumentCamera = ({
|
|
|
655
464
|
}
|
|
656
465
|
};
|
|
657
466
|
|
|
467
|
+
// Check if face image has glare (brightness exceeds threshold)
|
|
468
|
+
const checkFaceGlare = async (faceImage: string): Promise<boolean> => {
|
|
469
|
+
try {
|
|
470
|
+
// Check entire face region for glare
|
|
471
|
+
const hasGlare = await OpenCVModule.isRectangularRegionBright(
|
|
472
|
+
faceImage,
|
|
473
|
+
0,
|
|
474
|
+
0,
|
|
475
|
+
100, // Full face width
|
|
476
|
+
100, // Full face height
|
|
477
|
+
MAX_BRIGHTNESS_THRESHOLD
|
|
478
|
+
);
|
|
479
|
+
return hasGlare;
|
|
480
|
+
} catch (error) {
|
|
481
|
+
return false; // Assume no glare on error
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
// Check if face is fully visible (not cropped at edges)
|
|
486
|
+
const isFaceFullyVisible = (
|
|
487
|
+
face: Face,
|
|
488
|
+
frameWidth: number,
|
|
489
|
+
frameHeight: number
|
|
490
|
+
): boolean => {
|
|
491
|
+
const margin = FACE_EDGE_MARGIN_PERCENT;
|
|
492
|
+
const bounds = face.bounds;
|
|
493
|
+
return (
|
|
494
|
+
bounds.x >= frameWidth * margin &&
|
|
495
|
+
bounds.y >= frameHeight * margin &&
|
|
496
|
+
bounds.x + bounds.width <= frameWidth * (1 - margin) &&
|
|
497
|
+
bounds.y + bounds.height <= frameHeight * (1 - margin)
|
|
498
|
+
);
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
// Check if document image has glare
|
|
502
|
+
const checkDocumentGlare = async (
|
|
503
|
+
image: string,
|
|
504
|
+
width: number,
|
|
505
|
+
height: number
|
|
506
|
+
): Promise<boolean> => {
|
|
507
|
+
try {
|
|
508
|
+
// Check center 80% region for glare (document area)
|
|
509
|
+
const hasGlare = await OpenCVModule.isRectangularRegionBright(
|
|
510
|
+
image,
|
|
511
|
+
Math.round(width * 0.1),
|
|
512
|
+
Math.round(height * 0.1),
|
|
513
|
+
Math.round(width * 0.8),
|
|
514
|
+
Math.round(height * 0.8),
|
|
515
|
+
MAX_BRIGHTNESS_THRESHOLD
|
|
516
|
+
);
|
|
517
|
+
return hasGlare;
|
|
518
|
+
} catch (error) {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
|
|
658
523
|
const setNextStepAndVibrate = useCallback(
|
|
659
524
|
(
|
|
660
525
|
nextStepType:
|
|
@@ -670,15 +535,23 @@ const IdentityDocumentCamera = ({
|
|
|
670
535
|
|
|
671
536
|
// Turn flash on and reset hologram counters when entering SCAN_HOLOGRAM
|
|
672
537
|
if (nextStepType === 'SCAN_HOLOGRAM' && fromStep !== 'SCAN_HOLOGRAM') {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
538
|
+
const isMidCollection =
|
|
539
|
+
faceImages.current.length > 0 &&
|
|
540
|
+
faceImages.current.length < HOLOGRAM_IMAGE_COUNT;
|
|
541
|
+
|
|
542
|
+
if (!isMidCollection) {
|
|
543
|
+
setIsTorchOn(true);
|
|
544
|
+
hologramDetectionCurrentRetryCount.current = 0;
|
|
545
|
+
secondaryFaceDetectionCurrentRetryCount.current = 0;
|
|
546
|
+
hologramFramesWithoutFace.current = 0;
|
|
547
|
+
faceImages.current = [];
|
|
548
|
+
hologramImageCountRef.current = 0;
|
|
549
|
+
setHologramImageCount(0);
|
|
550
|
+
setLatestHologramFaceImage(undefined);
|
|
551
|
+
// Clear previous hologram state to prevent premature completion
|
|
552
|
+
setCurrentHologramImage(undefined);
|
|
553
|
+
setCurrentHologramMaskImage(undefined);
|
|
554
|
+
}
|
|
682
555
|
}
|
|
683
556
|
|
|
684
557
|
// Clean up flash and hologram state when leaving SCAN_HOLOGRAM step
|
|
@@ -688,15 +561,11 @@ const IdentityDocumentCamera = ({
|
|
|
688
561
|
hologramImageCountRef.current = 0;
|
|
689
562
|
setHologramImageCount(0);
|
|
690
563
|
setLatestHologramFaceImage(undefined);
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
console.log(
|
|
697
|
-
'[Flash] Turning off flash and clearing hologram images when leaving step'
|
|
698
|
-
);
|
|
699
|
-
}
|
|
564
|
+
isHologramDetectionInProgress.current = false;
|
|
565
|
+
lastFacePosition.current = null;
|
|
566
|
+
cachedBarcode.current = null;
|
|
567
|
+
setDocumentPlaneBounds(null);
|
|
568
|
+
setSecondaryFaceBounds(null);
|
|
700
569
|
}
|
|
701
570
|
|
|
702
571
|
setNextStep(nextStepType);
|
|
@@ -704,7 +573,12 @@ const IdentityDocumentCamera = ({
|
|
|
704
573
|
|
|
705
574
|
// Reset MRZ retry counter for each new step so retries start fresh
|
|
706
575
|
mrzDetectionCurrentRetryCount.current = 0;
|
|
707
|
-
|
|
576
|
+
// Only clear MRZ text when entering SCAN_ID_BACK (new MRZ expected).
|
|
577
|
+
// Preserve across SCAN_HOLOGRAM so passport completion has MRZ data.
|
|
578
|
+
if (nextStepType === 'SCAN_ID_BACK') {
|
|
579
|
+
lastValidMRZText.current = null;
|
|
580
|
+
lastValidMRZFields.current = null;
|
|
581
|
+
}
|
|
708
582
|
validMRZConsecutiveCount.current = 0;
|
|
709
583
|
cachedBarcode.current = null; // Clear cached barcode on step change
|
|
710
584
|
|
|
@@ -718,6 +592,50 @@ const IdentityDocumentCamera = ({
|
|
|
718
592
|
[setIsTorchOn]
|
|
719
593
|
);
|
|
720
594
|
|
|
595
|
+
const transitionStepWithCallback = useCallback(
|
|
596
|
+
(
|
|
597
|
+
nextStepType:
|
|
598
|
+
| 'SCAN_ID_FRONT_OR_PASSPORT'
|
|
599
|
+
| 'SCAN_ID_BACK'
|
|
600
|
+
| 'SCAN_HOLOGRAM'
|
|
601
|
+
| 'COMPLETED',
|
|
602
|
+
fromStep: 'SCAN_ID_FRONT_OR_PASSPORT' | 'SCAN_ID_BACK' | 'SCAN_HOLOGRAM',
|
|
603
|
+
scannedData: DocumentScannedData
|
|
604
|
+
) => {
|
|
605
|
+
if (isStepTransitionInProgress.current) {
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
isStepTransitionInProgress.current = true;
|
|
610
|
+
|
|
611
|
+
// Torch only needed during SCAN_HOLOGRAM - turn off for all other transitions
|
|
612
|
+
if (nextStepType !== 'SCAN_HOLOGRAM') {
|
|
613
|
+
setIsTorchOn(false);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
setNextStepAndVibrate(nextStepType, fromStep);
|
|
617
|
+
|
|
618
|
+
// Prevent the COMPLETED handler from firing a duplicate callback with
|
|
619
|
+
// potentially wrong detectedDocumentType. This transition already sends
|
|
620
|
+
// the correct scannedData below.
|
|
621
|
+
if (nextStepType === 'COMPLETED') {
|
|
622
|
+
isCompletionCallbackInvoked.current = true;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// Only notify parent for step completions, not intermediate transitions.
|
|
626
|
+
// The COMPLETED handler constructs final data from accumulated state.
|
|
627
|
+
// For ID cards, front/back data must be sent incrementally since parent stores them separately.
|
|
628
|
+
const isIntermediatePassportStep =
|
|
629
|
+
scannedData.documentType === 'PASSPORT' && nextStepType !== 'COMPLETED';
|
|
630
|
+
if (!isIntermediatePassportStep) {
|
|
631
|
+
setTimeout(() => {
|
|
632
|
+
onIdentityDocumentScanned(scannedData);
|
|
633
|
+
}, 1000);
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
[onIdentityDocumentScanned, setNextStepAndVibrate, setIsTorchOn]
|
|
637
|
+
);
|
|
638
|
+
|
|
721
639
|
const handleFaceAndText = useCallback(
|
|
722
640
|
async (
|
|
723
641
|
text: string,
|
|
@@ -729,97 +647,98 @@ const IdentityDocumentCamera = ({
|
|
|
729
647
|
elementsOutside?: boolean,
|
|
730
648
|
scannedText?: BlockText
|
|
731
649
|
) => {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
) => {
|
|
739
|
-
// Relaxed signature detection: matches signature/imza variants and OCR errors
|
|
740
|
-
const hasSignatureMatch = /s[gi]g?n[au]?t[u]?r|imz[a]s?/i.test(ocrText);
|
|
741
|
-
|
|
742
|
-
if (isDebugEnabled()) {
|
|
743
|
-
console.log(
|
|
744
|
-
'[DocType] faces:',
|
|
745
|
-
facesParam.length,
|
|
746
|
-
'mrzFields:',
|
|
747
|
-
!!mrzFields,
|
|
748
|
-
'mrzText:',
|
|
749
|
-
!!mrzTextParam,
|
|
750
|
-
'textLen:',
|
|
751
|
-
ocrText?.length,
|
|
752
|
-
'hasSignature:',
|
|
753
|
-
hasSignatureMatch
|
|
754
|
-
);
|
|
755
|
-
}
|
|
650
|
+
// Classify faces: Primary (>= 5% of frame) vs Secondary (< 5%)
|
|
651
|
+
const primaryFaces = faces.filter(
|
|
652
|
+
(face) =>
|
|
653
|
+
face.bounds.width >= frameWidth * MIN_CARD_FACE_SIZE_PERCENT &&
|
|
654
|
+
face.bounds.height >= frameWidth * MIN_CARD_FACE_SIZE_PERCENT
|
|
655
|
+
);
|
|
756
656
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
657
|
+
const secondaryFaces = faces.filter(
|
|
658
|
+
(face) =>
|
|
659
|
+
face.bounds.width < frameWidth * MIN_CARD_FACE_SIZE_PERCENT ||
|
|
660
|
+
face.bounds.height < frameWidth * MIN_CARD_FACE_SIZE_PERCENT
|
|
661
|
+
);
|
|
761
662
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
663
|
+
// All faces for processing
|
|
664
|
+
const allDetectedFaces = faces;
|
|
665
|
+
|
|
666
|
+
// Validate primary face meets ICAO standards (face height 70-80% of image, aspect ratio ~1:1.25)
|
|
667
|
+
let primaryFaceICAOCompliant = false;
|
|
668
|
+
if (primaryFaces.length > 0) {
|
|
669
|
+
const face = primaryFaces[0];
|
|
670
|
+
const faceHeightPercent = (face.bounds.height / frameHeight) * 100;
|
|
671
|
+
const aspectRatio = face.bounds.width / face.bounds.height;
|
|
672
|
+
|
|
673
|
+
// ICAO: face height 70-80% of image, width:height ratio between 0.75 and 0.85
|
|
674
|
+
primaryFaceICAOCompliant =
|
|
675
|
+
faceHeightPercent >= 70 &&
|
|
676
|
+
faceHeightPercent <= 80 &&
|
|
677
|
+
aspectRatio >= 0.75 &&
|
|
678
|
+
aspectRatio <= 0.85;
|
|
679
|
+
}
|
|
766
680
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
681
|
+
if (
|
|
682
|
+
isDebugEnabled() &&
|
|
683
|
+
nextStep === 'SCAN_ID_FRONT_OR_PASSPORT' &&
|
|
684
|
+
faces.length > 0
|
|
685
|
+
) {
|
|
686
|
+
debugLog('IdentityDocumentCamera', '[FACE DETECTION] All faces', {
|
|
687
|
+
totalFaces: faces.length,
|
|
688
|
+
primaryFacesCount: primaryFaces.length,
|
|
689
|
+
secondaryFacesCount: secondaryFaces.length,
|
|
690
|
+
frameWidth,
|
|
691
|
+
frameHeight,
|
|
692
|
+
minPrimarySize: frameWidth * MIN_CARD_FACE_SIZE_PERCENT,
|
|
693
|
+
primaryFaceICAOCompliant,
|
|
694
|
+
faceDetails: faces.map((f, i) => ({
|
|
695
|
+
index: i,
|
|
696
|
+
width: Math.round(f.bounds.width),
|
|
697
|
+
height: Math.round(f.bounds.height),
|
|
698
|
+
x: Math.round(f.bounds.x),
|
|
699
|
+
y: Math.round(f.bounds.y),
|
|
700
|
+
widthPercent:
|
|
701
|
+
((f.bounds.width / frameWidth) * 100).toFixed(1) + '%',
|
|
702
|
+
heightPercent:
|
|
703
|
+
((f.bounds.height / frameHeight) * 100).toFixed(1) + '%',
|
|
704
|
+
aspectRatio: (f.bounds.width / f.bounds.height).toFixed(2),
|
|
705
|
+
category:
|
|
706
|
+
f.bounds.width >= frameWidth * MIN_CARD_FACE_SIZE_PERCENT &&
|
|
707
|
+
f.bounds.height >= frameWidth * MIN_CARD_FACE_SIZE_PERCENT
|
|
708
|
+
? 'primary'
|
|
709
|
+
: 'secondary',
|
|
710
|
+
})),
|
|
711
|
+
});
|
|
712
|
+
}
|
|
774
713
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
714
|
+
// Get scan area bounds for face filtering
|
|
715
|
+
const { isInsideScan } = getScanAreaBounds(frameWidth, frameHeight);
|
|
716
|
+
|
|
717
|
+
// Filter to only faces inside scan area (for hologram, exclude passport secondary faces)
|
|
718
|
+
const facesInsideScanArea = primaryFaces.filter((face) =>
|
|
719
|
+
isInsideScan(
|
|
720
|
+
face.bounds.x,
|
|
721
|
+
face.bounds.y,
|
|
722
|
+
face.bounds.width,
|
|
723
|
+
face.bounds.height
|
|
724
|
+
)
|
|
725
|
+
);
|
|
783
726
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
) {
|
|
797
|
-
// Passport MRZ pattern detected (P<TUR, P<USA, etc.) but not parsed
|
|
798
|
-
// Could be passport with OCR errors - wait for proper parsing
|
|
799
|
-
if (isDebugEnabled()) {
|
|
800
|
-
console.log(
|
|
801
|
-
'[DocType] Passport MRZ pattern (P<XXX) detected but not parsed - returning UNKNOWN to wait for proper classification'
|
|
802
|
-
);
|
|
803
|
-
}
|
|
804
|
-
return 'UNKNOWN';
|
|
805
|
-
}
|
|
806
|
-
return 'ID_FRONT';
|
|
807
|
-
}
|
|
808
|
-
// Also ensure flash is off when scan is completed
|
|
809
|
-
if (nextStep === 'COMPLETED' && isTorchOn) {
|
|
810
|
-
setIsTorchOn(false);
|
|
727
|
+
if (
|
|
728
|
+
isDebugEnabled() &&
|
|
729
|
+
nextStep === 'SCAN_HOLOGRAM' &&
|
|
730
|
+
primaryFaces.length > facesInsideScanArea.length
|
|
731
|
+
) {
|
|
732
|
+
debugLog(
|
|
733
|
+
'IdentityDocumentCamera',
|
|
734
|
+
'[HOLOGRAM] Filtered out faces outside scan area',
|
|
735
|
+
{
|
|
736
|
+
totalFaces: primaryFaces.length,
|
|
737
|
+
facesInside: facesInsideScanArea.length,
|
|
738
|
+
filtered: primaryFaces.length - facesInsideScanArea.length,
|
|
811
739
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
return 'UNKNOWN';
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
// Filter to card-sized faces only (min 5% of frame width to exclude tiny background faces)
|
|
818
|
-
const cardSizedFaces = faces.filter(
|
|
819
|
-
(face) =>
|
|
820
|
-
face.bounds.width >= frameWidth * 0.05 &&
|
|
821
|
-
face.bounds.height >= frameWidth * 0.05
|
|
822
|
-
);
|
|
740
|
+
);
|
|
741
|
+
}
|
|
823
742
|
|
|
824
743
|
// Cache barcode when detected, use cached value if current frame has no barcode
|
|
825
744
|
// This handles inconsistent barcode detection across frames
|
|
@@ -847,27 +766,100 @@ const IdentityDocumentCamera = ({
|
|
|
847
766
|
}
|
|
848
767
|
|
|
849
768
|
if (nextStep === 'COMPLETED') {
|
|
769
|
+
// Prevent multiple callback invocations from repeated frames
|
|
770
|
+
if (isCompletionCallbackInvoked.current) {
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
isCompletionCallbackInvoked.current = true;
|
|
774
|
+
|
|
850
775
|
setStatus('SCANNED');
|
|
851
|
-
|
|
852
|
-
|
|
776
|
+
// Construct scanned data from available state and invoke callback
|
|
777
|
+
// Use MRZ document code as ultimate authority for document type —
|
|
778
|
+
// detectedDocumentType may be wrong if locked from early noisy frames
|
|
779
|
+
const completedDocType =
|
|
780
|
+
lastValidMRZFields.current?.documentCode === 'P'
|
|
781
|
+
? 'PASSPORT'
|
|
782
|
+
: (detectedDocumentType as
|
|
783
|
+
| 'ID_FRONT'
|
|
784
|
+
| 'ID_BACK'
|
|
785
|
+
| 'PASSPORT'
|
|
786
|
+
| 'UNKNOWN');
|
|
787
|
+
const scannedData: DocumentScannedData = {
|
|
788
|
+
documentType: completedDocType,
|
|
789
|
+
image: image ?? '',
|
|
790
|
+
faceImage: currentFaceImage,
|
|
791
|
+
secondaryFaceImage: currentSecondaryFaceImage,
|
|
792
|
+
hologramImage: currentHologramImage,
|
|
793
|
+
mrzText: lastValidMRZText.current ?? undefined,
|
|
794
|
+
mrzFields: lastValidMRZFields.current ?? undefined,
|
|
795
|
+
barcodeValue: barcodeToUse?.rawValue ?? undefined,
|
|
796
|
+
};
|
|
853
797
|
|
|
854
|
-
|
|
798
|
+
if (isDebugEnabled()) {
|
|
799
|
+
debugLog('IdentityDocumentCamera', '[COMPLETED] Final scanned data', {
|
|
800
|
+
documentType: completedDocType,
|
|
801
|
+
hasFaceImage: !!scannedData.faceImage,
|
|
802
|
+
hasSecondaryFace: !!scannedData.secondaryFaceImage,
|
|
803
|
+
secondaryFaceImageLength:
|
|
804
|
+
scannedData.secondaryFaceImage?.length || 0,
|
|
805
|
+
currentSecondaryFaceLength: currentSecondaryFaceImage?.length || 0,
|
|
806
|
+
hasHologramImage: !!scannedData.hologramImage,
|
|
807
|
+
hasMRZ: !!scannedData.mrzFields,
|
|
808
|
+
hasBarcode: !!scannedData.barcodeValue,
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
setTimeout(() => {
|
|
813
|
+
onIdentityDocumentScanned(scannedData);
|
|
814
|
+
}, 500);
|
|
855
815
|
return;
|
|
856
816
|
}
|
|
857
817
|
|
|
858
|
-
|
|
859
|
-
|
|
818
|
+
// Skip elementsOutside check during SCAN_HOLOGRAM - allow document tilting for hologram capture
|
|
819
|
+
if (elementsOutside && nextStep !== 'SCAN_HOLOGRAM') {
|
|
860
820
|
return;
|
|
861
821
|
}
|
|
862
822
|
|
|
863
|
-
//
|
|
823
|
+
// Parse MRZ early to use for document type detection
|
|
824
|
+
// Use JavaScript MRZ validation with corrections
|
|
825
|
+
// Prefer MRZ-only text if available (from detected MRZ blocks),
|
|
826
|
+
// otherwise fall back to all text (for backward compatibility)
|
|
827
|
+
const textForValidation = scannedText?.mrzOnlyText || text;
|
|
828
|
+
const mrzValidationResult =
|
|
829
|
+
mrzUtils.validateMRZWithCorrections(textForValidation);
|
|
830
|
+
const parsedMRZData = {
|
|
831
|
+
valid: mrzValidationResult.valid,
|
|
832
|
+
fields: mrzValidationResult.fields || null,
|
|
833
|
+
};
|
|
834
|
+
// Extract raw MRZ lines from text if validation succeeded
|
|
835
|
+
const mrzText = parsedMRZData.valid ? mrzUtils.fixMRZ(text) : null;
|
|
836
|
+
|
|
837
|
+
// CRITICAL: Only detect document type during initial scan step
|
|
838
|
+
// For SCAN_HOLOGRAM and beyond, use the locked detectedDocumentType to avoid
|
|
839
|
+
// interruptions when user tilts document (MRZ may not be visible)
|
|
840
|
+
// However, if MRZ code 'P' is detected, always use PASSPORT — the lock may
|
|
841
|
+
// be wrong (ID_FRONT locked before passport MRZ became readable)
|
|
842
|
+
const documentType =
|
|
843
|
+
nextStep === 'SCAN_ID_FRONT_OR_PASSPORT'
|
|
844
|
+
? detectDocumentType(
|
|
845
|
+
primaryFaces,
|
|
846
|
+
text,
|
|
847
|
+
parsedMRZData?.fields,
|
|
848
|
+
frameWidth,
|
|
849
|
+
mrzText
|
|
850
|
+
)
|
|
851
|
+
: parsedMRZData?.fields?.documentCode === 'P'
|
|
852
|
+
? 'PASSPORT'
|
|
853
|
+
: detectedDocumentType;
|
|
854
|
+
|
|
855
|
+
// Crop faces once document type is confirmed or we're past the initial step
|
|
864
856
|
const shouldCropFaces =
|
|
865
|
-
|
|
866
|
-
|
|
857
|
+
documentType === 'ID_FRONT' ||
|
|
858
|
+
documentType === 'PASSPORT' ||
|
|
867
859
|
nextStep !== 'SCAN_ID_FRONT_OR_PASSPORT';
|
|
868
860
|
const croppedFaces = shouldCropFaces
|
|
869
861
|
? await getFaceImages(
|
|
870
|
-
|
|
862
|
+
primaryFaces,
|
|
871
863
|
image ?? '',
|
|
872
864
|
frameWidth,
|
|
873
865
|
frameHeight
|
|
@@ -876,95 +868,41 @@ const IdentityDocumentCamera = ({
|
|
|
876
868
|
|
|
877
869
|
// Validate document plane consistency across all captures
|
|
878
870
|
let facePositionValid = true;
|
|
879
|
-
if (
|
|
880
|
-
const currentFaceBounds =
|
|
871
|
+
if (primaryFaces.length > 0 && primaryFaces[0]) {
|
|
872
|
+
const currentFaceBounds = primaryFaces[0].bounds;
|
|
881
873
|
if (lastFacePosition.current) {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
);
|
|
887
|
-
const yDiff = Math.abs(
|
|
888
|
-
currentFaceBounds.y - lastFacePosition.current.y
|
|
889
|
-
);
|
|
890
|
-
const widthDiff = Math.abs(
|
|
891
|
-
currentFaceBounds.width - lastFacePosition.current.width
|
|
892
|
-
);
|
|
893
|
-
const heightDiff = Math.abs(
|
|
894
|
-
currentFaceBounds.height - lastFacePosition.current.height
|
|
895
|
-
);
|
|
896
|
-
|
|
897
|
-
const tolerance = nextStep === 'SCAN_HOLOGRAM' ? 0.5 : 0.2;
|
|
898
|
-
const xTolerance = lastFacePosition.current.width * tolerance;
|
|
899
|
-
const yTolerance = lastFacePosition.current.height * tolerance;
|
|
900
|
-
const sizeTolerance = lastFacePosition.current.width * tolerance;
|
|
901
|
-
|
|
902
|
-
facePositionValid =
|
|
903
|
-
xDiff <= xTolerance &&
|
|
904
|
-
yDiff <= yTolerance &&
|
|
905
|
-
widthDiff <= sizeTolerance &&
|
|
906
|
-
heightDiff <= sizeTolerance;
|
|
907
|
-
|
|
908
|
-
if (!facePositionValid) {
|
|
909
|
-
if (isDebugEnabled()) {
|
|
910
|
-
console.log(
|
|
911
|
-
`[DocPlane] Face position changed - document moved (xDiff=${xDiff.toFixed(1)}, yDiff=${yDiff.toFixed(1)}) - rejecting frame`
|
|
912
|
-
);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
// Update reference position to follow gradual movement (sliding window)
|
|
917
|
-
lastFacePosition.current = {
|
|
918
|
-
x: currentFaceBounds.x,
|
|
919
|
-
y: currentFaceBounds.y,
|
|
920
|
-
width: currentFaceBounds.width,
|
|
921
|
-
height: currentFaceBounds.height,
|
|
922
|
-
};
|
|
923
|
-
} else {
|
|
924
|
-
// First capture - store reference position
|
|
925
|
-
lastFacePosition.current = {
|
|
926
|
-
x: currentFaceBounds.x,
|
|
927
|
-
y: currentFaceBounds.y,
|
|
928
|
-
width: currentFaceBounds.width,
|
|
929
|
-
height: currentFaceBounds.height,
|
|
930
|
-
};
|
|
931
|
-
console.log(
|
|
932
|
-
'[DocPlane] Stored reference face position for document plane validation'
|
|
874
|
+
facePositionValid = validateFacePosition(
|
|
875
|
+
currentFaceBounds,
|
|
876
|
+
lastFacePosition.current,
|
|
877
|
+
nextStep === 'SCAN_HOLOGRAM'
|
|
933
878
|
);
|
|
934
879
|
}
|
|
935
880
|
|
|
936
|
-
// Update
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
const screenAspect = screen.width / screen.height;
|
|
944
|
-
|
|
945
|
-
let scale: number;
|
|
946
|
-
let offsetX = 0;
|
|
947
|
-
let offsetY = 0;
|
|
948
|
-
|
|
949
|
-
if (frameAspect > screenAspect) {
|
|
950
|
-
// Frame is wider - scale by height, crop width
|
|
951
|
-
scale = screen.height / frameDimensions.height;
|
|
952
|
-
offsetX = (frameDimensions.width * scale - screen.width) / 2;
|
|
953
|
-
} else {
|
|
954
|
-
// Frame is taller - scale by width, crop height
|
|
955
|
-
scale = screen.width / frameDimensions.width;
|
|
956
|
-
offsetY = (frameDimensions.height * scale - screen.height) / 2;
|
|
957
|
-
}
|
|
881
|
+
// Update reference position (sliding window)
|
|
882
|
+
lastFacePosition.current = {
|
|
883
|
+
x: currentFaceBounds.x,
|
|
884
|
+
y: currentFaceBounds.y,
|
|
885
|
+
width: currentFaceBounds.width,
|
|
886
|
+
height: currentFaceBounds.height,
|
|
887
|
+
};
|
|
958
888
|
|
|
889
|
+
// Update debug overlay bounds
|
|
890
|
+
if (facePositionValid && frameDimensions) {
|
|
891
|
+
const { scale, offsetX, offsetY } = getFrameToScreenTransform(
|
|
892
|
+
frameDimensions.width,
|
|
893
|
+
frameDimensions.height
|
|
894
|
+
);
|
|
959
895
|
const cropPadding = Math.max(
|
|
960
896
|
currentFaceBounds.width * 0.15,
|
|
961
897
|
currentFaceBounds.height * 0.15
|
|
962
898
|
);
|
|
963
899
|
setDocumentPlaneBounds({
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
900
|
+
...transformBoundsToScreen(
|
|
901
|
+
currentFaceBounds,
|
|
902
|
+
scale,
|
|
903
|
+
offsetX,
|
|
904
|
+
offsetY
|
|
905
|
+
),
|
|
968
906
|
cropPadding: cropPadding * scale,
|
|
969
907
|
});
|
|
970
908
|
}
|
|
@@ -977,38 +915,40 @@ const IdentityDocumentCamera = ({
|
|
|
977
915
|
shouldCropFaces &&
|
|
978
916
|
croppedFaces.length > 0 &&
|
|
979
917
|
croppedFaces[0] &&
|
|
980
|
-
facePositionValid
|
|
918
|
+
facePositionValid &&
|
|
919
|
+
!currentFaceImage
|
|
981
920
|
) {
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
921
|
+
// Validate face quality before accepting
|
|
922
|
+
const faceFullyVisible =
|
|
923
|
+
primaryFaces[0] &&
|
|
924
|
+
isFaceFullyVisible(primaryFaces[0], frameWidth, frameHeight);
|
|
925
|
+
const hasGlare = await checkFaceGlare(croppedFaces[0]);
|
|
926
|
+
|
|
927
|
+
if (!faceFullyVisible || hasGlare) {
|
|
928
|
+
// Reject face with glare or partially visible
|
|
986
929
|
if (isDebugEnabled()) {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
);
|
|
930
|
+
debugLog('IdentityDocumentCamera', '[FACE] Rejected', {
|
|
931
|
+
fullyVisible: faceFullyVisible,
|
|
932
|
+
hasGlare,
|
|
933
|
+
});
|
|
992
934
|
}
|
|
935
|
+
// Continue scanning without locking this face
|
|
936
|
+
} else {
|
|
937
|
+
faceImageToUse = croppedFaces[0];
|
|
938
|
+
setCurrentFaceImage(croppedFaces[0]);
|
|
993
939
|
}
|
|
994
940
|
}
|
|
995
941
|
|
|
942
|
+
// Skip OCR text checks during SCAN_HOLOGRAM - flash and tilting make text unreadable
|
|
943
|
+
// but we only need face detection for hologram collection
|
|
996
944
|
if (!text || text.length < 5 || !image) {
|
|
997
|
-
|
|
998
|
-
|
|
945
|
+
if (nextStep !== 'SCAN_HOLOGRAM') {
|
|
946
|
+
setStatus('SEARCHING');
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
// During SCAN_HOLOGRAM, allow processing even if text is not readable
|
|
999
950
|
}
|
|
1000
951
|
|
|
1001
|
-
// Use JavaScript MRZ validation with corrections
|
|
1002
|
-
// Prefer MRZ-only text if available (from detected MRZ blocks),
|
|
1003
|
-
// otherwise fall back to all text (for backward compatibility)
|
|
1004
|
-
const textForValidation = scannedText?.mrzOnlyText || text;
|
|
1005
|
-
const mrzValidationResult =
|
|
1006
|
-
mrzUtils.validateMRZWithCorrections(textForValidation);
|
|
1007
|
-
const parsedMRZData = {
|
|
1008
|
-
valid: mrzValidationResult.valid,
|
|
1009
|
-
fields: mrzValidationResult.fields || null,
|
|
1010
|
-
};
|
|
1011
|
-
|
|
1012
952
|
// Capture test mode data
|
|
1013
953
|
if (testMode && text && text.includes('<')) {
|
|
1014
954
|
const mrzOnlyText = scannedText?.mrzOnlyText || text;
|
|
@@ -1018,36 +958,12 @@ const IdentityDocumentCamera = ({
|
|
|
1018
958
|
});
|
|
1019
959
|
}
|
|
1020
960
|
|
|
1021
|
-
//
|
|
1022
|
-
|
|
1023
|
-
const mrzLines = text
|
|
1024
|
-
.split('\n')
|
|
1025
|
-
.filter((line) => line.includes('<') && line.length > 20);
|
|
1026
|
-
if (mrzLines.length >= 2) {
|
|
1027
|
-
console.log(
|
|
1028
|
-
'[MRZ Debug] Raw OCR text lines:',
|
|
1029
|
-
mrzLines.map((l) => `"${l}"`)
|
|
1030
|
-
);
|
|
1031
|
-
console.log('[MRZ Debug] Validation result:', {
|
|
1032
|
-
valid: mrzValidationResult.valid,
|
|
1033
|
-
format: mrzValidationResult.format,
|
|
1034
|
-
documentCode: mrzValidationResult.fields?.documentCode,
|
|
1035
|
-
documentNumber: mrzValidationResult.fields?.documentNumber,
|
|
1036
|
-
optional1: mrzValidationResult.fields?.optional1,
|
|
1037
|
-
error: mrzValidationResult.error,
|
|
1038
|
-
});
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
// Extract raw MRZ lines from text if validation succeeded
|
|
1043
|
-
const mrzText = parsedMRZData.valid ? mrzUtils.fixMRZ(text) : null;
|
|
1044
|
-
|
|
1045
|
-
// MRZ stability check - require consistent valid reads to avoid OCR noise
|
|
1046
|
-
// Compare parsed field values instead of raw text to handle OCR variations in filler characters
|
|
1047
|
-
// Only proceed with MRZ if it's actually valid and has all required fields
|
|
961
|
+
// MRZ stability: require consistent valid reads across frames
|
|
962
|
+
// Skip during SCAN_HOLOGRAM - document type already locked
|
|
1048
963
|
const mrzHasRequiredFields = hasRequiredMRZFields(parsedMRZData?.fields);
|
|
1049
964
|
|
|
1050
965
|
if (
|
|
966
|
+
nextStep !== 'SCAN_HOLOGRAM' &&
|
|
1051
967
|
mrzText &&
|
|
1052
968
|
parsedMRZData?.valid === true &&
|
|
1053
969
|
parsedMRZData?.fields &&
|
|
@@ -1056,23 +972,14 @@ const IdentityDocumentCamera = ({
|
|
|
1056
972
|
const currentFields = parsedMRZData.fields;
|
|
1057
973
|
|
|
1058
974
|
if (areMRZFieldsEqual(lastValidMRZFields.current, currentFields)) {
|
|
1059
|
-
// Same MRZ data detected again - increment counter
|
|
1060
975
|
validMRZConsecutiveCount.current++;
|
|
1061
976
|
} else {
|
|
1062
|
-
// Different MRZ data - reset counter and store new data
|
|
1063
|
-
if (isDebugEnabled()) {
|
|
1064
|
-
console.log(
|
|
1065
|
-
`[MRZ Stability] New MRZ detected, resetting counter (was ${validMRZConsecutiveCount.current}, doc: ${currentFields.documentNumber?.slice(-4)})`
|
|
1066
|
-
);
|
|
1067
|
-
}
|
|
1068
977
|
lastValidMRZFields.current = currentFields;
|
|
1069
978
|
lastValidMRZText.current = mrzText;
|
|
1070
979
|
validMRZConsecutiveCount.current = 1;
|
|
1071
980
|
}
|
|
1072
|
-
} else {
|
|
1073
|
-
// Invalid or no MRZ - don't reset completely, just skip this frame
|
|
1074
|
-
// This allows temporary OCR noise without losing progress
|
|
1075
981
|
}
|
|
982
|
+
// else: Invalid/no MRZ - skip frame without resetting (allows temporary OCR noise)
|
|
1076
983
|
|
|
1077
984
|
// Check if we have enough consistent valid reads
|
|
1078
985
|
const mrzStableAndValid =
|
|
@@ -1080,276 +987,149 @@ const IdentityDocumentCamera = ({
|
|
|
1080
987
|
parsedMRZData?.valid === true &&
|
|
1081
988
|
areMRZFieldsEqual(lastValidMRZFields.current, parsedMRZData?.fields);
|
|
1082
989
|
|
|
1083
|
-
//
|
|
1084
|
-
//
|
|
1085
|
-
//
|
|
990
|
+
// ============================================================================
|
|
991
|
+
// SCAN_ID_BACK STEP - Validate MRZ + barcode on back of ID card
|
|
992
|
+
// ============================================================================
|
|
1086
993
|
if (nextStep === 'SCAN_ID_BACK') {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
994
|
+
const handleIdBackStep = async () => {
|
|
995
|
+
// Guard: wrong side detection (front or passport when back is expected)
|
|
996
|
+
const hasFaces = primaryFaces.length > 0;
|
|
997
|
+
const hasSignature = /signature|imza|İmza/i.test(text);
|
|
998
|
+
const hasPassportMRZ = parsedMRZData?.fields?.documentCode === 'P';
|
|
999
|
+
const hasPassportMRZPattern =
|
|
1000
|
+
mrzText && PASSPORT_MRZ_PATTERN.test(mrzText);
|
|
1094
1001
|
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
`[ID_BACK Scan] Wrong side detected - faces: ${hasFaces}, signature: ${hasSignature}, passport MRZ: ${hasPassportMRZ}, passport pattern: ${hasPassportMRZPattern}`
|
|
1104
|
-
);
|
|
1002
|
+
if (
|
|
1003
|
+
hasFaces ||
|
|
1004
|
+
hasSignature ||
|
|
1005
|
+
hasPassportMRZ ||
|
|
1006
|
+
hasPassportMRZPattern
|
|
1007
|
+
) {
|
|
1008
|
+
setStatus('INCORRECT');
|
|
1009
|
+
return;
|
|
1105
1010
|
}
|
|
1106
|
-
setStatus('INCORRECT');
|
|
1107
|
-
return;
|
|
1108
|
-
}
|
|
1109
1011
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
if (isDebugEnabled()) {
|
|
1114
|
-
console.log(
|
|
1115
|
-
'[ID_BACK Scan] ERROR: Passport detected in ID_BACK step - skipping to COMPLETED'
|
|
1116
|
-
);
|
|
1117
|
-
}
|
|
1118
|
-
setNextStepAndVibrate('COMPLETED', 'SCAN_ID_BACK');
|
|
1119
|
-
setTimeout(() => {
|
|
1120
|
-
onIdentityDocumentScanned({
|
|
1012
|
+
// Safety: passport somehow reached ID_BACK step
|
|
1013
|
+
if (detectedDocumentType === 'PASSPORT') {
|
|
1014
|
+
transitionStepWithCallback('COMPLETED', 'SCAN_ID_BACK', {
|
|
1121
1015
|
image,
|
|
1122
1016
|
documentType: 'PASSPORT',
|
|
1123
1017
|
mrzText: mrzText ?? undefined,
|
|
1124
1018
|
mrzFields: parsedMRZData?.fields,
|
|
1125
1019
|
});
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
}
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1129
1022
|
|
|
1130
|
-
|
|
1131
|
-
const hasRequiredFields = hasRequiredMRZFields(parsedMRZData?.fields);
|
|
1132
|
-
// CRITICAL: Only accept MRZ with valid checksums AND consistent reads
|
|
1133
|
-
// AND ensure all required fields are present
|
|
1134
|
-
const mrzAccepted =
|
|
1135
|
-
parsedMRZData?.valid === true &&
|
|
1136
|
-
hasRequiredFields &&
|
|
1137
|
-
mrzStableAndValid;
|
|
1138
|
-
|
|
1139
|
-
// For Turkish ID cards, barcode should match MRZ optional1 (serial number)
|
|
1140
|
-
// But some cards have encoding differences, so be lenient
|
|
1141
|
-
const barcodeMatchesMRZ =
|
|
1142
|
-
barcodeToUse?.rawValue?.trim() ===
|
|
1143
|
-
parsedMRZData?.fields?.optional1?.trim();
|
|
1144
|
-
|
|
1145
|
-
// If barcode doesn't match exactly, check if it contains the optional1 value
|
|
1146
|
-
const barcodeContainsMRZ =
|
|
1147
|
-
barcodeToUse?.rawValue?.includes(
|
|
1148
|
-
parsedMRZData?.fields?.optional1?.trim() || ''
|
|
1149
|
-
) ||
|
|
1150
|
-
parsedMRZData?.fields?.optional1?.includes(
|
|
1151
|
-
barcodeToUse?.rawValue?.trim() || ''
|
|
1152
|
-
);
|
|
1023
|
+
setElementsOutsideScanArea([]);
|
|
1153
1024
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1025
|
+
const flowResult = handleIDBackFlow(
|
|
1026
|
+
mrzText,
|
|
1027
|
+
parsedMRZData?.fields,
|
|
1028
|
+
parsedMRZData?.valid === true,
|
|
1029
|
+
mrzStableAndValid,
|
|
1030
|
+
hasRequiredMRZFields(parsedMRZData?.fields),
|
|
1031
|
+
barcodeToUse?.rawValue,
|
|
1032
|
+
onlyMRZScan
|
|
1033
|
+
);
|
|
1160
1034
|
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1035
|
+
if (!flowResult.shouldProceed) {
|
|
1036
|
+
mrzDetectionCurrentRetryCount.current++;
|
|
1037
|
+
setStatus(mrzText ? 'SCANNING' : 'SEARCHING');
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1166
1040
|
|
|
1167
|
-
|
|
1168
|
-
|
|
1041
|
+
// Check for glare on ID back before accepting
|
|
1042
|
+
const hasGlare = await checkDocumentGlare(
|
|
1043
|
+
image,
|
|
1044
|
+
frameWidth,
|
|
1045
|
+
frameHeight
|
|
1046
|
+
);
|
|
1047
|
+
if (hasGlare) {
|
|
1048
|
+
if (isDebugEnabled()) {
|
|
1049
|
+
debugLog(
|
|
1050
|
+
'IdentityDocumentCamera',
|
|
1051
|
+
'[ID_BACK] Rejected - glare detected'
|
|
1052
|
+
);
|
|
1053
|
+
}
|
|
1054
|
+
setStatus('SCANNING');
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1169
1057
|
|
|
1170
|
-
if (!allRequiredElementsInFrame && hasMRZ && mrzAccepted) {
|
|
1171
1058
|
if (isDebugEnabled()) {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1059
|
+
debugLog('IdentityDocumentCamera', '[ID_BACK] MRZ validated', {
|
|
1060
|
+
documentNumber: parsedMRZData?.fields?.documentNumber,
|
|
1061
|
+
reads: validMRZConsecutiveCount.current,
|
|
1062
|
+
});
|
|
1175
1063
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
if (
|
|
1181
|
-
hasMRZ &&
|
|
1182
|
-
mrzAccepted &&
|
|
1183
|
-
barcodeAccepted &&
|
|
1184
|
-
allRequiredElementsInFrame
|
|
1185
|
-
) {
|
|
1186
|
-
logMRZDetails(
|
|
1187
|
-
'ID_BACK Scan',
|
|
1188
|
-
parsedMRZData?.fields,
|
|
1189
|
-
mrzText,
|
|
1190
|
-
validMRZConsecutiveCount.current,
|
|
1191
|
-
isDebugEnabled()
|
|
1192
|
-
);
|
|
1193
|
-
const scannedData: DocumentScannedData = {
|
|
1064
|
+
setDetectedDocumentType('ID_BACK');
|
|
1065
|
+
setStatus('SCANNED');
|
|
1066
|
+
transitionStepWithCallback('COMPLETED', 'SCAN_ID_BACK', {
|
|
1194
1067
|
image,
|
|
1195
1068
|
documentType: 'ID_BACK',
|
|
1196
1069
|
mrzText: mrzText ?? undefined,
|
|
1197
1070
|
mrzFields: parsedMRZData?.fields,
|
|
1198
1071
|
barcodeValue: barcodeToUse?.rawValue ?? undefined,
|
|
1199
|
-
};
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
setNextStepAndVibrate('COMPLETED', 'SCAN_ID_BACK');
|
|
1204
|
-
setTimeout(() => {
|
|
1205
|
-
onIdentityDocumentScanned(scannedData);
|
|
1206
|
-
}, 1000);
|
|
1207
|
-
} else {
|
|
1208
|
-
if (hasMRZ && !mrzAccepted) {
|
|
1209
|
-
logMRZValidationFailure(
|
|
1210
|
-
'ID_BACK Scan',
|
|
1211
|
-
hasRequiredFields,
|
|
1212
|
-
parsedMRZData,
|
|
1213
|
-
mrzDetectionCurrentRetryCount.current,
|
|
1214
|
-
isDebugEnabled()
|
|
1215
|
-
);
|
|
1216
|
-
} else if (hasMRZ && mrzAccepted && !barcodeAccepted) {
|
|
1217
|
-
if (isDebugEnabled()) {
|
|
1218
|
-
console.log(
|
|
1219
|
-
'[ID_BACK Scan] MRZ valid but barcode check failed - retrying',
|
|
1220
|
-
{
|
|
1221
|
-
onlyMRZScan,
|
|
1222
|
-
hasBarcodeValue: !!barcodeToUse?.rawValue,
|
|
1223
|
-
barcodeMatchesMRZ,
|
|
1224
|
-
barcodeContainsMRZ,
|
|
1225
|
-
mrzOptional1: parsedMRZData?.fields?.optional1,
|
|
1226
|
-
barcodeValue: barcodeToUse?.rawValue,
|
|
1227
|
-
barcodeValueTrimmed: barcodeToUse?.rawValue?.trim(),
|
|
1228
|
-
optional1Trimmed: parsedMRZData?.fields?.optional1?.trim(),
|
|
1229
|
-
barcodeSource:
|
|
1230
|
-
barcodeToUse === cachedBarcode.current
|
|
1231
|
-
? 'cached'
|
|
1232
|
-
: 'current',
|
|
1233
|
-
}
|
|
1234
|
-
);
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
mrzDetectionCurrentRetryCount.current++;
|
|
1238
|
-
setStatus(hasMRZ ? 'SCANNING' : 'SEARCHING');
|
|
1239
|
-
}
|
|
1072
|
+
});
|
|
1073
|
+
};
|
|
1074
|
+
|
|
1075
|
+
handleIdBackStep();
|
|
1240
1076
|
return;
|
|
1241
1077
|
}
|
|
1242
1078
|
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1079
|
+
// Turn off torch when ID_FRONT detected during initial scan
|
|
1080
|
+
if (
|
|
1081
|
+
nextStep === 'SCAN_ID_FRONT_OR_PASSPORT' &&
|
|
1082
|
+
(documentType === 'ID_FRONT' || documentType === 'PASSPORT') &&
|
|
1083
|
+
isTorchOnRef.current
|
|
1084
|
+
) {
|
|
1085
|
+
setIsTorchOn(false);
|
|
1086
|
+
}
|
|
1250
1087
|
|
|
1251
|
-
//
|
|
1252
|
-
//
|
|
1253
|
-
//
|
|
1088
|
+
// Lock document type from stable quality frames during initial scan.
|
|
1089
|
+
// Also allow correcting ID_FRONT → PASSPORT when passport MRZ appears later.
|
|
1090
|
+
// Passport MRZ may not be visible in early frames (while signature is),
|
|
1091
|
+
// causing premature ID_FRONT lock that must be correctable.
|
|
1254
1092
|
if (
|
|
1255
1093
|
nextStep === 'SCAN_ID_FRONT_OR_PASSPORT' &&
|
|
1256
|
-
detectedDocumentType === 'UNKNOWN'
|
|
1094
|
+
(detectedDocumentType === 'UNKNOWN' ||
|
|
1095
|
+
detectedDocumentType === 'ID_FRONT')
|
|
1257
1096
|
) {
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
docTypeToSet = 'PASSPORT';
|
|
1265
|
-
} else if (
|
|
1266
|
-
documentType === 'UNKNOWN' &&
|
|
1267
|
-
cardSizedFaces.length > 0 &&
|
|
1268
|
-
parsedMRZData?.fields?.documentCode === 'P'
|
|
1269
|
-
) {
|
|
1270
|
-
// Early passport detection: face detected + passport MRZ code (even if not fully valid yet)
|
|
1271
|
-
docTypeToSet = 'PASSPORT';
|
|
1272
|
-
} else if (documentType === 'ID_FRONT') {
|
|
1273
|
-
// Check if this is actually a passport based on MRZ code
|
|
1274
|
-
// Passports can be misdetected as ID_FRONT when signature-like text is visible
|
|
1275
|
-
if (parsedMRZData?.fields?.documentCode === 'P') {
|
|
1276
|
-
if (isDebugEnabled()) {
|
|
1277
|
-
console.log(
|
|
1278
|
-
'[DocType] Correcting misdetection: ID_FRONT → PASSPORT (MRZ code P)'
|
|
1279
|
-
);
|
|
1280
|
-
}
|
|
1281
|
-
docTypeToSet = 'PASSPORT';
|
|
1282
|
-
} else if (parsedMRZData?.fields?.documentCode === 'I') {
|
|
1283
|
-
// MRZ confirms it's an ID card
|
|
1284
|
-
docTypeToSet = 'ID_FRONT';
|
|
1285
|
-
} else if (mrzText && /P<[A-Z]{3}/.test(mrzText)) {
|
|
1286
|
-
// Passport MRZ pattern visible but not parsed yet - wait for proper classification
|
|
1287
|
-
if (isDebugEnabled()) {
|
|
1288
|
-
console.log(
|
|
1289
|
-
'[DocType] Passport MRZ pattern detected but not parsed - waiting instead of locking as ID_FRONT'
|
|
1290
|
-
);
|
|
1291
|
-
}
|
|
1292
|
-
docTypeToSet = 'UNKNOWN';
|
|
1293
|
-
} else {
|
|
1294
|
-
// No MRZ code and no passport pattern - safe to classify as ID_FRONT
|
|
1295
|
-
// ID cards typically don't have MRZ on front (only on back)
|
|
1296
|
-
docTypeToSet = 'ID_FRONT';
|
|
1297
|
-
}
|
|
1298
|
-
} else {
|
|
1299
|
-
docTypeToSet = 'UNKNOWN';
|
|
1300
|
-
}
|
|
1097
|
+
const docTypeToSet = determineDocumentTypeToSet(
|
|
1098
|
+
documentType,
|
|
1099
|
+
primaryFaces,
|
|
1100
|
+
parsedMRZData?.fields,
|
|
1101
|
+
mrzText
|
|
1102
|
+
);
|
|
1301
1103
|
|
|
1302
|
-
//
|
|
1303
|
-
// 1. Frame quality is acceptable (not blurry, good brightness)
|
|
1304
|
-
// 2. Document type has been detected consistently for multiple frames
|
|
1104
|
+
// If already locked as ID_FRONT, only allow correction to PASSPORT
|
|
1305
1105
|
if (
|
|
1306
|
-
|
|
1307
|
-
docTypeToSet
|
|
1106
|
+
detectedDocumentType === 'ID_FRONT' &&
|
|
1107
|
+
docTypeToSet === 'PASSPORT'
|
|
1308
1108
|
) {
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1109
|
+
setDetectedDocumentType('PASSPORT');
|
|
1110
|
+
consistentDocTypeCount.current = 0;
|
|
1111
|
+
lastDetectedDocType.current = 'PASSPORT';
|
|
1112
|
+
} else if (detectedDocumentType === 'UNKNOWN') {
|
|
1113
|
+
if (
|
|
1114
|
+
lastFrameQuality.current.hasAcceptableQuality &&
|
|
1115
|
+
docTypeToSet !== 'UNKNOWN'
|
|
1116
|
+
) {
|
|
1117
|
+
if (docTypeToSet === lastDetectedDocType.current) {
|
|
1118
|
+
consistentDocTypeCount.current++;
|
|
1119
|
+
} else {
|
|
1120
|
+
lastDetectedDocType.current = docTypeToSet;
|
|
1121
|
+
consistentDocTypeCount.current = 1;
|
|
1315
1122
|
}
|
|
1316
1123
|
|
|
1317
1124
|
if (
|
|
1318
1125
|
consistentDocTypeCount.current >=
|
|
1319
1126
|
REQUIRED_CONSISTENT_DOCTYPE_DETECTIONS
|
|
1320
1127
|
) {
|
|
1321
|
-
// Stable detection confirmed - lock it in
|
|
1322
|
-
if (isDebugEnabled()) {
|
|
1323
|
-
console.log(
|
|
1324
|
-
`[DocType] Locked document type: ${docTypeToSet} (stable for ${consistentDocTypeCount.current} quality frames)`
|
|
1325
|
-
);
|
|
1326
|
-
}
|
|
1327
1128
|
setDetectedDocumentType(docTypeToSet);
|
|
1328
1129
|
}
|
|
1329
|
-
} else {
|
|
1330
|
-
// Document type changed - reset counter
|
|
1331
|
-
if (isDebugEnabled()) {
|
|
1332
|
-
console.log(
|
|
1333
|
-
`[DocType Stability] Type changed: ${lastDetectedDocType.current} → ${docTypeToSet}, resetting counter`
|
|
1334
|
-
);
|
|
1335
|
-
}
|
|
1336
|
-
lastDetectedDocType.current = docTypeToSet;
|
|
1337
|
-
consistentDocTypeCount.current = 1;
|
|
1338
|
-
}
|
|
1339
|
-
} else if (
|
|
1340
|
-
!lastFrameQuality.current.hasAcceptableQuality &&
|
|
1341
|
-
docTypeToSet !== 'UNKNOWN'
|
|
1342
|
-
) {
|
|
1343
|
-
// Poor quality frame - don't use for document type detection
|
|
1344
|
-
if (isDebugEnabled()) {
|
|
1345
|
-
console.log(
|
|
1346
|
-
`[DocType Stability] Skipping poor quality frame (blurry: ${lastFrameQuality.current.isBlurry}, brightness: ${lastFrameQuality.current.brightness.toFixed(0)})`
|
|
1347
|
-
);
|
|
1348
1130
|
}
|
|
1349
1131
|
}
|
|
1350
1132
|
}
|
|
1351
|
-
// Document type is now locked and won't be changed after initial scan
|
|
1352
|
-
// Hologram and subsequent steps use the preserved detectedDocumentType state
|
|
1353
1133
|
|
|
1354
1134
|
const scannedData: DocumentScannedData = {
|
|
1355
1135
|
image,
|
|
@@ -1358,10 +1138,10 @@ const IdentityDocumentCamera = ({
|
|
|
1358
1138
|
mrzFields: parsedMRZData?.fields,
|
|
1359
1139
|
};
|
|
1360
1140
|
|
|
1361
|
-
|
|
1362
|
-
nextStep === 'SCAN_ID_FRONT_OR_PASSPORT' &&
|
|
1363
|
-
|
|
1364
|
-
|
|
1141
|
+
if (
|
|
1142
|
+
nextStep === 'SCAN_ID_FRONT_OR_PASSPORT' &&
|
|
1143
|
+
documentType === 'ID_BACK'
|
|
1144
|
+
) {
|
|
1365
1145
|
setStatus('INCORRECT');
|
|
1366
1146
|
return;
|
|
1367
1147
|
}
|
|
@@ -1371,238 +1151,366 @@ const IdentityDocumentCamera = ({
|
|
|
1371
1151
|
scannedData.faceImage = faceImageToUse;
|
|
1372
1152
|
}
|
|
1373
1153
|
|
|
1154
|
+
const continueScanning = (incrementMrzRetry: boolean = false) => {
|
|
1155
|
+
if (incrementMrzRetry) {
|
|
1156
|
+
mrzDetectionCurrentRetryCount.current++;
|
|
1157
|
+
}
|
|
1158
|
+
setStatus('SCANNING');
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1374
1161
|
if (!onlyMRZScan) {
|
|
1375
|
-
// Hologram detection during SCAN_HOLOGRAM step
|
|
1162
|
+
// Hologram detection during SCAN_HOLOGRAM step
|
|
1376
1163
|
if (nextStep === 'SCAN_HOLOGRAM') {
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
`[Hologram] In SCAN_HOLOGRAM step - currentHologramImage: ${!!currentHologramImage}, collected: ${faceImages.current.length}/${HOLOGRAM_IMAGE_COUNT}`
|
|
1380
|
-
);
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
// Always crop to the same face region across all hologram frames so
|
|
1384
|
-
// OpenCV receives consistently-sized images for comparison.
|
|
1385
|
-
// Use current face bounds if available, otherwise fall back to last known position.
|
|
1164
|
+
// CRITICAL: Only use faces inside scan area for hologram
|
|
1165
|
+
// This prevents passport secondary faces (outside frame or on right side) from being used
|
|
1386
1166
|
const hologramFaceBounds =
|
|
1387
|
-
|
|
1388
|
-
?
|
|
1167
|
+
facesInsideScanArea.length > 0 && facesInsideScanArea[0]
|
|
1168
|
+
? facesInsideScanArea[0].bounds
|
|
1389
1169
|
: lastFacePosition.current;
|
|
1390
1170
|
let primaryFaceOnly: string | undefined;
|
|
1391
1171
|
if (hologramFaceBounds && image) {
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1172
|
+
// Verify face is fully visible before using for hologram
|
|
1173
|
+
const faceFullyVisible = hologramFaceBounds
|
|
1174
|
+
? hologramFaceBounds.x >= frameWidth * FACE_EDGE_MARGIN_PERCENT &&
|
|
1175
|
+
hologramFaceBounds.y >=
|
|
1176
|
+
frameHeight * FACE_EDGE_MARGIN_PERCENT &&
|
|
1177
|
+
hologramFaceBounds.x + hologramFaceBounds.width <=
|
|
1178
|
+
frameWidth * (1 - FACE_EDGE_MARGIN_PERCENT) &&
|
|
1179
|
+
hologramFaceBounds.y + hologramFaceBounds.height <=
|
|
1180
|
+
frameHeight * (1 - FACE_EDGE_MARGIN_PERCENT)
|
|
1181
|
+
: false;
|
|
1182
|
+
|
|
1183
|
+
if (faceFullyVisible) {
|
|
1184
|
+
const hologramCropped = await getFaceImages(
|
|
1185
|
+
[{ bounds: hologramFaceBounds, rollAngle: 0, yawAngle: 0 }],
|
|
1186
|
+
image,
|
|
1187
|
+
frameWidth,
|
|
1188
|
+
frameHeight,
|
|
1189
|
+
true // widerRightPadding for hologram detection
|
|
1190
|
+
);
|
|
1191
|
+
primaryFaceOnly = hologramCropped[0] ?? faceImageToUse;
|
|
1192
|
+
} else {
|
|
1193
|
+
// Face not fully visible - skip this frame
|
|
1194
|
+
if (isDebugEnabled()) {
|
|
1195
|
+
debugLog(
|
|
1196
|
+
'IdentityDocumentCamera',
|
|
1197
|
+
'[HOLOGRAM] Face not fully visible',
|
|
1198
|
+
{
|
|
1199
|
+
faceX: hologramFaceBounds.x,
|
|
1200
|
+
faceY: hologramFaceBounds.y,
|
|
1201
|
+
faceWidth: hologramFaceBounds.width,
|
|
1202
|
+
faceHeight: hologramFaceBounds.height,
|
|
1203
|
+
frameWidth,
|
|
1204
|
+
frameHeight,
|
|
1205
|
+
}
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
primaryFaceOnly = undefined;
|
|
1209
|
+
}
|
|
1399
1210
|
} else {
|
|
1400
1211
|
primaryFaceOnly = faceImageToUse;
|
|
1401
1212
|
}
|
|
1402
1213
|
|
|
1403
1214
|
// Skip face position validation for hologram — flash toggling causes position jitter
|
|
1404
1215
|
if (primaryFaceOnly) {
|
|
1405
|
-
// Reset consecutive no-face counter since we have a face
|
|
1406
1216
|
hologramFramesWithoutFace.current = 0;
|
|
1407
1217
|
|
|
1408
1218
|
if (currentHologramImage) {
|
|
1409
1219
|
scannedData.hologramImage = currentHologramImage;
|
|
1410
1220
|
} else if (faceImages.current.length < HOLOGRAM_IMAGE_COUNT) {
|
|
1411
|
-
//
|
|
1412
|
-
const now = Date.now();
|
|
1221
|
+
// Space out captures for better variation
|
|
1413
1222
|
const timeSinceLastCapture =
|
|
1414
|
-
now - lastHologramCaptureTime.current;
|
|
1223
|
+
Date.now() - lastHologramCaptureTime.current;
|
|
1415
1224
|
|
|
1416
1225
|
if (
|
|
1417
1226
|
faceImages.current.length === 0 ||
|
|
1418
1227
|
timeSinceLastCapture >= HOLOGRAM_CAPTURE_INTERVAL
|
|
1419
1228
|
) {
|
|
1420
|
-
//
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
hologramImageCountRef.current = faceImages.current.length;
|
|
1424
|
-
|
|
1425
|
-
// Only update state at first and last frame to minimize re-renders
|
|
1426
|
-
if (
|
|
1427
|
-
faceImages.current.length === 1 ||
|
|
1428
|
-
faceImages.current.length === HOLOGRAM_IMAGE_COUNT
|
|
1429
|
-
) {
|
|
1430
|
-
setHologramImageCount(faceImages.current.length);
|
|
1431
|
-
setLatestHologramFaceImage(primaryFaceOnly);
|
|
1229
|
+
// Keep torch on during hologram scan for consistent lighting
|
|
1230
|
+
if (!isTorchOnRef.current) {
|
|
1231
|
+
setIsTorchOn(true);
|
|
1432
1232
|
}
|
|
1433
1233
|
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1234
|
+
// Check hologram face for glare
|
|
1235
|
+
const hasGlare = await checkFaceGlare(primaryFaceOnly);
|
|
1236
|
+
if (!hasGlare) {
|
|
1237
|
+
faceImages.current.push(primaryFaceOnly);
|
|
1238
|
+
lastHologramCaptureTime.current = Date.now();
|
|
1239
|
+
hologramImageCountRef.current = faceImages.current.length;
|
|
1240
|
+
|
|
1241
|
+
if (isDebugEnabled()) {
|
|
1242
|
+
debugLog(
|
|
1243
|
+
'IdentityDocumentCamera',
|
|
1244
|
+
'[HOLOGRAM] Frame captured',
|
|
1245
|
+
{
|
|
1246
|
+
frameIndex: faceImages.current.length - 1,
|
|
1247
|
+
totalFrames: faceImages.current.length,
|
|
1248
|
+
}
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
1251
|
+
} else if (isDebugEnabled()) {
|
|
1252
|
+
debugLog(
|
|
1253
|
+
'IdentityDocumentCamera',
|
|
1254
|
+
'[HOLOGRAM] Rejected glare frame',
|
|
1255
|
+
{
|
|
1256
|
+
collectedCount: faceImages.current.length,
|
|
1257
|
+
}
|
|
1437
1258
|
);
|
|
1438
1259
|
}
|
|
1439
1260
|
|
|
1440
|
-
|
|
1261
|
+
if (faceImages.current.length > 0) {
|
|
1262
|
+
// Update UI state at first and last frame only
|
|
1263
|
+
if (
|
|
1264
|
+
faceImages.current.length === 1 ||
|
|
1265
|
+
faceImages.current.length === HOLOGRAM_IMAGE_COUNT
|
|
1266
|
+
) {
|
|
1267
|
+
setHologramImageCount(faceImages.current.length);
|
|
1268
|
+
setLatestHologramFaceImage(primaryFaceOnly);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1441
1271
|
}
|
|
1442
1272
|
} else if (faceImages.current.length >= HOLOGRAM_IMAGE_COUNT) {
|
|
1443
|
-
//
|
|
1444
|
-
if (
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1273
|
+
// Guard: skip if already processing or max retries exhausted
|
|
1274
|
+
if (isHologramDetectionInProgress.current) return;
|
|
1275
|
+
if (
|
|
1276
|
+
hologramDetectionCurrentRetryCount.current >=
|
|
1277
|
+
HOLOGRAM_DETECTION_RETRY_COUNT
|
|
1278
|
+
) {
|
|
1279
|
+
faceImages.current = [];
|
|
1280
|
+
hologramImageCountRef.current = 0;
|
|
1281
|
+
setHologramImageCount(0);
|
|
1282
|
+
setLatestHologramFaceImage(undefined);
|
|
1283
|
+
return;
|
|
1448
1284
|
}
|
|
1285
|
+
|
|
1286
|
+
// Process collected face images for hologram detection
|
|
1287
|
+
isHologramDetectionInProgress.current = true;
|
|
1449
1288
|
try {
|
|
1450
1289
|
const [hologramMask, hologram] = await detectHologramNative(
|
|
1451
1290
|
faceImages.current
|
|
1452
1291
|
);
|
|
1292
|
+
if (isDebugEnabled()) {
|
|
1293
|
+
debugLog(
|
|
1294
|
+
'IdentityDocumentCamera',
|
|
1295
|
+
'[Hologram] Native result',
|
|
1296
|
+
{
|
|
1297
|
+
hasHologram: !!hologram,
|
|
1298
|
+
hasHologramMask: !!hologramMask,
|
|
1299
|
+
hologramLength: hologram?.length || 0,
|
|
1300
|
+
}
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1453
1303
|
if (hologram) {
|
|
1454
1304
|
setCurrentHologramMaskImage(hologramMask);
|
|
1455
1305
|
scannedData.hologramImage = hologram;
|
|
1456
1306
|
setCurrentHologramImage(hologram);
|
|
1457
1307
|
if (isDebugEnabled()) {
|
|
1458
|
-
|
|
1308
|
+
debugLog(
|
|
1309
|
+
'IdentityDocumentCamera',
|
|
1310
|
+
'[Hologram] ✓ Saved hologram image'
|
|
1311
|
+
);
|
|
1459
1312
|
}
|
|
1460
1313
|
} else {
|
|
1461
1314
|
if (isDebugEnabled()) {
|
|
1462
|
-
|
|
1315
|
+
debugLog(
|
|
1316
|
+
'IdentityDocumentCamera',
|
|
1317
|
+
'[Hologram] ✗ No hologram detected'
|
|
1318
|
+
);
|
|
1463
1319
|
}
|
|
1464
1320
|
}
|
|
1465
1321
|
} catch (error) {
|
|
1466
1322
|
console.error('[Hologram] Processing error:', error);
|
|
1467
1323
|
} finally {
|
|
1468
|
-
// Keep flash on - will turn off when step changes
|
|
1469
1324
|
faceImages.current = [];
|
|
1470
1325
|
hologramImageCountRef.current = 0;
|
|
1471
1326
|
setHologramImageCount(0);
|
|
1472
1327
|
setLatestHologramFaceImage(undefined);
|
|
1473
1328
|
hologramDetectionCurrentRetryCount.current++;
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
);
|
|
1478
|
-
}
|
|
1329
|
+
isHologramDetectionInProgress.current = false;
|
|
1330
|
+
// Turn off torch after detection completes
|
|
1331
|
+
setIsTorchOn(false);
|
|
1479
1332
|
}
|
|
1480
1333
|
}
|
|
1481
1334
|
} else {
|
|
1482
|
-
// No face detected for hologram collection
|
|
1483
|
-
// Track consecutive frames without face for safety timeout
|
|
1484
1335
|
hologramFramesWithoutFace.current++;
|
|
1485
|
-
if (isDebugEnabled()) {
|
|
1486
|
-
console.log(
|
|
1487
|
-
`[Hologram] No face detected - frame ${hologramFramesWithoutFace.current}/${HOLOGRAM_MAX_FRAMES_WITHOUT_FACE}`
|
|
1488
|
-
);
|
|
1489
|
-
}
|
|
1490
1336
|
}
|
|
1491
1337
|
} else if (currentHologramImage) {
|
|
1492
1338
|
scannedData.hologramImage = currentHologramImage;
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
// Secondary face capture (continuous during initial scan and hologram detection)
|
|
1342
|
+
// MLI (Multi Layer Image) is small secondary face on Turkish ID cards
|
|
1343
|
+
if (
|
|
1344
|
+
nextStep === 'SCAN_ID_FRONT_OR_PASSPORT' ||
|
|
1345
|
+
nextStep === 'SCAN_HOLOGRAM'
|
|
1346
|
+
) {
|
|
1347
|
+
if (isDebugEnabled() && allDetectedFaces.length > 1) {
|
|
1348
|
+
debugLog(
|
|
1349
|
+
'IdentityDocumentCamera',
|
|
1350
|
+
'[MLI FACE] Entry conditions check',
|
|
1351
|
+
{
|
|
1352
|
+
hasCurrentSecondary: !!currentSecondaryFaceImage,
|
|
1353
|
+
hasPrimaryFace: !!scannedData.faceImage,
|
|
1354
|
+
totalFaces: allDetectedFaces.length,
|
|
1355
|
+
facePositionValid,
|
|
1356
|
+
willAttemptDetection:
|
|
1357
|
+
!currentSecondaryFaceImage &&
|
|
1358
|
+
!!scannedData.faceImage &&
|
|
1359
|
+
allDetectedFaces.length > 1 &&
|
|
1360
|
+
facePositionValid,
|
|
1361
|
+
}
|
|
1502
1362
|
);
|
|
1503
1363
|
}
|
|
1504
|
-
}
|
|
1505
1364
|
|
|
1506
|
-
// SKIP secondary face detection during SCAN_HOLOGRAM - only focus on primary face
|
|
1507
|
-
// Secondary face was already captured during initial scan (SCAN_ID_FRONT_OR_PASSPORT)
|
|
1508
|
-
// During hologram, we only collect hologram images from primary face
|
|
1509
|
-
if (nextStep === 'SCAN_ID_FRONT_OR_PASSPORT') {
|
|
1510
|
-
// Capture secondary face - must be similar to main face AND from same document plane
|
|
1511
1365
|
if (currentSecondaryFaceImage) {
|
|
1512
1366
|
scannedData.secondaryFaceImage = currentSecondaryFaceImage;
|
|
1513
1367
|
} else if (
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
!!croppedFaces[1] &&
|
|
1368
|
+
scannedData.faceImage &&
|
|
1369
|
+
allDetectedFaces.length > 1 &&
|
|
1517
1370
|
facePositionValid
|
|
1518
1371
|
) {
|
|
1519
|
-
//
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1372
|
+
// Detect MLI face (smaller than main face, to the right)
|
|
1373
|
+
const primaryFace = primaryFaces[0];
|
|
1374
|
+
|
|
1375
|
+
if (isDebugEnabled() && primaryFace) {
|
|
1376
|
+
debugLog(
|
|
1377
|
+
'IdentityDocumentCamera',
|
|
1378
|
+
'[MLI FACE] Starting detection',
|
|
1379
|
+
{
|
|
1380
|
+
totalFaces: allDetectedFaces.length,
|
|
1381
|
+
primaryFaceSize: `${Math.round(primaryFace.bounds.width)}x${Math.round(primaryFace.bounds.height)}`,
|
|
1382
|
+
primaryFacePos: `x:${Math.round(primaryFace.bounds.x)} y:${Math.round(primaryFace.bounds.y)}`,
|
|
1383
|
+
otherFaces: allDetectedFaces
|
|
1384
|
+
.filter((f) => f !== primaryFace)
|
|
1385
|
+
.map((f) => ({
|
|
1386
|
+
size: `${Math.round(f.bounds.width)}x${Math.round(f.bounds.height)}`,
|
|
1387
|
+
pos: `x:${Math.round(f.bounds.x)} y:${Math.round(f.bounds.y)}`,
|
|
1388
|
+
isRight: f.bounds.x > primaryFace.bounds.x,
|
|
1389
|
+
verticalRange: `${Math.round(primaryFace.bounds.y - primaryFace.bounds.height * 0.3)}-${Math.round(primaryFace.bounds.y + primaryFace.bounds.height * 1.3)}`,
|
|
1390
|
+
inVerticalRange:
|
|
1391
|
+
f.bounds.y >=
|
|
1392
|
+
primaryFace.bounds.y -
|
|
1393
|
+
primaryFace.bounds.height * 0.3 &&
|
|
1394
|
+
f.bounds.y <=
|
|
1395
|
+
primaryFace.bounds.y +
|
|
1396
|
+
primaryFace.bounds.height * 1.3,
|
|
1397
|
+
})),
|
|
1398
|
+
}
|
|
1399
|
+
);
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
const potentialMLIFaces = allDetectedFaces.filter(
|
|
1403
|
+
(f) =>
|
|
1404
|
+
f !== primaryFace &&
|
|
1405
|
+
f.bounds.x > primaryFace.bounds.x && // MLI is to the right of main face
|
|
1406
|
+
f.bounds.y >=
|
|
1407
|
+
primaryFace.bounds.y - primaryFace.bounds.height * 0.3 && // Same vertical level (±30%)
|
|
1408
|
+
f.bounds.y <=
|
|
1409
|
+
primaryFace.bounds.y + primaryFace.bounds.height * 1.3
|
|
1524
1410
|
);
|
|
1525
1411
|
|
|
1526
|
-
if (
|
|
1527
|
-
|
|
1528
|
-
|
|
1412
|
+
if (isDebugEnabled()) {
|
|
1413
|
+
debugLog(
|
|
1414
|
+
'IdentityDocumentCamera',
|
|
1415
|
+
'[MLI FACE] Position filter result',
|
|
1416
|
+
{
|
|
1417
|
+
potentialMLICount: potentialMLIFaces.length,
|
|
1418
|
+
}
|
|
1419
|
+
);
|
|
1420
|
+
}
|
|
1529
1421
|
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
const screen = Dimensions.get('window');
|
|
1533
|
-
const frameAspect =
|
|
1534
|
-
frameDimensions.width / frameDimensions.height;
|
|
1535
|
-
const screenAspect = screen.width / screen.height;
|
|
1422
|
+
if (potentialMLIFaces.length > 0 && potentialMLIFaces[0]) {
|
|
1423
|
+
const secondaryFace = potentialMLIFaces[0];
|
|
1536
1424
|
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1425
|
+
// Crop MLI face separately
|
|
1426
|
+
const mliFaceCropped = await getFaceImages(
|
|
1427
|
+
[primaryFace, secondaryFace],
|
|
1428
|
+
image ?? '',
|
|
1429
|
+
frameWidth,
|
|
1430
|
+
frameHeight
|
|
1431
|
+
);
|
|
1540
1432
|
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
(frameDimensions.height * scale - screen.height) / 2;
|
|
1548
|
-
}
|
|
1433
|
+
if (mliFaceCropped.length > 1 && mliFaceCropped[1]) {
|
|
1434
|
+
// Visual similarity check with lenient threshold
|
|
1435
|
+
const visualResult = await compareFaceVisualSimilarityNative(
|
|
1436
|
+
mliFaceCropped[0],
|
|
1437
|
+
mliFaceCropped[1]
|
|
1438
|
+
);
|
|
1549
1439
|
|
|
1550
|
-
const
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
y + h <= scanBottom;
|
|
1564
|
-
|
|
1565
|
-
const secondaryBounds = faces[1].bounds;
|
|
1566
|
-
if (
|
|
1567
|
-
isInsideScan(
|
|
1568
|
-
secondaryBounds.x,
|
|
1569
|
-
secondaryBounds.y,
|
|
1570
|
-
secondaryBounds.width,
|
|
1571
|
-
secondaryBounds.height
|
|
1572
|
-
)
|
|
1573
|
-
) {
|
|
1574
|
-
setSecondaryFaceBounds({
|
|
1575
|
-
x: secondaryBounds.x * scale - offsetX,
|
|
1576
|
-
y: secondaryBounds.y * scale - offsetY,
|
|
1577
|
-
width: secondaryBounds.width * scale,
|
|
1578
|
-
height: secondaryBounds.height * scale,
|
|
1579
|
-
});
|
|
1580
|
-
} else {
|
|
1581
|
-
setSecondaryFaceBounds(null);
|
|
1440
|
+
const similarityScore = visualResult?.similarity || 0;
|
|
1441
|
+
const isLikelySamePerson = similarityScore >= 0.2; // Very lenient: 20%
|
|
1442
|
+
|
|
1443
|
+
if (isDebugEnabled()) {
|
|
1444
|
+
debugLog(
|
|
1445
|
+
'IdentityDocumentCamera',
|
|
1446
|
+
'[MLI FACE] Similarity check',
|
|
1447
|
+
{
|
|
1448
|
+
visualSimilarity: similarityScore.toFixed(3),
|
|
1449
|
+
isLikelySamePerson,
|
|
1450
|
+
threshold: 0.2,
|
|
1451
|
+
}
|
|
1452
|
+
);
|
|
1582
1453
|
}
|
|
1583
|
-
}
|
|
1584
1454
|
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1455
|
+
if (isLikelySamePerson) {
|
|
1456
|
+
// Skip glare check for MLI - it's a small printed photo with different reflective properties
|
|
1457
|
+
// Backend will validate quality
|
|
1458
|
+
scannedData.secondaryFaceImage = mliFaceCropped[1];
|
|
1459
|
+
setCurrentSecondaryFaceImage(scannedData.secondaryFaceImage);
|
|
1460
|
+
|
|
1461
|
+
if (isDebugEnabled()) {
|
|
1462
|
+
debugLog(
|
|
1463
|
+
'IdentityDocumentCamera',
|
|
1464
|
+
'[MLI FACE] Captured successfully',
|
|
1465
|
+
{
|
|
1466
|
+
similarity: similarityScore.toFixed(3),
|
|
1467
|
+
imageLength: mliFaceCropped[1]?.length || 0,
|
|
1468
|
+
imageSet: !!scannedData.secondaryFaceImage,
|
|
1469
|
+
stateSet: !!currentSecondaryFaceImage,
|
|
1470
|
+
primarySize: `${Math.round(primaryFace.bounds.width)}x${Math.round(primaryFace.bounds.height)}`,
|
|
1471
|
+
secondarySize: `${Math.round(secondaryFace.bounds.width)}x${Math.round(secondaryFace.bounds.height)}`,
|
|
1472
|
+
}
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
if (frameDimensions) {
|
|
1477
|
+
const { scale, offsetX, offsetY } =
|
|
1478
|
+
getFrameToScreenTransform(
|
|
1479
|
+
frameDimensions.width,
|
|
1480
|
+
frameDimensions.height
|
|
1481
|
+
);
|
|
1482
|
+
const secondaryBounds = secondaryFace.bounds;
|
|
1483
|
+
setSecondaryFaceBounds(
|
|
1484
|
+
transformBoundsToScreen(
|
|
1485
|
+
secondaryBounds,
|
|
1486
|
+
scale,
|
|
1487
|
+
offsetX,
|
|
1488
|
+
offsetY
|
|
1489
|
+
)
|
|
1490
|
+
);
|
|
1491
|
+
}
|
|
1492
|
+
} else if (isDebugEnabled()) {
|
|
1493
|
+
debugLog(
|
|
1494
|
+
'IdentityDocumentCamera',
|
|
1495
|
+
'[MLI FACE] Rejected - similarity too low',
|
|
1496
|
+
{ similarity: similarityScore.toFixed(3), threshold: 0.2 }
|
|
1497
|
+
);
|
|
1498
|
+
}
|
|
1596
1499
|
}
|
|
1597
1500
|
}
|
|
1598
1501
|
} else {
|
|
1599
1502
|
secondaryFaceDetectionCurrentRetryCount.current++;
|
|
1600
|
-
if (
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1503
|
+
if (isDebugEnabled() && allDetectedFaces.length > 1) {
|
|
1504
|
+
debugLog(
|
|
1505
|
+
'IdentityDocumentCamera',
|
|
1506
|
+
'[MLI FACE] Conditions not met',
|
|
1507
|
+
{
|
|
1508
|
+
hasPrimaryFace: !!scannedData.faceImage,
|
|
1509
|
+
primaryFacesCount: primaryFaces.length,
|
|
1510
|
+
allDetectedFaces: allDetectedFaces.length,
|
|
1511
|
+
facePositionValid,
|
|
1512
|
+
}
|
|
1513
|
+
);
|
|
1606
1514
|
}
|
|
1607
1515
|
}
|
|
1608
1516
|
} else if (currentSecondaryFaceImage) {
|
|
@@ -1611,324 +1519,198 @@ const IdentityDocumentCamera = ({
|
|
|
1611
1519
|
}
|
|
1612
1520
|
}
|
|
1613
1521
|
|
|
1614
|
-
//
|
|
1615
|
-
//
|
|
1522
|
+
// ============================================================================
|
|
1523
|
+
// SCAN_HOLOGRAM STEP
|
|
1524
|
+
// ============================================================================
|
|
1616
1525
|
if (nextStep === 'SCAN_HOLOGRAM') {
|
|
1617
|
-
//
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1526
|
+
// Guard: barcode visible = back side shown
|
|
1527
|
+
if (barcode?.rawValue) {
|
|
1528
|
+
setStatus('INCORRECT');
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1621
1531
|
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1532
|
+
const isCollecting = faceImages.current.length > 0;
|
|
1533
|
+
const maxRetriesReached =
|
|
1534
|
+
hologramDetectionCurrentRetryCount.current >=
|
|
1535
|
+
HOLOGRAM_DETECTION_RETRY_COUNT;
|
|
1625
1536
|
|
|
1626
|
-
if
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1537
|
+
// Wait for face if not yet started collecting
|
|
1538
|
+
if (!isCollecting && primaryFaces.length === 0) {
|
|
1539
|
+
hologramFramesWithoutFace.current++;
|
|
1540
|
+
if (
|
|
1541
|
+
hologramFramesWithoutFace.current >=
|
|
1542
|
+
HOLOGRAM_MAX_FRAMES_WITHOUT_FACE
|
|
1543
|
+
) {
|
|
1544
|
+
setStatus('INCORRECT');
|
|
1545
|
+
return;
|
|
1631
1546
|
}
|
|
1632
|
-
|
|
1547
|
+
continueScanning();
|
|
1633
1548
|
return;
|
|
1634
1549
|
}
|
|
1635
1550
|
|
|
1636
|
-
//
|
|
1637
|
-
const
|
|
1638
|
-
|
|
1551
|
+
// Complete when hologram captured OR retries exhausted (not mid-collection)
|
|
1552
|
+
const stepComplete =
|
|
1553
|
+
(!!scannedData.hologramImage ||
|
|
1554
|
+
(maxRetriesReached && !isCollecting)) &&
|
|
1555
|
+
!!faceImageToUse; // Require face before completing
|
|
1556
|
+
|
|
1557
|
+
if (stepComplete) {
|
|
1558
|
+
// Ensure preserved MRZ data is included (current frame may not have
|
|
1559
|
+
// readable MRZ due to flash/tilting during hologram capture)
|
|
1560
|
+
if (!scannedData.mrzText && lastValidMRZText.current) {
|
|
1561
|
+
scannedData.mrzText = lastValidMRZText.current;
|
|
1562
|
+
}
|
|
1563
|
+
if (!scannedData.mrzFields && lastValidMRZFields.current) {
|
|
1564
|
+
scannedData.mrzFields = lastValidMRZFields.current;
|
|
1565
|
+
}
|
|
1639
1566
|
|
|
1640
|
-
|
|
1641
|
-
const isActivelyCollecting =
|
|
1642
|
-
faceImages.current.length > 0 &&
|
|
1643
|
-
faceImages.current.length < HOLOGRAM_IMAGE_COUNT;
|
|
1567
|
+
setStatus('SCANNED');
|
|
1644
1568
|
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
(
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
// During hologram scan, we ONLY care about hologram collection - no other checks
|
|
1653
|
-
// Secondary face, MRZ, document type checks are all skipped
|
|
1654
|
-
// Document type was already definitively determined in the initial scan phase
|
|
1655
|
-
|
|
1656
|
-
// Log detailed state for debugging
|
|
1657
|
-
if (isActivelyCollecting && isDebugEnabled()) {
|
|
1658
|
-
console.log(
|
|
1659
|
-
`[SCAN_HOLOGRAM] Actively collecting: ${faceImages.current.length}/${HOLOGRAM_IMAGE_COUNT} - continuing collection`
|
|
1569
|
+
// Use scannedData.mrzFields which we just ensured has preserved MRZ
|
|
1570
|
+
const mrzDocCode = scannedData.mrzFields?.documentCode;
|
|
1571
|
+
const nextStepAfterHologram = getNextStepAfterHologram(
|
|
1572
|
+
detectedDocumentType,
|
|
1573
|
+
documentType,
|
|
1574
|
+
mrzDocCode
|
|
1660
1575
|
);
|
|
1661
|
-
}
|
|
1662
1576
|
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
}
|
|
1669
|
-
setStatus('SCANNED');
|
|
1670
|
-
if (nextStep !== 'SCAN_HOLOGRAM') {
|
|
1671
|
-
setIsTorchOn(false);
|
|
1672
|
-
}
|
|
1673
|
-
// Route based on PRESERVED detectedDocumentType state (set during initial scan)
|
|
1674
|
-
// Also check current frame's documentType and MRZ code as fallback
|
|
1675
|
-
// Passport has no back side - go directly to COMPLETED
|
|
1676
|
-
const isPassport =
|
|
1677
|
-
detectedDocumentType === 'PASSPORT' ||
|
|
1678
|
-
documentType === 'PASSPORT' ||
|
|
1679
|
-
parsedMRZData?.fields?.documentCode === 'P';
|
|
1680
|
-
if (isDebugEnabled()) {
|
|
1681
|
-
console.log('[SCAN_HOLOGRAM] Document type check:', {
|
|
1682
|
-
detectedDocumentType,
|
|
1683
|
-
documentType,
|
|
1684
|
-
mrzCode: parsedMRZData?.fields?.documentCode,
|
|
1685
|
-
isPassport,
|
|
1686
|
-
});
|
|
1687
|
-
}
|
|
1688
|
-
if (isPassport) {
|
|
1689
|
-
if (isDebugEnabled()) {
|
|
1690
|
-
console.log(
|
|
1691
|
-
'[SCAN_HOLOGRAM] Passport detected - completing scan (no back side)'
|
|
1692
|
-
);
|
|
1693
|
-
}
|
|
1694
|
-
setNextStepAndVibrate('COMPLETED', 'SCAN_HOLOGRAM');
|
|
1695
|
-
} else {
|
|
1696
|
-
if (isDebugEnabled()) {
|
|
1697
|
-
console.log(
|
|
1698
|
-
'[SCAN_HOLOGRAM] ID card detected - proceeding to back scan'
|
|
1699
|
-
);
|
|
1700
|
-
}
|
|
1701
|
-
setNextStepAndVibrate('SCAN_ID_BACK', 'SCAN_HOLOGRAM');
|
|
1702
|
-
}
|
|
1703
|
-
setTimeout(() => {
|
|
1704
|
-
onIdentityDocumentScanned(scannedData);
|
|
1705
|
-
}, 1000);
|
|
1577
|
+
transitionStepWithCallback(
|
|
1578
|
+
nextStepAfterHologram,
|
|
1579
|
+
'SCAN_HOLOGRAM',
|
|
1580
|
+
scannedData
|
|
1581
|
+
);
|
|
1706
1582
|
return;
|
|
1707
1583
|
}
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
setStatus('SCANNING');
|
|
1584
|
+
|
|
1585
|
+
continueScanning();
|
|
1711
1586
|
return;
|
|
1712
1587
|
}
|
|
1713
1588
|
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1589
|
+
// ============================================================================
|
|
1590
|
+
// INITIAL SCAN STEP - Detect document type and validate
|
|
1591
|
+
// ============================================================================
|
|
1592
|
+
if (nextStep === 'SCAN_ID_FRONT_OR_PASSPORT') {
|
|
1593
|
+
// Determine which flow handler to use.
|
|
1594
|
+
// Current-frame passport detection always takes precedence over a locked
|
|
1595
|
+
// ID_FRONT — passport MRZ may not appear until later frames.
|
|
1596
|
+
const flowDocumentType =
|
|
1597
|
+
documentType === 'PASSPORT'
|
|
1598
|
+
? 'PASSPORT'
|
|
1599
|
+
: detectedDocumentType !== 'UNKNOWN'
|
|
1600
|
+
? detectedDocumentType
|
|
1601
|
+
: documentType;
|
|
1602
|
+
|
|
1603
|
+
const handlePassportInitialStep = async () => {
|
|
1604
|
+
const flowResult = handlePassportFlow(
|
|
1605
|
+
primaryFaces,
|
|
1606
|
+
mrzText,
|
|
1607
|
+
parsedMRZData?.fields,
|
|
1608
|
+
mrzStableAndValid,
|
|
1609
|
+
onlyMRZScan,
|
|
1610
|
+
hasRequiredMRZFields(parsedMRZData?.fields),
|
|
1611
|
+
!!faceImageToUse
|
|
1612
|
+
);
|
|
1613
|
+
|
|
1614
|
+
if (!flowResult.shouldProceed) {
|
|
1615
|
+
continueScanning(true);
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
// Check for glare on passport before accepting
|
|
1620
|
+
const hasGlare = await checkDocumentGlare(
|
|
1621
|
+
image,
|
|
1622
|
+
frameWidth,
|
|
1623
|
+
frameHeight
|
|
1624
|
+
);
|
|
1625
|
+
if (hasGlare) {
|
|
1719
1626
|
if (isDebugEnabled()) {
|
|
1720
|
-
|
|
1721
|
-
'
|
|
1627
|
+
debugLog(
|
|
1628
|
+
'IdentityDocumentCamera',
|
|
1629
|
+
'[PASSPORT] Rejected - glare detected'
|
|
1722
1630
|
);
|
|
1723
1631
|
}
|
|
1724
|
-
|
|
1632
|
+
continueScanning(false);
|
|
1725
1633
|
return;
|
|
1726
1634
|
}
|
|
1727
1635
|
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
const retryThreshold = 60;
|
|
1731
|
-
const allowFaceOnly =
|
|
1732
|
-
mrzDetectionCurrentRetryCount.current > retryThreshold;
|
|
1733
|
-
const allRequiredElementsInFrame =
|
|
1734
|
-
hasFace && (hasSignature || allowFaceOnly);
|
|
1636
|
+
setDetectedDocumentType('PASSPORT');
|
|
1637
|
+
setStatus('SCANNED');
|
|
1735
1638
|
|
|
1736
|
-
|
|
1639
|
+
const nextPassportStep =
|
|
1640
|
+
flowResult.nextAction === 'PROCEED_TO_COMPLETED'
|
|
1641
|
+
? 'COMPLETED'
|
|
1642
|
+
: 'SCAN_HOLOGRAM';
|
|
1643
|
+
transitionStepWithCallback(
|
|
1644
|
+
nextPassportStep,
|
|
1645
|
+
'SCAN_ID_FRONT_OR_PASSPORT',
|
|
1646
|
+
scannedData
|
|
1647
|
+
);
|
|
1648
|
+
};
|
|
1737
1649
|
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1650
|
+
const handleIdFrontInitialStep = async () => {
|
|
1651
|
+
const flowResult = handleIDFrontFlow(
|
|
1652
|
+
primaryFaces,
|
|
1653
|
+
text,
|
|
1654
|
+
mrzText,
|
|
1655
|
+
parsedMRZData?.fields,
|
|
1656
|
+
mrzDetectionCurrentRetryCount.current
|
|
1657
|
+
);
|
|
1658
|
+
|
|
1659
|
+
if (!flowResult.shouldProceed) {
|
|
1660
|
+
if (flowResult.nextAction === 'REJECT_AS_PASSPORT') {
|
|
1661
|
+
setDetectedDocumentType('UNKNOWN');
|
|
1662
|
+
consistentDocTypeCount.current = 0;
|
|
1663
|
+
lastDetectedDocType.current = 'UNKNOWN';
|
|
1664
|
+
}
|
|
1665
|
+
continueScanning(flowResult.nextAction !== 'REJECT_AS_PASSPORT');
|
|
1744
1666
|
return;
|
|
1745
1667
|
}
|
|
1746
1668
|
|
|
1747
|
-
//
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
} else if (parsedMRZData.fields.documentCode === 'P') {
|
|
1755
|
-
if (isDebugEnabled()) {
|
|
1756
|
-
console.log(
|
|
1757
|
-
'[ID_FRONT Scan] MRZ shows passport (code P) - rejecting as ID_FRONT'
|
|
1758
|
-
);
|
|
1759
|
-
}
|
|
1760
|
-
setStatus('SCANNING');
|
|
1761
|
-
return;
|
|
1762
|
-
}
|
|
1763
|
-
} else if (mrzText && /P<[A-Z]{3}/.test(mrzText)) {
|
|
1764
|
-
// No parsed MRZ BUT passport MRZ pattern visible (P<TUR, P<USA, etc.)
|
|
1765
|
-
// This is likely a passport with OCR errors - wait for proper parsing
|
|
1669
|
+
// Check for glare on ID front before accepting
|
|
1670
|
+
const hasGlare = await checkDocumentGlare(
|
|
1671
|
+
image,
|
|
1672
|
+
frameWidth,
|
|
1673
|
+
frameHeight
|
|
1674
|
+
);
|
|
1675
|
+
if (hasGlare) {
|
|
1766
1676
|
if (isDebugEnabled()) {
|
|
1767
|
-
|
|
1768
|
-
'
|
|
1677
|
+
debugLog(
|
|
1678
|
+
'IdentityDocumentCamera',
|
|
1679
|
+
'[ID_FRONT] Rejected - glare detected'
|
|
1769
1680
|
);
|
|
1770
1681
|
}
|
|
1771
|
-
|
|
1772
|
-
setStatus('SCANNING');
|
|
1682
|
+
continueScanning(false);
|
|
1773
1683
|
return;
|
|
1774
1684
|
}
|
|
1775
|
-
// No MRZ or no passport pattern - proceed as ID card
|
|
1776
|
-
// ID cards typically don't have MRZ on front side (only on back)
|
|
1777
1685
|
|
|
1778
|
-
// CRITICAL: Lock document type state to ID_FRONT before proceeding
|
|
1779
|
-
// This ensures hologram completion knows it's an ID card (needs ID_BACK step)
|
|
1780
1686
|
setDetectedDocumentType('ID_FRONT');
|
|
1781
1687
|
setStatus('SCANNED');
|
|
1782
|
-
setIsTorchOn(false);
|
|
1783
|
-
if (onlyMRZScan) {
|
|
1784
|
-
// Passport has no back side - go directly to COMPLETED
|
|
1785
|
-
// At this point detectedDocumentType is definitively set
|
|
1786
|
-
if (detectedDocumentType === 'PASSPORT') {
|
|
1787
|
-
setNextStepAndVibrate('COMPLETED', 'SCAN_ID_FRONT_OR_PASSPORT');
|
|
1788
|
-
} else {
|
|
1789
|
-
setNextStepAndVibrate(
|
|
1790
|
-
'SCAN_ID_BACK',
|
|
1791
|
-
'SCAN_ID_FRONT_OR_PASSPORT'
|
|
1792
|
-
);
|
|
1793
|
-
}
|
|
1794
|
-
setTimeout(() => {
|
|
1795
|
-
onIdentityDocumentScanned(scannedData);
|
|
1796
|
-
}, 1000);
|
|
1797
|
-
} else {
|
|
1798
|
-
if (isDebugEnabled()) {
|
|
1799
|
-
console.log(
|
|
1800
|
-
'[ID_FRONT Scan] Confirmed as ID card - proceeding to hologram'
|
|
1801
|
-
);
|
|
1802
|
-
}
|
|
1803
|
-
setNextStepAndVibrate('SCAN_HOLOGRAM', 'SCAN_ID_FRONT_OR_PASSPORT');
|
|
1804
|
-
setTimeout(() => {
|
|
1805
|
-
onIdentityDocumentScanned(scannedData);
|
|
1806
|
-
}, 1000);
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
// Note: SCAN_HOLOGRAM completion is now handled in the unified block above
|
|
1810
|
-
} else if (documentType === 'PASSPORT') {
|
|
1811
|
-
if (
|
|
1812
|
-
nextStep === 'SCAN_ID_FRONT_OR_PASSPORT' &&
|
|
1813
|
-
!scannedData.hologramImage
|
|
1814
|
-
) {
|
|
1815
|
-
if (onlyMRZScan) {
|
|
1816
|
-
const hasRequiredFields = hasRequiredMRZFields(
|
|
1817
|
-
parsedMRZData?.fields
|
|
1818
|
-
);
|
|
1819
|
-
// CRITICAL: Only accept MRZ with valid checksums AND consistent reads
|
|
1820
|
-
if (
|
|
1821
|
-
!!scannedData.mrzText &&
|
|
1822
|
-
hasRequiredFields &&
|
|
1823
|
-
mrzStableAndValid
|
|
1824
|
-
) {
|
|
1825
|
-
const hasFace = cardSizedFaces.length > 0;
|
|
1826
|
-
const hasMRZ = !!mrzText;
|
|
1827
|
-
const allRequiredElementsInFrame = hasFace && hasMRZ;
|
|
1828
|
-
|
|
1829
|
-
setElementsOutsideScanArea([]);
|
|
1830
1688
|
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
parsedMRZData?.fields,
|
|
1841
|
-
mrzText,
|
|
1842
|
-
validMRZConsecutiveCount.current,
|
|
1843
|
-
isDebugEnabled()
|
|
1844
|
-
);
|
|
1845
|
-
setDetectedDocumentType('PASSPORT');
|
|
1846
|
-
setStatus('SCANNED');
|
|
1847
|
-
setIsTorchOn(false);
|
|
1848
|
-
setNextStepAndVibrate('COMPLETED', 'SCAN_ID_FRONT_OR_PASSPORT');
|
|
1849
|
-
setTimeout(() => {
|
|
1850
|
-
onIdentityDocumentScanned(scannedData);
|
|
1851
|
-
}, 1000);
|
|
1852
|
-
return; // CRITICAL: Exit after MRZ-only scan completes to prevent fall-through
|
|
1853
|
-
} else {
|
|
1854
|
-
if (!!scannedData.mrzText && !mrzStableAndValid) {
|
|
1855
|
-
logMRZValidationFailure(
|
|
1856
|
-
'Passport Scan',
|
|
1857
|
-
hasRequiredFields,
|
|
1858
|
-
parsedMRZData,
|
|
1859
|
-
mrzDetectionCurrentRetryCount.current,
|
|
1860
|
-
isDebugEnabled()
|
|
1861
|
-
);
|
|
1862
|
-
}
|
|
1863
|
-
mrzDetectionCurrentRetryCount.current++;
|
|
1864
|
-
setStatus('SCANNING');
|
|
1865
|
-
return; // Don't fall through to else-if
|
|
1866
|
-
}
|
|
1867
|
-
} else {
|
|
1868
|
-
// Normal passport scan (with hologram) - require MRZ to be detected before proceeding
|
|
1869
|
-
const hasFace = cardSizedFaces.length > 0;
|
|
1870
|
-
const hasMRZ = !!mrzText;
|
|
1871
|
-
const allRequiredElementsInFrame = hasFace && hasMRZ;
|
|
1872
|
-
|
|
1873
|
-
setElementsOutsideScanArea([]);
|
|
1874
|
-
|
|
1875
|
-
if (!allRequiredElementsInFrame) {
|
|
1876
|
-
console.log(
|
|
1877
|
-
'[Passport Scan] Valid but waiting for all elements in frame (face + MRZ)'
|
|
1878
|
-
);
|
|
1879
|
-
setStatus('SCANNING');
|
|
1880
|
-
return;
|
|
1881
|
-
}
|
|
1882
|
-
|
|
1883
|
-
// CRITICAL: Final verification - ensure MRZ definitively identifies this as passport
|
|
1884
|
-
// This must pass before we can proceed to hologram
|
|
1885
|
-
if (
|
|
1886
|
-
!parsedMRZData?.fields?.documentCode ||
|
|
1887
|
-
parsedMRZData.fields.documentCode !== 'P'
|
|
1888
|
-
) {
|
|
1889
|
-
console.log(
|
|
1890
|
-
'[Passport Scan] MRZ detected but not confirmed as passport (code:',
|
|
1891
|
-
parsedMRZData?.fields?.documentCode || 'none',
|
|
1892
|
-
') - waiting for valid passport MRZ'
|
|
1893
|
-
);
|
|
1894
|
-
setStatus('SCANNING');
|
|
1895
|
-
return;
|
|
1896
|
-
}
|
|
1689
|
+
const nextIdFrontStep = onlyMRZScan
|
|
1690
|
+
? 'SCAN_ID_BACK'
|
|
1691
|
+
: 'SCAN_HOLOGRAM';
|
|
1692
|
+
transitionStepWithCallback(
|
|
1693
|
+
nextIdFrontStep,
|
|
1694
|
+
'SCAN_ID_FRONT_OR_PASSPORT',
|
|
1695
|
+
scannedData
|
|
1696
|
+
);
|
|
1697
|
+
};
|
|
1897
1698
|
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
// This ensures hologram completion knows it's a passport (no ID_BACK step)
|
|
1903
|
-
setDetectedDocumentType('PASSPORT');
|
|
1904
|
-
setStatus('SCANNED');
|
|
1905
|
-
setIsTorchOn(false);
|
|
1906
|
-
setNextStepAndVibrate('SCAN_HOLOGRAM', 'SCAN_ID_FRONT_OR_PASSPORT');
|
|
1907
|
-
setTimeout(() => {
|
|
1908
|
-
onIdentityDocumentScanned(scannedData);
|
|
1909
|
-
}, 1000);
|
|
1910
|
-
}
|
|
1699
|
+
// PASSPORT FLOW: Face + MRZ with code 'P'
|
|
1700
|
+
if (flowDocumentType === 'PASSPORT') {
|
|
1701
|
+
handlePassportInitialStep();
|
|
1702
|
+
return;
|
|
1911
1703
|
}
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
setStatus('SCANNING');
|
|
1918
|
-
} else {
|
|
1919
|
-
// Document type UNKNOWN - continue scanning until we can classify it
|
|
1920
|
-
if (nextStep === 'SCAN_ID_FRONT_OR_PASSPORT') {
|
|
1921
|
-
console.log(
|
|
1922
|
-
'[Document Scan] Type UNKNOWN - waiting for clearer detection (faces:',
|
|
1923
|
-
cardSizedFaces.length,
|
|
1924
|
-
'mrzCode:',
|
|
1925
|
-
parsedMRZData?.fields?.documentCode || 'none',
|
|
1926
|
-
'text length:',
|
|
1927
|
-
text.length,
|
|
1928
|
-
')'
|
|
1929
|
-
);
|
|
1704
|
+
|
|
1705
|
+
// ID CARD FLOW: Face + No passport MRZ pattern
|
|
1706
|
+
if (flowDocumentType === 'ID_FRONT') {
|
|
1707
|
+
handleIdFrontInitialStep();
|
|
1708
|
+
return;
|
|
1930
1709
|
}
|
|
1931
|
-
|
|
1710
|
+
|
|
1711
|
+
// UNKNOWN - Continue scanning
|
|
1712
|
+
continueScanning();
|
|
1713
|
+
return;
|
|
1932
1714
|
}
|
|
1933
1715
|
},
|
|
1934
1716
|
[
|
|
@@ -1938,15 +1720,10 @@ const IdentityDocumentCamera = ({
|
|
|
1938
1720
|
detectedDocumentType,
|
|
1939
1721
|
currentFaceImage,
|
|
1940
1722
|
testMode,
|
|
1941
|
-
hasRequiredMRZFields,
|
|
1942
|
-
areMRZFieldsEqual,
|
|
1943
1723
|
onlyMRZScan,
|
|
1944
|
-
isTorchOn,
|
|
1945
1724
|
setIsTorchOn,
|
|
1946
|
-
|
|
1725
|
+
transitionStepWithCallback,
|
|
1947
1726
|
onIdentityDocumentScanned,
|
|
1948
|
-
logMRZDetails,
|
|
1949
|
-
logMRZValidationFailure,
|
|
1950
1727
|
currentSecondaryFaceImage,
|
|
1951
1728
|
detectHologramNative,
|
|
1952
1729
|
]
|
|
@@ -2099,61 +1876,18 @@ const IdentityDocumentCamera = ({
|
|
|
2099
1876
|
},
|
|
2100
1877
|
cornerPoints: b.cornerPoints ?? [],
|
|
2101
1878
|
}));
|
|
2102
|
-
|
|
2103
|
-
// Log barcode detection for debugging (only when scanning ID back)
|
|
2104
|
-
if (
|
|
2105
|
-
barcodes.length > 0 &&
|
|
2106
|
-
nextStep === 'SCAN_ID_BACK' &&
|
|
2107
|
-
isDebugEnabled()
|
|
2108
|
-
) {
|
|
2109
|
-
console.log(`[Barcode JS] Detected ${barcodes.length} barcode(s):`);
|
|
2110
|
-
barcodes.forEach((b, idx) => {
|
|
2111
|
-
const formatNames: { [key: number]: string } = {
|
|
2112
|
-
5: 'PDF417',
|
|
2113
|
-
64: 'QR_CODE',
|
|
2114
|
-
1: 'CODE_128',
|
|
2115
|
-
2: 'CODE_39',
|
|
2116
|
-
13: 'EAN_13',
|
|
2117
|
-
8: 'EAN_8',
|
|
2118
|
-
4096: 'AZTEC',
|
|
2119
|
-
16: 'DATA_MATRIX',
|
|
2120
|
-
};
|
|
2121
|
-
const formatName =
|
|
2122
|
-
formatNames[b.format] || `UNKNOWN(${b.format})`;
|
|
2123
|
-
console.log(
|
|
2124
|
-
` [${idx + 1}] ${formatName}: ${b.rawValue.substring(0, 50)}`
|
|
2125
|
-
);
|
|
2126
|
-
});
|
|
2127
|
-
}
|
|
2128
1879
|
}
|
|
2129
1880
|
|
|
2130
1881
|
// Update all debug overlay bounds continuously when debug mode is enabled
|
|
2131
1882
|
if (isDebugEnabled() && frameDimensions) {
|
|
2132
|
-
const
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
if (frameAspect > screenAspect) {
|
|
2141
|
-
scale = screen.height / frameDimensions.height;
|
|
2142
|
-
offsetX = (frameDimensions.width * scale - screen.width) / 2;
|
|
2143
|
-
} else {
|
|
2144
|
-
scale = screen.width / frameDimensions.width;
|
|
2145
|
-
offsetY = (frameDimensions.height * scale - screen.height) / 2;
|
|
2146
|
-
}
|
|
2147
|
-
|
|
2148
|
-
const scanLeft = (screen.width * 0.05 + offsetX) / scale;
|
|
2149
|
-
const scanTop = (screen.height * 0.36 + offsetY) / scale;
|
|
2150
|
-
const scanRight = (screen.width * 0.95 + offsetX) / scale;
|
|
2151
|
-
const scanBottom = (screen.height * 0.64 + offsetY) / scale;
|
|
2152
|
-
const isInsideScan = (x: number, y: number, w: number, h: number) =>
|
|
2153
|
-
x >= scanLeft &&
|
|
2154
|
-
y >= scanTop &&
|
|
2155
|
-
x + w <= scanRight &&
|
|
2156
|
-
y + h <= scanBottom;
|
|
1883
|
+
const { scale, offsetX, offsetY } = getFrameToScreenTransform(
|
|
1884
|
+
frameDimensions.width,
|
|
1885
|
+
frameDimensions.height
|
|
1886
|
+
);
|
|
1887
|
+
const { isInsideScan } = getScanAreaBounds(
|
|
1888
|
+
frameDimensions.width,
|
|
1889
|
+
frameDimensions.height
|
|
1890
|
+
);
|
|
2157
1891
|
|
|
2158
1892
|
// Update barcode bounds
|
|
2159
1893
|
if (barcodes.length > 0 && barcodes[0]) {
|
|
@@ -2167,15 +1901,12 @@ const IdentityDocumentCamera = ({
|
|
|
2167
1901
|
x: c.x * scale - offsetX,
|
|
2168
1902
|
y: c.y * scale - offsetY,
|
|
2169
1903
|
}));
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
1904
|
+
angle = angleBetweenPoints(
|
|
1905
|
+
transformedCorners[0],
|
|
1906
|
+
transformedCorners[1]
|
|
1907
|
+
);
|
|
2174
1908
|
}
|
|
2175
1909
|
|
|
2176
|
-
if (isDebugEnabled()) {
|
|
2177
|
-
console.log('[Debug] Barcode detected:', { bbox, angle });
|
|
2178
|
-
}
|
|
2179
1910
|
setBarcodeBounds({
|
|
2180
1911
|
x: bbox.left * scale - offsetX,
|
|
2181
1912
|
y: bbox.top * scale - offsetY,
|
|
@@ -2245,46 +1976,21 @@ const IdentityDocumentCamera = ({
|
|
|
2245
1976
|
|
|
2246
1977
|
// Detect MRZ and signature text areas continuously
|
|
2247
1978
|
if (textBlocks.length > 0) {
|
|
2248
|
-
|
|
2249
|
-
// Find MRZ-like text blocks (bottom area, contains MRZ-like characters)
|
|
2250
|
-
// More strict pattern: look for blocks with 8+ consecutive uppercase/numbers/< characters AND
|
|
2251
|
-
// must contain at least one '<' character (true MRZ characteristic)
|
|
2252
|
-
const mrzPattern = /[A-Z0-9<]{8,}.*</i;
|
|
2253
|
-
const bottomHalf = frame.height * 0.5; // Increased from 0.67 to catch more MRZ blocks
|
|
2254
|
-
|
|
2255
|
-
// Log bottom area blocks for debugging
|
|
2256
|
-
const bottomBlocks = textBlocks.filter(
|
|
2257
|
-
(block) => block.blockFrame && block.blockFrame.y > bottomHalf
|
|
2258
|
-
);
|
|
2259
|
-
if (bottomBlocks.length > 0) {
|
|
2260
|
-
console.log(
|
|
2261
|
-
'[Debug] Bottom area blocks:',
|
|
2262
|
-
bottomBlocks.map((b) => b.text.substring(0, 30))
|
|
2263
|
-
);
|
|
2264
|
-
}
|
|
2265
|
-
|
|
1979
|
+
const bottomHalf = frame.height * 0.5;
|
|
2266
1980
|
const mrzBlocks = textBlocks.filter(
|
|
2267
1981
|
(block) =>
|
|
2268
1982
|
block.blockFrame &&
|
|
2269
1983
|
block.blockFrame.y > bottomHalf &&
|
|
2270
|
-
|
|
1984
|
+
MRZ_BLOCK_PATTERN.test(block.text)
|
|
2271
1985
|
);
|
|
2272
1986
|
|
|
2273
|
-
console.log('[Debug] MRZ blocks found:', mrzBlocks.length);
|
|
2274
1987
|
if (mrzBlocks.length > 0) {
|
|
2275
|
-
// Extract MRZ-only text from detected blocks (sorted by Y position for correct line order)
|
|
2276
1988
|
const sortedMrzBlocks = [...mrzBlocks].sort(
|
|
2277
1989
|
(a, b) => (a.blockFrame?.y || 0) - (b.blockFrame?.y || 0)
|
|
2278
1990
|
);
|
|
2279
1991
|
scannedText.mrzOnlyText = sortedMrzBlocks
|
|
2280
1992
|
.map((b) => b.text)
|
|
2281
1993
|
.join('\n');
|
|
2282
|
-
if (isDebugEnabled()) {
|
|
2283
|
-
console.log(
|
|
2284
|
-
'[MRZ Extraction] Using only MRZ blocks:',
|
|
2285
|
-
scannedText.mrzOnlyText.substring(0, 100)
|
|
2286
|
-
);
|
|
2287
|
-
}
|
|
2288
1994
|
|
|
2289
1995
|
const minX = Math.min(...mrzBlocks.map((b) => b.blockFrame!.x));
|
|
2290
1996
|
const minY = Math.min(...mrzBlocks.map((b) => b.blockFrame!.y));
|
|
@@ -2294,30 +2000,17 @@ const IdentityDocumentCamera = ({
|
|
|
2294
2000
|
const maxY = Math.max(
|
|
2295
2001
|
...mrzBlocks.map((b) => b.blockFrame!.y + b.blockFrame!.height)
|
|
2296
2002
|
);
|
|
2297
|
-
|
|
2298
|
-
// Collect all corner points from MRZ blocks
|
|
2299
2003
|
const allCornerPoints = mrzBlocks
|
|
2300
2004
|
.flatMap((b) => b.cornerPoints || [])
|
|
2301
2005
|
.map((c) => ({
|
|
2302
2006
|
x: c.x * scale - offsetX,
|
|
2303
2007
|
y: c.y * scale - offsetY,
|
|
2304
2008
|
}));
|
|
2009
|
+
const angle =
|
|
2010
|
+
allCornerPoints.length >= 2
|
|
2011
|
+
? angleBetweenPoints(allCornerPoints[0], allCornerPoints[1])
|
|
2012
|
+
: 0;
|
|
2305
2013
|
|
|
2306
|
-
let angle = 0;
|
|
2307
|
-
if (allCornerPoints.length >= 2) {
|
|
2308
|
-
// Calculate angle from first two points
|
|
2309
|
-
const dx = allCornerPoints[1].x - allCornerPoints[0].x;
|
|
2310
|
-
const dy = allCornerPoints[1].y - allCornerPoints[0].y;
|
|
2311
|
-
angle = Math.atan2(dy, dx) * (180 / Math.PI);
|
|
2312
|
-
}
|
|
2313
|
-
|
|
2314
|
-
console.log('[Debug] MRZ bounds:', {
|
|
2315
|
-
minX,
|
|
2316
|
-
minY,
|
|
2317
|
-
maxX,
|
|
2318
|
-
maxY,
|
|
2319
|
-
angle,
|
|
2320
|
-
});
|
|
2321
2014
|
setMrzBounds({
|
|
2322
2015
|
x: minX * scale - offsetX,
|
|
2323
2016
|
y: minY * scale - offsetY,
|
|
@@ -2331,19 +2024,11 @@ const IdentityDocumentCamera = ({
|
|
|
2331
2024
|
setMrzBounds(null);
|
|
2332
2025
|
}
|
|
2333
2026
|
|
|
2334
|
-
// Detect signature area
|
|
2335
|
-
const signaturePattern = /signature|imza|İmza/i;
|
|
2336
2027
|
const signatureBlocks = textBlocks.filter(
|
|
2337
|
-
(block) =>
|
|
2028
|
+
(block) =>
|
|
2029
|
+
block.blockFrame && SIGNATURE_TEXT_REGEX.test(block.text)
|
|
2338
2030
|
);
|
|
2339
2031
|
|
|
2340
|
-
if (textBlocks.length > 0 && signatureBlocks.length === 0) {
|
|
2341
|
-
console.log(
|
|
2342
|
-
`[Signature Debug] No signature blocks found. All blocks (${textBlocks.length}):`,
|
|
2343
|
-
textBlocks.map((b) => b.text).join(' | ')
|
|
2344
|
-
);
|
|
2345
|
-
}
|
|
2346
|
-
|
|
2347
2032
|
if (signatureBlocks.length > 0) {
|
|
2348
2033
|
const minX = Math.min(
|
|
2349
2034
|
...signatureBlocks.map((b) => b.blockFrame!.x)
|
|
@@ -2361,22 +2046,16 @@ const IdentityDocumentCamera = ({
|
|
|
2361
2046
|
(b) => b.blockFrame!.y + b.blockFrame!.height
|
|
2362
2047
|
)
|
|
2363
2048
|
);
|
|
2364
|
-
|
|
2365
|
-
// Collect all corner points from signature blocks
|
|
2366
2049
|
const allCornerPoints = signatureBlocks
|
|
2367
2050
|
.flatMap((b) => b.cornerPoints || [])
|
|
2368
2051
|
.map((c) => ({
|
|
2369
2052
|
x: c.x * scale - offsetX,
|
|
2370
2053
|
y: c.y * scale - offsetY,
|
|
2371
2054
|
}));
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
const dx = allCornerPoints[1].x - allCornerPoints[0].x;
|
|
2377
|
-
const dy = allCornerPoints[1].y - allCornerPoints[0].y;
|
|
2378
|
-
angle = Math.atan2(dy, dx) * (180 / Math.PI);
|
|
2379
|
-
}
|
|
2055
|
+
const angle =
|
|
2056
|
+
allCornerPoints.length >= 2
|
|
2057
|
+
? angleBetweenPoints(allCornerPoints[0], allCornerPoints[1])
|
|
2058
|
+
: 0;
|
|
2380
2059
|
|
|
2381
2060
|
setSignatureBounds({
|
|
2382
2061
|
x: minX * scale - offsetX,
|
|
@@ -2390,81 +2069,9 @@ const IdentityDocumentCamera = ({
|
|
|
2390
2069
|
} else {
|
|
2391
2070
|
setSignatureBounds(null);
|
|
2392
2071
|
}
|
|
2393
|
-
|
|
2394
|
-
// Check if all required elements are detected based on document type
|
|
2395
|
-
if (nextStep === 'SCAN_ID_BACK') {
|
|
2396
|
-
// ID Back: MRZ + barcode (barcode optional but preferred)
|
|
2397
|
-
const hasMRZ = mrzBlocks.length > 0;
|
|
2398
|
-
const hasBarcode =
|
|
2399
|
-
barcodes.length > 0 || cachedBarcode.current !== null;
|
|
2400
|
-
const allPresent = hasMRZ && hasBarcode;
|
|
2401
|
-
setAllElementsDetected(allPresent);
|
|
2402
|
-
|
|
2403
|
-
// Don't block based on bounds - allow elements even if slightly outside
|
|
2404
|
-
setElementsOutsideScanArea([]);
|
|
2405
|
-
|
|
2406
|
-
if (!allPresent) {
|
|
2407
|
-
const missing = [];
|
|
2408
|
-
if (!hasMRZ) missing.push('MRZ');
|
|
2409
|
-
if (!hasBarcode) missing.push('Barcode');
|
|
2410
|
-
console.log(
|
|
2411
|
-
`[Frame Check] Missing elements: ${missing.join(', ')}`
|
|
2412
|
-
);
|
|
2413
|
-
} else {
|
|
2414
|
-
console.log('[Frame Check] ✓ All elements detected in frame');
|
|
2415
|
-
}
|
|
2416
|
-
} else if (nextStep === 'SCAN_ID_FRONT_OR_PASSPORT') {
|
|
2417
|
-
// Check if it's passport (has MRZ) or ID front (no MRZ)
|
|
2418
|
-
const hasMRZ = mrzBlocks.length > 0;
|
|
2419
|
-
const hasFace = detectedFaces.length > 0;
|
|
2420
|
-
const hasSignature = signatureBlocks.length > 0;
|
|
2421
|
-
|
|
2422
|
-
// Don't block based on bounds - allow elements even if slightly outside
|
|
2423
|
-
setElementsOutsideScanArea([]);
|
|
2424
|
-
|
|
2425
|
-
let allPresent = false;
|
|
2426
|
-
if (hasMRZ) {
|
|
2427
|
-
// Passport: face + MRZ
|
|
2428
|
-
allPresent = hasFace && hasMRZ;
|
|
2429
|
-
if (!allPresent) {
|
|
2430
|
-
const missing = [];
|
|
2431
|
-
if (!hasFace) missing.push('Face');
|
|
2432
|
-
if (!hasMRZ) missing.push('MRZ');
|
|
2433
|
-
console.log(
|
|
2434
|
-
`[Frame Check] Passport - Missing elements: ${missing.join(', ')}`
|
|
2435
|
-
);
|
|
2436
|
-
} else {
|
|
2437
|
-
console.log(
|
|
2438
|
-
'[Frame Check] ✓ Passport - All elements detected (face + MRZ)'
|
|
2439
|
-
);
|
|
2440
|
-
}
|
|
2441
|
-
} else {
|
|
2442
|
-
// ID Front: face + signature
|
|
2443
|
-
allPresent = hasFace && hasSignature;
|
|
2444
|
-
if (!allPresent) {
|
|
2445
|
-
const missing = [];
|
|
2446
|
-
if (!hasFace) missing.push('Face');
|
|
2447
|
-
if (!hasSignature) missing.push('Signature');
|
|
2448
|
-
console.log(
|
|
2449
|
-
`[Frame Check] ID Front - Missing elements: ${missing.join(', ')}`
|
|
2450
|
-
);
|
|
2451
|
-
} else {
|
|
2452
|
-
console.log(
|
|
2453
|
-
'[Frame Check] ✓ ID Front - All elements detected (face + signature)'
|
|
2454
|
-
);
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
|
-
setAllElementsDetected(allPresent);
|
|
2459
|
-
} else {
|
|
2460
|
-
setAllElementsDetected(false);
|
|
2461
|
-
setElementsOutsideScanArea([]);
|
|
2462
|
-
}
|
|
2463
2072
|
} else {
|
|
2464
2073
|
setMrzBounds(null);
|
|
2465
2074
|
setSignatureBounds(null);
|
|
2466
|
-
setAllElementsDetected(false);
|
|
2467
|
-
setElementsOutsideScanArea([]);
|
|
2468
2075
|
}
|
|
2469
2076
|
} else if (!isDebugEnabled()) {
|
|
2470
2077
|
// Clear all bounds when debug mode is disabled
|
|
@@ -2475,21 +2082,17 @@ const IdentityDocumentCamera = ({
|
|
|
2475
2082
|
setSignatureBounds(null);
|
|
2476
2083
|
}
|
|
2477
2084
|
|
|
2478
|
-
// Update allElementsDetected for status text display
|
|
2085
|
+
// Update allElementsDetected for status text display
|
|
2479
2086
|
if (nextStep === 'SCAN_ID_BACK') {
|
|
2480
|
-
const hasMRZ = textBlocks.some((b) =>
|
|
2481
|
-
/[A-Z0-9<]{8,}.*</i.test(b.text)
|
|
2482
|
-
);
|
|
2087
|
+
const hasMRZ = textBlocks.some((b) => MRZ_BLOCK_PATTERN.test(b.text));
|
|
2483
2088
|
const hasBarcode =
|
|
2484
2089
|
barcodes.length > 0 || cachedBarcode.current !== null;
|
|
2485
2090
|
setAllElementsDetected(hasMRZ && hasBarcode);
|
|
2486
2091
|
} else if (nextStep === 'SCAN_ID_FRONT_OR_PASSPORT') {
|
|
2487
|
-
const hasMRZ = textBlocks.some((b) =>
|
|
2488
|
-
/[A-Z0-9<]{8,}.*</i.test(b.text)
|
|
2489
|
-
);
|
|
2092
|
+
const hasMRZ = textBlocks.some((b) => MRZ_BLOCK_PATTERN.test(b.text));
|
|
2490
2093
|
const hasFace = detectedFaces.length > 0;
|
|
2491
2094
|
const hasSignature = textBlocks.some((b) =>
|
|
2492
|
-
|
|
2095
|
+
SIGNATURE_TEXT_REGEX.test(b.text)
|
|
2493
2096
|
);
|
|
2494
2097
|
setAllElementsDetected(
|
|
2495
2098
|
hasMRZ ? hasFace && hasMRZ : hasFace && hasSignature
|
|
@@ -2499,29 +2102,8 @@ const IdentityDocumentCamera = ({
|
|
|
2499
2102
|
}
|
|
2500
2103
|
|
|
2501
2104
|
// Check if detected elements are inside the scan area
|
|
2502
|
-
const
|
|
2503
|
-
|
|
2504
|
-
const scanScreenAspect = scanScreen.width / scanScreen.height;
|
|
2505
|
-
let scanScale: number;
|
|
2506
|
-
let scanOffsetX = 0;
|
|
2507
|
-
let scanOffsetY = 0;
|
|
2508
|
-
if (scanFrameAspect > scanScreenAspect) {
|
|
2509
|
-
scanScale = scanScreen.height / frame.height;
|
|
2510
|
-
scanOffsetX = (frame.width * scanScale - scanScreen.width) / 2;
|
|
2511
|
-
} else {
|
|
2512
|
-
scanScale = scanScreen.width / frame.width;
|
|
2513
|
-
scanOffsetY = (frame.height * scanScale - scanScreen.height) / 2;
|
|
2514
|
-
}
|
|
2515
|
-
const scanLeft = (scanScreen.width * 0.05 + scanOffsetX) / scanScale;
|
|
2516
|
-
const scanTop = (scanScreen.height * 0.36 + scanOffsetY) / scanScale;
|
|
2517
|
-
const scanRight = (scanScreen.width * 0.95 + scanOffsetX) / scanScale;
|
|
2518
|
-
const scanBottom = (scanScreen.height * 0.64 + scanOffsetY) / scanScale;
|
|
2519
|
-
|
|
2520
|
-
const isInsideScan = (x: number, y: number, w: number, h: number) =>
|
|
2521
|
-
x >= scanLeft &&
|
|
2522
|
-
y >= scanTop &&
|
|
2523
|
-
x + w <= scanRight &&
|
|
2524
|
-
y + h <= scanBottom;
|
|
2105
|
+
const { scanLeft, scanTop, scanRight, scanBottom, isInsideScan } =
|
|
2106
|
+
getScanAreaBounds(frame.width, frame.height);
|
|
2525
2107
|
|
|
2526
2108
|
const outsideElements: string[] = [];
|
|
2527
2109
|
|
|
@@ -2567,8 +2149,8 @@ const IdentityDocumentCamera = ({
|
|
|
2567
2149
|
y2: bf.y + bf.height,
|
|
2568
2150
|
});
|
|
2569
2151
|
}
|
|
2570
|
-
const isMRZ =
|
|
2571
|
-
const isSignature =
|
|
2152
|
+
const isMRZ = MRZ_BLOCK_PATTERN.test(block.text);
|
|
2153
|
+
const isSignature = SIGNATURE_TEXT_REGEX.test(block.text);
|
|
2572
2154
|
if (
|
|
2573
2155
|
(isMRZ || isSignature) &&
|
|
2574
2156
|
!isInsideScan(bf.x, bf.y, bf.width, bf.height)
|
|
@@ -2734,444 +2316,6 @@ const IdentityDocumentCamera = ({
|
|
|
2734
2316
|
onCameraReady={handleCameraReady}
|
|
2735
2317
|
onCameraError={handleCameraError}
|
|
2736
2318
|
/>
|
|
2737
|
-
{isDebugEnabled() &&
|
|
2738
|
-
documentPlaneBounds &&
|
|
2739
|
-
nextStep !== 'COMPLETED' && (
|
|
2740
|
-
<>
|
|
2741
|
-
{/* Crop area border (with padding) */}
|
|
2742
|
-
{!!documentPlaneBounds.cropPadding && (
|
|
2743
|
-
<View
|
|
2744
|
-
style={{
|
|
2745
|
-
position: 'absolute',
|
|
2746
|
-
left:
|
|
2747
|
-
documentPlaneBounds.x - documentPlaneBounds.cropPadding,
|
|
2748
|
-
top:
|
|
2749
|
-
documentPlaneBounds.y - documentPlaneBounds.cropPadding,
|
|
2750
|
-
width:
|
|
2751
|
-
documentPlaneBounds.width +
|
|
2752
|
-
2 * documentPlaneBounds.cropPadding,
|
|
2753
|
-
height:
|
|
2754
|
-
documentPlaneBounds.height +
|
|
2755
|
-
2 * documentPlaneBounds.cropPadding,
|
|
2756
|
-
borderWidth: 2,
|
|
2757
|
-
borderColor: 'rgba(76, 175, 80, 0.5)',
|
|
2758
|
-
borderStyle: 'dashed',
|
|
2759
|
-
borderRadius: 8,
|
|
2760
|
-
backgroundColor: 'transparent',
|
|
2761
|
-
transform: [
|
|
2762
|
-
{
|
|
2763
|
-
rotate: `${-(documentPlaneBounds.rollAngle || 0)}deg`,
|
|
2764
|
-
},
|
|
2765
|
-
],
|
|
2766
|
-
transformOrigin: 'center',
|
|
2767
|
-
}}
|
|
2768
|
-
/>
|
|
2769
|
-
)}
|
|
2770
|
-
{/* Actual face border */}
|
|
2771
|
-
<View
|
|
2772
|
-
style={{
|
|
2773
|
-
position: 'absolute',
|
|
2774
|
-
left: documentPlaneBounds.x,
|
|
2775
|
-
top: documentPlaneBounds.y,
|
|
2776
|
-
width: documentPlaneBounds.width,
|
|
2777
|
-
height: documentPlaneBounds.height,
|
|
2778
|
-
borderWidth: 3,
|
|
2779
|
-
borderColor: '#4CAF50',
|
|
2780
|
-
borderRadius: 8,
|
|
2781
|
-
backgroundColor: 'transparent',
|
|
2782
|
-
transform: [
|
|
2783
|
-
{ rotate: `${-(documentPlaneBounds.rollAngle || 0)}deg` },
|
|
2784
|
-
],
|
|
2785
|
-
transformOrigin: 'center',
|
|
2786
|
-
}}
|
|
2787
|
-
>
|
|
2788
|
-
{!!documentPlaneBounds.rollAngle &&
|
|
2789
|
-
Math.abs(documentPlaneBounds.rollAngle) > 5 && (
|
|
2790
|
-
<TextView
|
|
2791
|
-
style={{
|
|
2792
|
-
position: 'absolute',
|
|
2793
|
-
top: -20,
|
|
2794
|
-
left: 0,
|
|
2795
|
-
color: '#4CAF50',
|
|
2796
|
-
fontSize: 10,
|
|
2797
|
-
fontWeight: 'bold',
|
|
2798
|
-
backgroundColor: 'rgba(0,0,0,0.7)',
|
|
2799
|
-
paddingHorizontal: 4,
|
|
2800
|
-
paddingVertical: 2,
|
|
2801
|
-
borderRadius: 2,
|
|
2802
|
-
}}
|
|
2803
|
-
>
|
|
2804
|
-
{documentPlaneBounds.rollAngle.toFixed(1)}°
|
|
2805
|
-
</TextView>
|
|
2806
|
-
)}
|
|
2807
|
-
</View>
|
|
2808
|
-
</>
|
|
2809
|
-
)}
|
|
2810
|
-
{isDebugEnabled() &&
|
|
2811
|
-
secondaryFaceBounds &&
|
|
2812
|
-
nextStep !== 'COMPLETED' && (
|
|
2813
|
-
<>
|
|
2814
|
-
{/* Crop area border (with padding) */}
|
|
2815
|
-
{!!secondaryFaceBounds.cropPadding && (
|
|
2816
|
-
<View
|
|
2817
|
-
style={{
|
|
2818
|
-
position: 'absolute',
|
|
2819
|
-
left:
|
|
2820
|
-
secondaryFaceBounds.x - secondaryFaceBounds.cropPadding,
|
|
2821
|
-
top:
|
|
2822
|
-
secondaryFaceBounds.y - secondaryFaceBounds.cropPadding,
|
|
2823
|
-
width:
|
|
2824
|
-
secondaryFaceBounds.width +
|
|
2825
|
-
2 * secondaryFaceBounds.cropPadding,
|
|
2826
|
-
height:
|
|
2827
|
-
secondaryFaceBounds.height +
|
|
2828
|
-
2 * secondaryFaceBounds.cropPadding,
|
|
2829
|
-
borderWidth: 2,
|
|
2830
|
-
borderColor: 'rgba(33, 150, 243, 0.5)',
|
|
2831
|
-
borderStyle: 'dashed',
|
|
2832
|
-
borderRadius: 8,
|
|
2833
|
-
backgroundColor: 'transparent',
|
|
2834
|
-
transform: [
|
|
2835
|
-
{
|
|
2836
|
-
rotate: `${-(secondaryFaceBounds.rollAngle || 0)}deg`,
|
|
2837
|
-
},
|
|
2838
|
-
],
|
|
2839
|
-
transformOrigin: 'center',
|
|
2840
|
-
}}
|
|
2841
|
-
/>
|
|
2842
|
-
)}
|
|
2843
|
-
{/* Actual face border */}
|
|
2844
|
-
<View
|
|
2845
|
-
style={{
|
|
2846
|
-
position: 'absolute',
|
|
2847
|
-
left: secondaryFaceBounds.x,
|
|
2848
|
-
top: secondaryFaceBounds.y,
|
|
2849
|
-
width: secondaryFaceBounds.width,
|
|
2850
|
-
height: secondaryFaceBounds.height,
|
|
2851
|
-
borderWidth: 3,
|
|
2852
|
-
borderColor: '#2196F3',
|
|
2853
|
-
borderRadius: 8,
|
|
2854
|
-
backgroundColor: 'transparent',
|
|
2855
|
-
transform: [
|
|
2856
|
-
{ rotate: `${-(secondaryFaceBounds.rollAngle || 0)}deg` },
|
|
2857
|
-
],
|
|
2858
|
-
transformOrigin: 'center',
|
|
2859
|
-
}}
|
|
2860
|
-
>
|
|
2861
|
-
{!!secondaryFaceBounds.rollAngle &&
|
|
2862
|
-
Math.abs(secondaryFaceBounds.rollAngle) > 5 && (
|
|
2863
|
-
<TextView
|
|
2864
|
-
style={{
|
|
2865
|
-
position: 'absolute',
|
|
2866
|
-
top: -20,
|
|
2867
|
-
left: 0,
|
|
2868
|
-
color: '#2196F3',
|
|
2869
|
-
fontSize: 10,
|
|
2870
|
-
fontWeight: 'bold',
|
|
2871
|
-
backgroundColor: 'rgba(0,0,0,0.7)',
|
|
2872
|
-
paddingHorizontal: 4,
|
|
2873
|
-
paddingVertical: 2,
|
|
2874
|
-
borderRadius: 2,
|
|
2875
|
-
}}
|
|
2876
|
-
>
|
|
2877
|
-
{secondaryFaceBounds.rollAngle.toFixed(1)}°
|
|
2878
|
-
</TextView>
|
|
2879
|
-
)}
|
|
2880
|
-
</View>
|
|
2881
|
-
</>
|
|
2882
|
-
)}
|
|
2883
|
-
{isDebugEnabled() && barcodeBounds && nextStep !== 'COMPLETED' && (
|
|
2884
|
-
<>
|
|
2885
|
-
{barcodeBounds.corners && barcodeBounds.corners.length >= 4 ? (
|
|
2886
|
-
// Render using corner points for precise rotated border
|
|
2887
|
-
<>
|
|
2888
|
-
{/* Draw border lines between corners */}
|
|
2889
|
-
{[0, 1, 2, 3].map((i) => {
|
|
2890
|
-
const start = barcodeBounds.corners![i];
|
|
2891
|
-
const end = barcodeBounds.corners![(i + 1) % 4];
|
|
2892
|
-
const dx = end.x - start.x;
|
|
2893
|
-
const dy = end.y - start.y;
|
|
2894
|
-
const length = Math.sqrt(dx * dx + dy * dy);
|
|
2895
|
-
const angle = Math.atan2(dy, dx) * (180 / Math.PI);
|
|
2896
|
-
|
|
2897
|
-
return (
|
|
2898
|
-
<View
|
|
2899
|
-
key={i}
|
|
2900
|
-
style={{
|
|
2901
|
-
position: 'absolute',
|
|
2902
|
-
left: start.x,
|
|
2903
|
-
top: start.y,
|
|
2904
|
-
width: length,
|
|
2905
|
-
height: 3,
|
|
2906
|
-
backgroundColor: '#FF9800',
|
|
2907
|
-
transform: [{ rotate: `${angle}deg` }],
|
|
2908
|
-
transformOrigin: 'top left',
|
|
2909
|
-
}}
|
|
2910
|
-
/>
|
|
2911
|
-
);
|
|
2912
|
-
})}
|
|
2913
|
-
{/* Draw corner markers */}
|
|
2914
|
-
{barcodeBounds.corners.map((corner, idx) => (
|
|
2915
|
-
<View
|
|
2916
|
-
key={`corner-${idx}`}
|
|
2917
|
-
style={{
|
|
2918
|
-
position: 'absolute',
|
|
2919
|
-
left: corner.x - 4,
|
|
2920
|
-
top: corner.y - 4,
|
|
2921
|
-
width: 8,
|
|
2922
|
-
height: 8,
|
|
2923
|
-
borderRadius: 4,
|
|
2924
|
-
backgroundColor: '#FF9800',
|
|
2925
|
-
}}
|
|
2926
|
-
/>
|
|
2927
|
-
))}
|
|
2928
|
-
{/* Angle indicator */}
|
|
2929
|
-
{!!barcodeBounds.angle &&
|
|
2930
|
-
Math.abs(barcodeBounds.angle) > 5 && (
|
|
2931
|
-
<TextView
|
|
2932
|
-
style={{
|
|
2933
|
-
position: 'absolute',
|
|
2934
|
-
left: barcodeBounds.x,
|
|
2935
|
-
top: barcodeBounds.y - 20,
|
|
2936
|
-
color: '#FF9800',
|
|
2937
|
-
fontSize: 10,
|
|
2938
|
-
fontWeight: 'bold',
|
|
2939
|
-
backgroundColor: 'rgba(0,0,0,0.7)',
|
|
2940
|
-
paddingHorizontal: 4,
|
|
2941
|
-
paddingVertical: 2,
|
|
2942
|
-
borderRadius: 2,
|
|
2943
|
-
}}
|
|
2944
|
-
>
|
|
2945
|
-
{barcodeBounds.angle.toFixed(1)}°
|
|
2946
|
-
</TextView>
|
|
2947
|
-
)}
|
|
2948
|
-
</>
|
|
2949
|
-
) : (
|
|
2950
|
-
// Fallback to rotated rectangle if corners not available
|
|
2951
|
-
<View
|
|
2952
|
-
style={{
|
|
2953
|
-
position: 'absolute',
|
|
2954
|
-
left: barcodeBounds.x + barcodeBounds.width / 2,
|
|
2955
|
-
top: barcodeBounds.y + barcodeBounds.height / 2,
|
|
2956
|
-
width: barcodeBounds.width,
|
|
2957
|
-
height: barcodeBounds.height,
|
|
2958
|
-
marginLeft: -barcodeBounds.width / 2,
|
|
2959
|
-
marginTop: -barcodeBounds.height / 2,
|
|
2960
|
-
borderWidth: 3,
|
|
2961
|
-
borderColor: '#FF9800',
|
|
2962
|
-
borderRadius: 8,
|
|
2963
|
-
backgroundColor: 'transparent',
|
|
2964
|
-
transform: [{ rotate: `${barcodeBounds.angle || 0}deg` }],
|
|
2965
|
-
}}
|
|
2966
|
-
>
|
|
2967
|
-
{!!barcodeBounds.angle &&
|
|
2968
|
-
Math.abs(barcodeBounds.angle) > 5 && (
|
|
2969
|
-
<TextView
|
|
2970
|
-
style={{
|
|
2971
|
-
position: 'absolute',
|
|
2972
|
-
top: -20,
|
|
2973
|
-
left: 0,
|
|
2974
|
-
color: '#FF9800',
|
|
2975
|
-
fontSize: 10,
|
|
2976
|
-
fontWeight: 'bold',
|
|
2977
|
-
backgroundColor: 'rgba(0,0,0,0.7)',
|
|
2978
|
-
paddingHorizontal: 4,
|
|
2979
|
-
paddingVertical: 2,
|
|
2980
|
-
borderRadius: 2,
|
|
2981
|
-
}}
|
|
2982
|
-
>
|
|
2983
|
-
{barcodeBounds.angle.toFixed(1)}°
|
|
2984
|
-
</TextView>
|
|
2985
|
-
)}
|
|
2986
|
-
</View>
|
|
2987
|
-
)}
|
|
2988
|
-
</>
|
|
2989
|
-
)}
|
|
2990
|
-
{isDebugEnabled() && mrzBounds && nextStep !== 'COMPLETED' && (
|
|
2991
|
-
<>
|
|
2992
|
-
{mrzBounds.corners && mrzBounds.corners.length >= 2 ? (
|
|
2993
|
-
// Render using corner points for precise rotated border
|
|
2994
|
-
<>
|
|
2995
|
-
{/* Draw border lines between consecutive corners */}
|
|
2996
|
-
{mrzBounds.corners.map((corner, idx) => {
|
|
2997
|
-
const nextCorner =
|
|
2998
|
-
mrzBounds.corners![(idx + 1) % mrzBounds.corners!.length];
|
|
2999
|
-
const dx = nextCorner.x - corner.x;
|
|
3000
|
-
const dy = nextCorner.y - corner.y;
|
|
3001
|
-
const length = Math.sqrt(dx * dx + dy * dy);
|
|
3002
|
-
const angle = Math.atan2(dy, dx) * (180 / Math.PI);
|
|
3003
|
-
|
|
3004
|
-
return (
|
|
3005
|
-
<View
|
|
3006
|
-
key={idx}
|
|
3007
|
-
style={{
|
|
3008
|
-
position: 'absolute',
|
|
3009
|
-
left: corner.x,
|
|
3010
|
-
top: corner.y,
|
|
3011
|
-
width: length,
|
|
3012
|
-
height: 3,
|
|
3013
|
-
backgroundColor: '#9C27B0',
|
|
3014
|
-
transform: [{ rotate: `${angle}deg` }],
|
|
3015
|
-
transformOrigin: 'top left',
|
|
3016
|
-
}}
|
|
3017
|
-
/>
|
|
3018
|
-
);
|
|
3019
|
-
})}
|
|
3020
|
-
{/* Angle indicator */}
|
|
3021
|
-
{!!mrzBounds.angle && Math.abs(mrzBounds.angle) > 5 && (
|
|
3022
|
-
<TextView
|
|
3023
|
-
style={{
|
|
3024
|
-
position: 'absolute',
|
|
3025
|
-
left: mrzBounds.x,
|
|
3026
|
-
top: mrzBounds.y - 20,
|
|
3027
|
-
color: '#9C27B0',
|
|
3028
|
-
fontSize: 10,
|
|
3029
|
-
fontWeight: 'bold',
|
|
3030
|
-
backgroundColor: 'rgba(0,0,0,0.7)',
|
|
3031
|
-
paddingHorizontal: 4,
|
|
3032
|
-
paddingVertical: 2,
|
|
3033
|
-
borderRadius: 2,
|
|
3034
|
-
}}
|
|
3035
|
-
>
|
|
3036
|
-
{mrzBounds.angle.toFixed(1)}°
|
|
3037
|
-
</TextView>
|
|
3038
|
-
)}
|
|
3039
|
-
</>
|
|
3040
|
-
) : (
|
|
3041
|
-
// Fallback to rotated rectangle if corners not available
|
|
3042
|
-
<View
|
|
3043
|
-
style={{
|
|
3044
|
-
position: 'absolute',
|
|
3045
|
-
left: mrzBounds.x + mrzBounds.width / 2,
|
|
3046
|
-
top: mrzBounds.y + mrzBounds.height / 2,
|
|
3047
|
-
width: mrzBounds.width,
|
|
3048
|
-
height: mrzBounds.height,
|
|
3049
|
-
marginLeft: -mrzBounds.width / 2,
|
|
3050
|
-
marginTop: -mrzBounds.height / 2,
|
|
3051
|
-
borderWidth: 3,
|
|
3052
|
-
borderColor: '#9C27B0',
|
|
3053
|
-
borderRadius: 8,
|
|
3054
|
-
backgroundColor: 'transparent',
|
|
3055
|
-
transform: [{ rotate: `${mrzBounds.angle || 0}deg` }],
|
|
3056
|
-
}}
|
|
3057
|
-
>
|
|
3058
|
-
{!!mrzBounds.angle && Math.abs(mrzBounds.angle) > 5 && (
|
|
3059
|
-
<TextView
|
|
3060
|
-
style={{
|
|
3061
|
-
position: 'absolute',
|
|
3062
|
-
top: -20,
|
|
3063
|
-
left: 0,
|
|
3064
|
-
color: '#9C27B0',
|
|
3065
|
-
fontSize: 10,
|
|
3066
|
-
fontWeight: 'bold',
|
|
3067
|
-
backgroundColor: 'rgba(0,0,0,0.7)',
|
|
3068
|
-
paddingHorizontal: 4,
|
|
3069
|
-
paddingVertical: 2,
|
|
3070
|
-
borderRadius: 2,
|
|
3071
|
-
}}
|
|
3072
|
-
>
|
|
3073
|
-
{mrzBounds.angle.toFixed(1)}°
|
|
3074
|
-
</TextView>
|
|
3075
|
-
)}
|
|
3076
|
-
</View>
|
|
3077
|
-
)}
|
|
3078
|
-
</>
|
|
3079
|
-
)}
|
|
3080
|
-
{isDebugEnabled() && signatureBounds && nextStep !== 'COMPLETED' && (
|
|
3081
|
-
<>
|
|
3082
|
-
{signatureBounds.corners &&
|
|
3083
|
-
signatureBounds.corners.length >= 2 ? (
|
|
3084
|
-
// Render using corner points for precise rotated border
|
|
3085
|
-
<>
|
|
3086
|
-
{/* Draw border lines between consecutive corners */}
|
|
3087
|
-
{signatureBounds.corners.map((corner, idx) => {
|
|
3088
|
-
const nextCorner =
|
|
3089
|
-
signatureBounds.corners![
|
|
3090
|
-
(idx + 1) % signatureBounds.corners!.length
|
|
3091
|
-
];
|
|
3092
|
-
const dx = nextCorner.x - corner.x;
|
|
3093
|
-
const dy = nextCorner.y - corner.y;
|
|
3094
|
-
const length = Math.sqrt(dx * dx + dy * dy);
|
|
3095
|
-
const angle = Math.atan2(dy, dx) * (180 / Math.PI);
|
|
3096
|
-
|
|
3097
|
-
return (
|
|
3098
|
-
<View
|
|
3099
|
-
key={idx}
|
|
3100
|
-
style={{
|
|
3101
|
-
position: 'absolute',
|
|
3102
|
-
left: corner.x,
|
|
3103
|
-
top: corner.y,
|
|
3104
|
-
width: length,
|
|
3105
|
-
height: 3,
|
|
3106
|
-
backgroundColor: '#00BCD4',
|
|
3107
|
-
transform: [{ rotate: `${angle}deg` }],
|
|
3108
|
-
transformOrigin: 'top left',
|
|
3109
|
-
}}
|
|
3110
|
-
/>
|
|
3111
|
-
);
|
|
3112
|
-
})}
|
|
3113
|
-
{/* Angle indicator */}
|
|
3114
|
-
{!!signatureBounds.angle &&
|
|
3115
|
-
Math.abs(signatureBounds.angle) > 5 && (
|
|
3116
|
-
<TextView
|
|
3117
|
-
style={{
|
|
3118
|
-
position: 'absolute',
|
|
3119
|
-
left: signatureBounds.x,
|
|
3120
|
-
top: signatureBounds.y - 20,
|
|
3121
|
-
color: '#00BCD4',
|
|
3122
|
-
fontSize: 10,
|
|
3123
|
-
fontWeight: 'bold',
|
|
3124
|
-
backgroundColor: 'rgba(0,0,0,0.7)',
|
|
3125
|
-
paddingHorizontal: 4,
|
|
3126
|
-
paddingVertical: 2,
|
|
3127
|
-
borderRadius: 2,
|
|
3128
|
-
}}
|
|
3129
|
-
>
|
|
3130
|
-
{signatureBounds.angle.toFixed(1)}°
|
|
3131
|
-
</TextView>
|
|
3132
|
-
)}
|
|
3133
|
-
</>
|
|
3134
|
-
) : (
|
|
3135
|
-
// Fallback to rotated rectangle if corners not available
|
|
3136
|
-
<View
|
|
3137
|
-
style={{
|
|
3138
|
-
position: 'absolute',
|
|
3139
|
-
left: signatureBounds.x + signatureBounds.width / 2,
|
|
3140
|
-
top: signatureBounds.y + signatureBounds.height / 2,
|
|
3141
|
-
width: signatureBounds.width,
|
|
3142
|
-
height: signatureBounds.height,
|
|
3143
|
-
marginLeft: -signatureBounds.width / 2,
|
|
3144
|
-
marginTop: -signatureBounds.height / 2,
|
|
3145
|
-
borderWidth: 3,
|
|
3146
|
-
borderColor: '#00BCD4',
|
|
3147
|
-
borderRadius: 8,
|
|
3148
|
-
backgroundColor: 'transparent',
|
|
3149
|
-
transform: [{ rotate: `${signatureBounds.angle || 0}deg` }],
|
|
3150
|
-
}}
|
|
3151
|
-
>
|
|
3152
|
-
{!!signatureBounds.angle &&
|
|
3153
|
-
Math.abs(signatureBounds.angle) > 5 && (
|
|
3154
|
-
<TextView
|
|
3155
|
-
style={{
|
|
3156
|
-
position: 'absolute',
|
|
3157
|
-
top: -20,
|
|
3158
|
-
left: 0,
|
|
3159
|
-
color: '#00BCD4',
|
|
3160
|
-
fontSize: 10,
|
|
3161
|
-
fontWeight: 'bold',
|
|
3162
|
-
backgroundColor: 'rgba(0,0,0,0.7)',
|
|
3163
|
-
paddingHorizontal: 4,
|
|
3164
|
-
paddingVertical: 2,
|
|
3165
|
-
borderRadius: 2,
|
|
3166
|
-
}}
|
|
3167
|
-
>
|
|
3168
|
-
{signatureBounds.angle.toFixed(1)}°
|
|
3169
|
-
</TextView>
|
|
3170
|
-
)}
|
|
3171
|
-
</View>
|
|
3172
|
-
)}
|
|
3173
|
-
</>
|
|
3174
|
-
)}
|
|
3175
2319
|
<View style={[styles.topZone, { paddingTop: insets.top }]}>
|
|
3176
2320
|
{nextStep !== 'COMPLETED' &&
|
|
3177
2321
|
status !== 'SCANNED' &&
|
|
@@ -3228,64 +2372,16 @@ const IdentityDocumentCamera = ({
|
|
|
3228
2372
|
// 5. Default (white) - aligning (not all detected OR elements outside scan area)
|
|
3229
2373
|
]}
|
|
3230
2374
|
>
|
|
3231
|
-
{
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
: isBrightnessLow
|
|
3242
|
-
? t('identityDocumentCamera.lowBrightness')
|
|
3243
|
-
: isFrameBlurry
|
|
3244
|
-
? t('identityDocumentCamera.avoidBlur')
|
|
3245
|
-
: status === 'SCANNING' &&
|
|
3246
|
-
allElementsDetected &&
|
|
3247
|
-
elementsOutsideScanArea.length === 0
|
|
3248
|
-
? nextStep === 'SCAN_ID_BACK'
|
|
3249
|
-
? t('identityDocumentCamera.idCardBackDetected')
|
|
3250
|
-
: detectedDocumentType === 'PASSPORT'
|
|
3251
|
-
? t('identityDocumentCamera.passportDetected')
|
|
3252
|
-
: detectedDocumentType === 'ID_FRONT'
|
|
3253
|
-
? t('identityDocumentCamera.idCardFrontDetected')
|
|
3254
|
-
: nextStep === 'SCAN_HOLOGRAM'
|
|
3255
|
-
? t('identityDocumentCamera.alignHologram')
|
|
3256
|
-
: t('identityDocumentCamera.readingDocument')
|
|
3257
|
-
: elementsOutsideScanArea.length > 0
|
|
3258
|
-
? t('identityDocumentCamera.centerDocument')
|
|
3259
|
-
: (status === 'SCANNING' || status === 'SEARCHING') &&
|
|
3260
|
-
!allElementsDetected
|
|
3261
|
-
? nextStep === 'SCAN_ID_BACK'
|
|
3262
|
-
? t('identityDocumentCamera.alignIDBack')
|
|
3263
|
-
: nextStep === 'SCAN_ID_FRONT_OR_PASSPORT'
|
|
3264
|
-
? detectedDocumentType === 'PASSPORT'
|
|
3265
|
-
? t('identityDocumentCamera.alignPassport')
|
|
3266
|
-
: detectedDocumentType === 'ID_FRONT'
|
|
3267
|
-
? t('identityDocumentCamera.alignIDFront')
|
|
3268
|
-
: t('identityDocumentCamera.alignPhotoSide')
|
|
3269
|
-
: nextStep === 'SCAN_HOLOGRAM'
|
|
3270
|
-
? t('identityDocumentCamera.alignHologram')
|
|
3271
|
-
: t('identityDocumentCamera.readingDocument')
|
|
3272
|
-
: nextStep === 'SCAN_ID_FRONT_OR_PASSPORT'
|
|
3273
|
-
? status === 'SCANNING'
|
|
3274
|
-
? t('identityDocumentCamera.readingDocument')
|
|
3275
|
-
: t('identityDocumentCamera.alignPhotoSide')
|
|
3276
|
-
: nextStep === 'SCAN_HOLOGRAM'
|
|
3277
|
-
? t('identityDocumentCamera.alignHologram')
|
|
3278
|
-
: nextStep === 'SCAN_ID_BACK'
|
|
3279
|
-
? status === 'SCANNING'
|
|
3280
|
-
? t(
|
|
3281
|
-
'identityDocumentCamera.readingDocument'
|
|
3282
|
-
)
|
|
3283
|
-
: t(
|
|
3284
|
-
'identityDocumentCamera.alignIDBackSide'
|
|
3285
|
-
)
|
|
3286
|
-
: nextStep === 'COMPLETED'
|
|
3287
|
-
? t('identityDocumentCamera.scanCompleted')
|
|
3288
|
-
: ''}
|
|
2375
|
+
{getStatusMessage(
|
|
2376
|
+
nextStep,
|
|
2377
|
+
status,
|
|
2378
|
+
detectedDocumentType,
|
|
2379
|
+
isBrightnessLow,
|
|
2380
|
+
isFrameBlurry,
|
|
2381
|
+
allElementsDetected,
|
|
2382
|
+
elementsOutsideScanArea,
|
|
2383
|
+
t
|
|
2384
|
+
)}
|
|
3289
2385
|
</AnimatedText>
|
|
3290
2386
|
</View>
|
|
3291
2387
|
<View style={styles.leftZone} />
|
|
@@ -3333,476 +2429,30 @@ const IdentityDocumentCamera = ({
|
|
|
3333
2429
|
) : null}
|
|
3334
2430
|
</View>
|
|
3335
2431
|
{isDebugEnabled() && (
|
|
3336
|
-
<
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
}
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
}}
|
|
3358
|
-
>
|
|
3359
|
-
{/* Status & State Row */}
|
|
3360
|
-
<View
|
|
3361
|
-
style={{
|
|
3362
|
-
flexDirection: 'row',
|
|
3363
|
-
justifyContent: 'space-between',
|
|
3364
|
-
marginBottom: 4,
|
|
3365
|
-
}}
|
|
3366
|
-
>
|
|
3367
|
-
<TextView
|
|
3368
|
-
style={{
|
|
3369
|
-
color: '#88D8B0',
|
|
3370
|
-
fontSize: 10,
|
|
3371
|
-
fontWeight: 'bold',
|
|
3372
|
-
}}
|
|
3373
|
-
>
|
|
3374
|
-
{`Status: ${status}`}
|
|
3375
|
-
</TextView>
|
|
3376
|
-
<TextView
|
|
3377
|
-
style={{
|
|
3378
|
-
color: '#FFEB3B',
|
|
3379
|
-
fontSize: 10,
|
|
3380
|
-
fontWeight: 'bold',
|
|
3381
|
-
}}
|
|
3382
|
-
>
|
|
3383
|
-
{`Step: ${nextStep}`}
|
|
3384
|
-
</TextView>
|
|
3385
|
-
</View>
|
|
3386
|
-
|
|
3387
|
-
{/* Quality Info - Badges */}
|
|
3388
|
-
<View
|
|
3389
|
-
style={{
|
|
3390
|
-
flexDirection: 'row',
|
|
3391
|
-
justifyContent: 'space-between',
|
|
3392
|
-
marginBottom: 4,
|
|
3393
|
-
gap: 3,
|
|
3394
|
-
}}
|
|
3395
|
-
>
|
|
3396
|
-
<View
|
|
3397
|
-
style={{
|
|
3398
|
-
backgroundColor: isBrightnessLow ? '#f44336' : '#4CAF50',
|
|
3399
|
-
paddingHorizontal: 6,
|
|
3400
|
-
paddingVertical: 1,
|
|
3401
|
-
borderRadius: 3,
|
|
3402
|
-
}}
|
|
3403
|
-
>
|
|
3404
|
-
<TextView
|
|
3405
|
-
style={{
|
|
3406
|
-
color: '#FFFFFF',
|
|
3407
|
-
fontSize: 8,
|
|
3408
|
-
fontWeight: 'bold',
|
|
3409
|
-
}}
|
|
3410
|
-
>
|
|
3411
|
-
{isBrightnessLow ? 'Low Light' : 'Good Light'}
|
|
3412
|
-
</TextView>
|
|
3413
|
-
</View>
|
|
3414
|
-
<View
|
|
3415
|
-
style={{
|
|
3416
|
-
backgroundColor: isFrameBlurry ? '#f44336' : '#4CAF50',
|
|
3417
|
-
paddingHorizontal: 6,
|
|
3418
|
-
paddingVertical: 1,
|
|
3419
|
-
borderRadius: 3,
|
|
3420
|
-
}}
|
|
3421
|
-
>
|
|
3422
|
-
<TextView
|
|
3423
|
-
style={{
|
|
3424
|
-
color: '#FFFFFF',
|
|
3425
|
-
fontSize: 8,
|
|
3426
|
-
fontWeight: 'bold',
|
|
3427
|
-
}}
|
|
3428
|
-
>
|
|
3429
|
-
{isFrameBlurry ? 'Blurry' : 'Sharp'}
|
|
3430
|
-
</TextView>
|
|
3431
|
-
</View>
|
|
3432
|
-
</View>
|
|
3433
|
-
|
|
3434
|
-
{/* Elements Status */}
|
|
3435
|
-
<TextView
|
|
3436
|
-
style={{
|
|
3437
|
-
color:
|
|
3438
|
-
elementsOutsideScanArea.length === 0
|
|
3439
|
-
? '#4CAF50'
|
|
3440
|
-
: '#FFA500',
|
|
3441
|
-
fontSize: 8,
|
|
3442
|
-
marginBottom: 3,
|
|
3443
|
-
}}
|
|
3444
|
-
>
|
|
3445
|
-
{elementsOutsideScanArea.length === 0
|
|
3446
|
-
? 'All elements in frame'
|
|
3447
|
-
: `Outside: ${elementsOutsideScanArea.join(', ')}`}
|
|
3448
|
-
</TextView>
|
|
3449
|
-
|
|
3450
|
-
{/* Detection Info */}
|
|
3451
|
-
<TextView
|
|
3452
|
-
style={{
|
|
3453
|
-
color: 'rgba(255, 255, 255, 0.7)',
|
|
3454
|
-
fontSize: 8,
|
|
3455
|
-
marginBottom: 3,
|
|
3456
|
-
}}
|
|
3457
|
-
>
|
|
3458
|
-
{`Face: ${documentPlaneBounds ? '✓' : '✗'}, MRZ: ${mrzBounds ? '✓' : '✗'}, Sig: ${signatureBounds ? '✓' : '✗'}`}
|
|
3459
|
-
</TextView>
|
|
3460
|
-
|
|
3461
|
-
{/* Hologram Count */}
|
|
3462
|
-
{nextStep === 'SCAN_HOLOGRAM' && hologramImageCount > 0 && (
|
|
3463
|
-
<TextView
|
|
3464
|
-
style={{
|
|
3465
|
-
color: '#9C27B0',
|
|
3466
|
-
fontSize: 8,
|
|
3467
|
-
fontWeight: 'bold',
|
|
3468
|
-
marginBottom: 3,
|
|
3469
|
-
}}
|
|
3470
|
-
>
|
|
3471
|
-
{`Hologram: ${hologramImageCount}/${HOLOGRAM_IMAGE_COUNT}`}
|
|
3472
|
-
</TextView>
|
|
3473
|
-
)}
|
|
3474
|
-
|
|
3475
|
-
{/* Additional Info Row */}
|
|
3476
|
-
<View
|
|
3477
|
-
style={{
|
|
3478
|
-
flexDirection: 'row',
|
|
3479
|
-
gap: 8,
|
|
3480
|
-
paddingTop: 3,
|
|
3481
|
-
borderTopWidth: 1,
|
|
3482
|
-
borderTopColor: 'rgba(255, 255, 255, 0.2)',
|
|
3483
|
-
marginBottom: 4,
|
|
3484
|
-
}}
|
|
3485
|
-
>
|
|
3486
|
-
<TextView
|
|
3487
|
-
style={{
|
|
3488
|
-
color: 'rgba(255, 255, 255, 0.7)',
|
|
3489
|
-
fontSize: 8,
|
|
3490
|
-
marginTop: 3,
|
|
3491
|
-
}}
|
|
3492
|
-
>
|
|
3493
|
-
{`Doc: ${detectedDocumentType}`}
|
|
3494
|
-
</TextView>
|
|
3495
|
-
<TextView
|
|
3496
|
-
style={{
|
|
3497
|
-
color: 'rgba(255, 255, 255, 0.7)',
|
|
3498
|
-
fontSize: 8,
|
|
3499
|
-
marginTop: 3,
|
|
3500
|
-
}}
|
|
3501
|
-
>
|
|
3502
|
-
{`Flash: ${isTorchOn ? '🔦' : '○'}`}
|
|
3503
|
-
</TextView>
|
|
3504
|
-
</View>
|
|
3505
|
-
|
|
3506
|
-
{/* Debug Images Grid - Compact */}
|
|
3507
|
-
<View
|
|
3508
|
-
style={{
|
|
3509
|
-
flexDirection: 'row',
|
|
3510
|
-
flexWrap: 'wrap',
|
|
3511
|
-
gap: 4,
|
|
3512
|
-
justifyContent: 'center',
|
|
3513
|
-
}}
|
|
3514
|
-
>
|
|
3515
|
-
{/* Face Image */}
|
|
3516
|
-
<View style={{ alignItems: 'center' }}>
|
|
3517
|
-
{currentFaceImage ? (
|
|
3518
|
-
<Image
|
|
3519
|
-
source={{
|
|
3520
|
-
uri: `data:image/jpeg;base64,${currentFaceImage}`,
|
|
3521
|
-
}}
|
|
3522
|
-
style={{
|
|
3523
|
-
width: 40,
|
|
3524
|
-
height: 48,
|
|
3525
|
-
borderRadius: 2,
|
|
3526
|
-
borderWidth: 1,
|
|
3527
|
-
borderColor: '#4CAF50',
|
|
3528
|
-
}}
|
|
3529
|
-
/>
|
|
3530
|
-
) : (
|
|
3531
|
-
<View
|
|
3532
|
-
style={{
|
|
3533
|
-
width: 40,
|
|
3534
|
-
height: 48,
|
|
3535
|
-
borderRadius: 2,
|
|
3536
|
-
borderWidth: 1,
|
|
3537
|
-
borderColor: '#666',
|
|
3538
|
-
backgroundColor: '#222',
|
|
3539
|
-
justifyContent: 'center',
|
|
3540
|
-
alignItems: 'center',
|
|
3541
|
-
}}
|
|
3542
|
-
>
|
|
3543
|
-
<TextView
|
|
3544
|
-
style={{
|
|
3545
|
-
color: '#666',
|
|
3546
|
-
fontSize: 7,
|
|
3547
|
-
}}
|
|
3548
|
-
>
|
|
3549
|
-
—
|
|
3550
|
-
</TextView>
|
|
3551
|
-
</View>
|
|
3552
|
-
)}
|
|
3553
|
-
<TextView
|
|
3554
|
-
style={{
|
|
3555
|
-
color: currentFaceImage ? '#4CAF50' : '#999',
|
|
3556
|
-
fontSize: 7,
|
|
3557
|
-
marginTop: 1,
|
|
3558
|
-
fontWeight: 'bold',
|
|
3559
|
-
}}
|
|
3560
|
-
>
|
|
3561
|
-
{`${currentFaceImage ? '✓' : '○'} Face`}
|
|
3562
|
-
</TextView>
|
|
3563
|
-
</View>
|
|
3564
|
-
|
|
3565
|
-
{/* Secondary Face Image */}
|
|
3566
|
-
<View style={{ alignItems: 'center' }}>
|
|
3567
|
-
{currentSecondaryFaceImage ? (
|
|
3568
|
-
<Image
|
|
3569
|
-
source={{
|
|
3570
|
-
uri: `data:image/jpeg;base64,${currentSecondaryFaceImage}`,
|
|
3571
|
-
}}
|
|
3572
|
-
style={{
|
|
3573
|
-
width: 40,
|
|
3574
|
-
height: 48,
|
|
3575
|
-
borderRadius: 2,
|
|
3576
|
-
borderWidth: 1,
|
|
3577
|
-
borderColor: '#2196F3',
|
|
3578
|
-
}}
|
|
3579
|
-
/>
|
|
3580
|
-
) : (
|
|
3581
|
-
<View
|
|
3582
|
-
style={{
|
|
3583
|
-
width: 40,
|
|
3584
|
-
height: 48,
|
|
3585
|
-
borderRadius: 2,
|
|
3586
|
-
borderWidth: 1,
|
|
3587
|
-
borderColor: '#666',
|
|
3588
|
-
backgroundColor: '#222',
|
|
3589
|
-
justifyContent: 'center',
|
|
3590
|
-
alignItems: 'center',
|
|
3591
|
-
}}
|
|
3592
|
-
>
|
|
3593
|
-
<TextView
|
|
3594
|
-
style={{
|
|
3595
|
-
color: '#666',
|
|
3596
|
-
fontSize: 7,
|
|
3597
|
-
}}
|
|
3598
|
-
>
|
|
3599
|
-
—
|
|
3600
|
-
</TextView>
|
|
3601
|
-
</View>
|
|
3602
|
-
)}
|
|
3603
|
-
<TextView
|
|
3604
|
-
style={{
|
|
3605
|
-
color: currentSecondaryFaceImage ? '#2196F3' : '#999',
|
|
3606
|
-
fontSize: 7,
|
|
3607
|
-
marginTop: 1,
|
|
3608
|
-
fontWeight: 'bold',
|
|
3609
|
-
}}
|
|
3610
|
-
>
|
|
3611
|
-
{`${currentSecondaryFaceImage ? '✓' : '○'} 2nd`}
|
|
3612
|
-
</TextView>
|
|
3613
|
-
</View>
|
|
3614
|
-
|
|
3615
|
-
{/* Hologram Image */}
|
|
3616
|
-
<View style={{ alignItems: 'center' }}>
|
|
3617
|
-
{currentHologramImage ? (
|
|
3618
|
-
<Image
|
|
3619
|
-
source={{
|
|
3620
|
-
uri: `data:image/jpeg;base64,${currentHologramImage}`,
|
|
3621
|
-
}}
|
|
3622
|
-
style={{
|
|
3623
|
-
width: 40,
|
|
3624
|
-
height: 48,
|
|
3625
|
-
borderRadius: 2,
|
|
3626
|
-
borderWidth: 1,
|
|
3627
|
-
borderColor: '#9C27B0',
|
|
3628
|
-
}}
|
|
3629
|
-
/>
|
|
3630
|
-
) : latestHologramFaceImage && hologramImageCount > 0 ? (
|
|
3631
|
-
<View style={{ position: 'relative' }}>
|
|
3632
|
-
<Image
|
|
3633
|
-
source={{
|
|
3634
|
-
uri: `data:image/jpeg;base64,${latestHologramFaceImage}`,
|
|
3635
|
-
}}
|
|
3636
|
-
style={{
|
|
3637
|
-
width: 40,
|
|
3638
|
-
height: 48,
|
|
3639
|
-
borderRadius: 2,
|
|
3640
|
-
borderWidth: 1,
|
|
3641
|
-
borderColor: '#FFA500',
|
|
3642
|
-
opacity: 0.7,
|
|
3643
|
-
}}
|
|
3644
|
-
/>
|
|
3645
|
-
<View
|
|
3646
|
-
style={{
|
|
3647
|
-
position: 'absolute',
|
|
3648
|
-
bottom: 1,
|
|
3649
|
-
left: 1,
|
|
3650
|
-
right: 1,
|
|
3651
|
-
backgroundColor: 'rgba(0,0,0,0.8)',
|
|
3652
|
-
paddingVertical: 0,
|
|
3653
|
-
borderRadius: 1,
|
|
3654
|
-
}}
|
|
3655
|
-
>
|
|
3656
|
-
<TextView
|
|
3657
|
-
style={{
|
|
3658
|
-
color: '#FFA500',
|
|
3659
|
-
fontSize: 6,
|
|
3660
|
-
textAlign: 'center',
|
|
3661
|
-
fontWeight: 'bold',
|
|
3662
|
-
}}
|
|
3663
|
-
>
|
|
3664
|
-
{hologramImageCount}/{HOLOGRAM_IMAGE_COUNT}
|
|
3665
|
-
</TextView>
|
|
3666
|
-
</View>
|
|
3667
|
-
</View>
|
|
3668
|
-
) : (
|
|
3669
|
-
<View
|
|
3670
|
-
style={{
|
|
3671
|
-
width: 40,
|
|
3672
|
-
height: 48,
|
|
3673
|
-
borderRadius: 2,
|
|
3674
|
-
borderWidth: 1,
|
|
3675
|
-
borderColor: '#666',
|
|
3676
|
-
backgroundColor: '#222',
|
|
3677
|
-
justifyContent: 'center',
|
|
3678
|
-
alignItems: 'center',
|
|
3679
|
-
}}
|
|
3680
|
-
>
|
|
3681
|
-
<TextView
|
|
3682
|
-
style={{
|
|
3683
|
-
color: '#666',
|
|
3684
|
-
fontSize: 7,
|
|
3685
|
-
}}
|
|
3686
|
-
>
|
|
3687
|
-
—
|
|
3688
|
-
</TextView>
|
|
3689
|
-
</View>
|
|
3690
|
-
)}
|
|
3691
|
-
<TextView
|
|
3692
|
-
style={{
|
|
3693
|
-
color: currentHologramImage
|
|
3694
|
-
? '#9C27B0'
|
|
3695
|
-
: latestHologramFaceImage
|
|
3696
|
-
? '#FFA500'
|
|
3697
|
-
: '#999',
|
|
3698
|
-
fontSize: 7,
|
|
3699
|
-
marginTop: 1,
|
|
3700
|
-
fontWeight: 'bold',
|
|
3701
|
-
}}
|
|
3702
|
-
>
|
|
3703
|
-
{`${currentHologramImage ? '✓' : latestHologramFaceImage ? '⏳' : '○'} Holo`}
|
|
3704
|
-
</TextView>
|
|
3705
|
-
</View>
|
|
3706
|
-
|
|
3707
|
-
{/* Hologram Mask Image */}
|
|
3708
|
-
<View style={{ alignItems: 'center' }}>
|
|
3709
|
-
{_currentHologramMaskImage ? (
|
|
3710
|
-
<Image
|
|
3711
|
-
source={{
|
|
3712
|
-
uri: `data:image/jpeg;base64,${_currentHologramMaskImage}`,
|
|
3713
|
-
}}
|
|
3714
|
-
style={{
|
|
3715
|
-
width: 40,
|
|
3716
|
-
height: 48,
|
|
3717
|
-
borderRadius: 2,
|
|
3718
|
-
borderWidth: 1,
|
|
3719
|
-
borderColor: '#FF6B6B',
|
|
3720
|
-
}}
|
|
3721
|
-
/>
|
|
3722
|
-
) : (
|
|
3723
|
-
<View
|
|
3724
|
-
style={{
|
|
3725
|
-
width: 40,
|
|
3726
|
-
height: 48,
|
|
3727
|
-
borderRadius: 2,
|
|
3728
|
-
borderWidth: 1,
|
|
3729
|
-
borderColor: '#666',
|
|
3730
|
-
backgroundColor: '#222',
|
|
3731
|
-
justifyContent: 'center',
|
|
3732
|
-
alignItems: 'center',
|
|
3733
|
-
}}
|
|
3734
|
-
>
|
|
3735
|
-
<TextView
|
|
3736
|
-
style={{
|
|
3737
|
-
color: '#666',
|
|
3738
|
-
fontSize: 7,
|
|
3739
|
-
}}
|
|
3740
|
-
>
|
|
3741
|
-
—
|
|
3742
|
-
</TextView>
|
|
3743
|
-
</View>
|
|
3744
|
-
)}
|
|
3745
|
-
<TextView
|
|
3746
|
-
style={{
|
|
3747
|
-
color: _currentHologramMaskImage ? '#FF6B6B' : '#999',
|
|
3748
|
-
fontSize: 7,
|
|
3749
|
-
marginTop: 1,
|
|
3750
|
-
fontWeight: 'bold',
|
|
3751
|
-
}}
|
|
3752
|
-
>
|
|
3753
|
-
{`${_currentHologramMaskImage ? '✓' : '○'} Mask`}
|
|
3754
|
-
</TextView>
|
|
3755
|
-
</View>
|
|
3756
|
-
</View>
|
|
3757
|
-
</View>
|
|
3758
|
-
</SafeAreaView>
|
|
2432
|
+
<DebugOverlay
|
|
2433
|
+
nextStep={nextStep}
|
|
2434
|
+
status={status}
|
|
2435
|
+
detectedDocumentType={detectedDocumentType}
|
|
2436
|
+
isBrightnessLow={isBrightnessLow}
|
|
2437
|
+
isFrameBlurry={isFrameBlurry}
|
|
2438
|
+
isTorchOn={isTorchOn}
|
|
2439
|
+
documentPlaneBounds={documentPlaneBounds}
|
|
2440
|
+
secondaryFaceBounds={secondaryFaceBounds}
|
|
2441
|
+
barcodeBounds={barcodeBounds}
|
|
2442
|
+
mrzBounds={mrzBounds}
|
|
2443
|
+
signatureBounds={signatureBounds}
|
|
2444
|
+
currentFaceImage={currentFaceImage}
|
|
2445
|
+
currentSecondaryFaceImage={currentSecondaryFaceImage}
|
|
2446
|
+
currentHologramImage={currentHologramImage}
|
|
2447
|
+
currentHologramMaskImage={_currentHologramMaskImage}
|
|
2448
|
+
latestHologramFaceImage={latestHologramFaceImage}
|
|
2449
|
+
hologramImageCount={hologramImageCount}
|
|
2450
|
+
allElementsDetected={allElementsDetected}
|
|
2451
|
+
elementsOutsideScanArea={elementsOutsideScanArea}
|
|
2452
|
+
/>
|
|
3759
2453
|
)}
|
|
3760
2454
|
{testMode && testModeData && (
|
|
3761
|
-
<
|
|
3762
|
-
style={{
|
|
3763
|
-
position: 'absolute',
|
|
3764
|
-
bottom: 0,
|
|
3765
|
-
left: 0,
|
|
3766
|
-
right: 0,
|
|
3767
|
-
maxHeight: '40%',
|
|
3768
|
-
backgroundColor: 'rgba(0, 0, 0, 0.95)',
|
|
3769
|
-
borderTopWidth: 2,
|
|
3770
|
-
borderTopColor: '#FFA500',
|
|
3771
|
-
}}
|
|
3772
|
-
>
|
|
3773
|
-
<ScrollView style={{ flex: 1 }}>
|
|
3774
|
-
<View style={{ padding: 10 }}>
|
|
3775
|
-
<TextView
|
|
3776
|
-
style={{
|
|
3777
|
-
color: '#FFA500',
|
|
3778
|
-
fontSize: 12,
|
|
3779
|
-
fontWeight: 'bold',
|
|
3780
|
-
marginBottom: 8,
|
|
3781
|
-
textAlign: 'center',
|
|
3782
|
-
}}
|
|
3783
|
-
>
|
|
3784
|
-
MRZ Text Read
|
|
3785
|
-
</TextView>
|
|
3786
|
-
|
|
3787
|
-
<TextView
|
|
3788
|
-
style={{
|
|
3789
|
-
color: '#FFFFFF',
|
|
3790
|
-
fontSize: 9,
|
|
3791
|
-
fontFamily: 'monospace',
|
|
3792
|
-
lineHeight: 16,
|
|
3793
|
-
}}
|
|
3794
|
-
>
|
|
3795
|
-
{testModeData.mrzText
|
|
3796
|
-
.split('\n')
|
|
3797
|
-
.map(
|
|
3798
|
-
(line, i) =>
|
|
3799
|
-
`Line ${i + 1}: ${line} (${line.length} chars)`
|
|
3800
|
-
)
|
|
3801
|
-
.join('\n')}
|
|
3802
|
-
</TextView>
|
|
3803
|
-
</View>
|
|
3804
|
-
</ScrollView>
|
|
3805
|
-
</SafeAreaView>
|
|
2455
|
+
<TestModePanel mrzText={testModeData.mrzText} />
|
|
3806
2456
|
)}
|
|
3807
2457
|
</>
|
|
3808
2458
|
)}
|
|
@@ -3811,9 +2461,6 @@ const IdentityDocumentCamera = ({
|
|
|
3811
2461
|
};
|
|
3812
2462
|
|
|
3813
2463
|
const styles = StyleSheet.create({
|
|
3814
|
-
container: {
|
|
3815
|
-
flex: 1,
|
|
3816
|
-
},
|
|
3817
2464
|
permissionContainer: {
|
|
3818
2465
|
flex: 1,
|
|
3819
2466
|
justifyContent: 'center',
|
|
@@ -3910,50 +2557,6 @@ const styles = StyleSheet.create({
|
|
|
3910
2557
|
gap: 10,
|
|
3911
2558
|
justifyContent: 'flex-start',
|
|
3912
2559
|
},
|
|
3913
|
-
debugImagesRow: {
|
|
3914
|
-
display: 'flex',
|
|
3915
|
-
flexDirection: 'row',
|
|
3916
|
-
gap: 10,
|
|
3917
|
-
justifyContent: 'center',
|
|
3918
|
-
flexWrap: 'wrap',
|
|
3919
|
-
},
|
|
3920
|
-
cardDetectionRow: {
|
|
3921
|
-
display: 'flex',
|
|
3922
|
-
flexDirection: 'row',
|
|
3923
|
-
justifyContent: 'center',
|
|
3924
|
-
marginTop: 5,
|
|
3925
|
-
},
|
|
3926
|
-
imageContainer: {
|
|
3927
|
-
display: 'flex',
|
|
3928
|
-
flexDirection: 'column',
|
|
3929
|
-
alignItems: 'center',
|
|
3930
|
-
},
|
|
3931
|
-
imageContainerText: {
|
|
3932
|
-
color: 'white',
|
|
3933
|
-
fontSize: 8,
|
|
3934
|
-
textAlign: 'center',
|
|
3935
|
-
fontWeight: 'bold',
|
|
3936
|
-
marginTop: 2,
|
|
3937
|
-
},
|
|
3938
|
-
faceImage: {
|
|
3939
|
-
width: 60,
|
|
3940
|
-
height: 80,
|
|
3941
|
-
borderRadius: 4,
|
|
3942
|
-
borderWidth: 1,
|
|
3943
|
-
borderColor: 'white',
|
|
3944
|
-
},
|
|
3945
|
-
cardDetectionImage: {
|
|
3946
|
-
width: 160,
|
|
3947
|
-
height: 120,
|
|
3948
|
-
borderRadius: 8,
|
|
3949
|
-
borderWidth: 2,
|
|
3950
|
-
borderColor: '#FF9800',
|
|
3951
|
-
},
|
|
3952
|
-
cardDetectionContainer: {
|
|
3953
|
-
display: 'flex',
|
|
3954
|
-
flexDirection: 'column',
|
|
3955
|
-
alignItems: 'center',
|
|
3956
|
-
},
|
|
3957
2560
|
guide: {
|
|
3958
2561
|
flex: 1,
|
|
3959
2562
|
display: 'flex',
|