@trustchex/react-native-sdk 1.355.1 → 1.357.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/README.md +2 -9
- package/TrustchexSDK.podspec +5 -4
- package/android/build.gradle +6 -4
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKPackage.kt +45 -25
- package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraManager.kt +168 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraView.kt +871 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mlkit/MLKitModule.kt +245 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidationModule.kt +785 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidator.kt +419 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/opencv/OpenCVModule.kt +818 -0
- package/ios/Camera/TrustchexCameraManager.m +37 -0
- package/ios/Camera/TrustchexCameraManager.swift +125 -0
- package/ios/Camera/TrustchexCameraView.swift +1176 -0
- package/ios/MLKit/MLKitModule.m +23 -0
- package/ios/MLKit/MLKitModule.swift +250 -0
- package/ios/MRZValidation.m +39 -0
- package/ios/MRZValidation.swift +802 -0
- package/ios/MRZValidator.swift +466 -0
- package/ios/OpenCV/OpenCVModule.h +4 -0
- package/ios/OpenCV/OpenCVModule.mm +810 -0
- package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +2 -3
- package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +1 -2
- package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +418 -193
- package/lib/module/Screens/Static/OTPVerificationScreen.js +11 -11
- package/lib/module/Screens/Static/QrCodeScanningScreen.js +5 -1
- package/lib/module/Screens/Static/ResultScreen.js +25 -2
- package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +25 -7
- package/lib/module/Shared/Components/DebugNavigationPanel.js +234 -24
- package/lib/module/Shared/Components/EIDScanner.js +99 -9
- package/lib/module/Shared/Components/FaceCamera.js +170 -179
- package/lib/module/Shared/Components/IdentityDocumentCamera.js +2151 -771
- package/lib/module/Shared/Components/QrCodeScannerCamera.js +109 -107
- package/lib/module/Shared/Components/TrustchexCamera.js +122 -0
- package/lib/module/Shared/EIDReader/tlv/tlv.helpers.js +91 -0
- package/lib/module/Shared/EIDReader/tlv/tlv.utils.js +2 -124
- package/lib/module/Shared/EIDReader/tlv/tlvInputStream.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputState.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputStream.js +4 -4
- package/lib/module/Shared/Libs/analytics.utils.js +2 -2
- package/lib/module/Shared/Libs/debug.utils.js +132 -0
- package/lib/module/Shared/Libs/deeplink.utils.js +6 -5
- package/lib/module/Shared/Libs/demo.utils.js +13 -3
- package/lib/module/Shared/Libs/mrz.utils.js +1 -175
- package/lib/module/Shared/Libs/native-device-info.utils.js +12 -6
- package/lib/module/Shared/Libs/tts.utils.js +40 -6
- package/lib/module/Shared/Services/AnalyticsService.js +9 -8
- package/lib/module/Shared/Types/mrzFields.js +1 -0
- package/lib/module/Translation/Resources/en.js +87 -88
- package/lib/module/Translation/Resources/tr.js +84 -85
- package/lib/module/Trustchex.js +9 -2
- package/lib/module/index.js +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/OTPVerificationScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/DebugNavigationPanel.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/EIDScanner.d.ts +2 -2
- package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/FaceCamera.d.ts +18 -4
- package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts +3 -4
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts +2 -1
- package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts +124 -0
- package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts +11 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts +2 -39
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/debug.utils.d.ts +42 -0
- package/lib/typescript/src/Shared/Libs/debug.utils.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/demo.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/http-client.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts +0 -4
- package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/native-device-info.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/tts.utils.d.ts +4 -3
- package/lib/typescript/src/Shared/Libs/tts.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Types/identificationInfo.d.ts +2 -2
- package/lib/typescript/src/Shared/Types/identificationInfo.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Types/mrzFields.d.ts +11 -0
- package/lib/typescript/src/Shared/Types/mrzFields.d.ts.map +1 -0
- package/lib/typescript/src/Translation/Resources/en.d.ts +4 -5
- package/lib/typescript/src/Translation/Resources/en.d.ts.map +1 -1
- package/lib/typescript/src/Translation/Resources/tr.d.ts +4 -5
- package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
- package/lib/typescript/src/Trustchex.d.ts +2 -0
- package/lib/typescript/src/Trustchex.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +4 -35
- package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +1 -1
- package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +7 -5
- package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +2 -3
- package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +498 -216
- package/src/Screens/Static/OTPVerificationScreen.tsx +37 -31
- package/src/Screens/Static/QrCodeScanningScreen.tsx +8 -1
- package/src/Screens/Static/ResultScreen.tsx +136 -88
- package/src/Screens/Static/VerificationSessionCheckScreen.tsx +46 -13
- package/src/Shared/Components/DebugNavigationPanel.tsx +290 -34
- package/src/Shared/Components/EIDScanner.tsx +94 -16
- package/src/Shared/Components/FaceCamera.tsx +236 -203
- package/src/Shared/Components/IdentityDocumentCamera.tsx +3073 -1030
- package/src/Shared/Components/QrCodeScannerCamera.tsx +133 -127
- package/src/Shared/Components/TrustchexCamera.tsx +289 -0
- package/src/Shared/Config/camera-enhancement.config.ts +2 -2
- package/src/Shared/EIDReader/tlv/tlv.helpers.ts +96 -0
- package/src/Shared/EIDReader/tlv/tlv.utils.ts +2 -125
- package/src/Shared/EIDReader/tlv/tlvInputStream.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputState.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputStream.ts +4 -4
- package/src/Shared/Libs/analytics.utils.ts +48 -20
- package/src/Shared/Libs/debug.utils.ts +149 -0
- package/src/Shared/Libs/deeplink.utils.ts +7 -5
- package/src/Shared/Libs/demo.utils.ts +4 -0
- package/src/Shared/Libs/http-client.ts +12 -8
- package/src/Shared/Libs/mrz.utils.ts +1 -163
- package/src/Shared/Libs/native-device-info.utils.ts +12 -6
- package/src/Shared/Libs/tts.utils.ts +48 -6
- package/src/Shared/Services/AnalyticsService.ts +69 -24
- package/src/Shared/Types/identificationInfo.ts +2 -2
- package/src/Shared/Types/mrzFields.ts +29 -0
- package/src/Translation/Resources/en.ts +90 -100
- package/src/Translation/Resources/tr.ts +89 -97
- package/src/Translation/index.ts +1 -1
- package/src/Trustchex.tsx +21 -4
- package/src/index.tsx +14 -0
- package/src/version.ts +1 -1
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/barcodescanner/BarcodeScannerFrameProcessorPlugin.kt +0 -301
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/BitmapUtils.kt +0 -205
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/CropperPlugin.kt +0 -72
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/FrameMetadata.kt +0 -4
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/facedetector/FaceDetectorFrameProcessorPlugin.kt +0 -303
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/textrecognition/TextRecognitionFrameProcessorPlugin.kt +0 -115
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin-Bridging-Header.h +0 -9
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.mm +0 -22
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.swift +0 -188
- package/ios/VisionCameraPlugins/Cropper/Cropper-Bridging-Header.h +0 -13
- package/ios/VisionCameraPlugins/Cropper/Cropper.h +0 -20
- package/ios/VisionCameraPlugins/Cropper/Cropper.mm +0 -22
- package/ios/VisionCameraPlugins/Cropper/Cropper.swift +0 -145
- package/ios/VisionCameraPlugins/Cropper/CropperUtils.swift +0 -49
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin-Bridging-Header.h +0 -4
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.mm +0 -22
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.swift +0 -320
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin-Bridging-Header.h +0 -4
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.mm +0 -27
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.swift +0 -144
- package/lib/module/Shared/Libs/camera.utils.js +0 -308
- package/lib/module/Shared/Libs/frame-enhancement.utils.js +0 -133
- package/lib/module/Shared/Libs/opencv.utils.js +0 -21
- package/lib/module/Shared/Libs/worklet.utils.js +0 -68
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.js +0 -46
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.js +0 -35
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/index.js +0 -19
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.js +0 -26
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/types.js +0 -3
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.js +0 -197
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.js +0 -101
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.js +0 -60
- package/lib/module/Shared/VisionCameraPlugins/Cropper/index.js +0 -47
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/Camera.js +0 -42
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/detectFaces.js +0 -35
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/index.js +0 -4
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/types.js +0 -3
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/Camera.js +0 -56
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.js +0 -20
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.js +0 -9
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/index.js +0 -6
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/scanText.js +0 -20
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/translateText.js +0 -19
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/types.js +0 -3
- package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +0 -87
- package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts +0 -25
- package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts +0 -3
- package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts +0 -9
- package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts +0 -13
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts +0 -6
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts +0 -12
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts +0 -52
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts +0 -62
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts +0 -34
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts +0 -32
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts +0 -23
- package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts +0 -9
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts +0 -79
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts +0 -6
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts +0 -5
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts +0 -67
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts.map +0 -1
- package/src/Shared/Libs/camera.utils.ts +0 -345
- package/src/Shared/Libs/frame-enhancement.utils.ts +0 -217
- package/src/Shared/Libs/opencv.utils.ts +0 -40
- package/src/Shared/Libs/worklet.utils.ts +0 -72
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.ts +0 -79
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.ts +0 -46
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts +0 -60
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts +0 -32
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/types.ts +0 -82
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.ts +0 -195
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.ts +0 -135
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.ts +0 -84
- package/src/Shared/VisionCameraPlugins/Cropper/index.ts +0 -78
- package/src/Shared/VisionCameraPlugins/FaceDetector/Camera.tsx +0 -63
- package/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.ts +0 -44
- package/src/Shared/VisionCameraPlugins/FaceDetector/index.ts +0 -3
- package/src/Shared/VisionCameraPlugins/FaceDetector/types.ts +0 -99
- package/src/Shared/VisionCameraPlugins/TextRecognition/Camera.tsx +0 -76
- package/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.ts +0 -18
- package/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.ts +0 -7
- package/src/Shared/VisionCameraPlugins/TextRecognition/index.ts +0 -7
- package/src/Shared/VisionCameraPlugins/TextRecognition/scanText.ts +0 -27
- package/src/Shared/VisionCameraPlugins/TextRecognition/translateText.ts +0 -21
- package/src/Shared/VisionCameraPlugins/TextRecognition/types.ts +0 -141
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/FaceDetector/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,KAAK,EACL,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,YAAY,GACb,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,W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C,EAAE,KAAK,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EACR,gBAAgB,GAChB,UAAU,GACV,oBAAoB,GACpB,eAAe,CAAC;CACrB,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { CameraTypes, TextRecognitionPlugin, TranslatorPlugin, TextRecognitionOptions, TranslatorOptions } from './types';
|
|
3
|
-
export declare const Camera: React.ForwardRefExoticComponent<CameraTypes & React.RefAttributes<any>>;
|
|
4
|
-
export declare function useTextRecognition(options?: TextRecognitionOptions): TextRecognitionPlugin;
|
|
5
|
-
export declare function useTranslate(options?: TranslatorOptions): TranslatorPlugin;
|
|
6
|
-
//# sourceMappingURL=Camera.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Camera.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/Camera.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAOtE,OAAO,KAAK,EACV,WAAW,EAIX,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,MAAM,yEA8CjB,CAAC;AAEH,wBAAgB,kBAAkB,CAChC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,qBAAqB,CAEvB;AAED,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,gBAAgB,CAE1E"}
|
package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PhotoRecognizer.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAElD,wBAAsB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAc1E"}
|
package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RemoveLanguageModel.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAG3E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scanText.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/scanText.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,qBAAqB,EACrB,sBAAsB,EAEvB,MAAM,SAAS,CAAC;AAIjB,wBAAgB,2BAA2B,CACzC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,qBAAqB,CAcvB"}
|
package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"translateText.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/translateText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAK1E,wBAAgB,sBAAsB,CACpC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,gBAAgB,CAalB"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export type { Frame, ReadonlyFrameProcessor, FrameProcessorPlugin, FrameInternal, CameraProps, CameraDevice, } from 'react-native-vision-camera';
|
|
2
|
-
export type { ForwardedRef } from 'react';
|
|
3
|
-
import type { CameraProps, Frame } from 'react-native-vision-camera';
|
|
4
|
-
export type Languages = 'af' | 'sq' | 'ar' | 'be' | 'bn' | 'bg' | 'ca' | 'zh' | 'cs' | 'da' | 'nl' | 'en' | 'eo' | 'et' | 'fi' | 'fr' | 'gl' | 'ka' | 'de' | 'el' | 'gu' | 'ht' | 'he' | 'hi' | 'hu' | 'is' | 'id' | 'ga' | 'it' | 'ja' | 'kn' | 'ko' | 'lv' | 'lt' | 'mk' | 'ms' | 'mt' | 'mr' | 'no' | 'fa' | 'pl' | 'pt' | 'ro' | 'ru' | 'sk' | 'sl' | 'es' | 'sw' | 'tl' | 'ta' | 'te' | 'th' | 'tr' | 'uk' | 'ur' | 'vi' | 'cy';
|
|
5
|
-
export type TextRecognitionOptions = {
|
|
6
|
-
language: 'latin' | 'chinese' | 'devanagari' | 'japanese' | 'korean';
|
|
7
|
-
};
|
|
8
|
-
export type TranslatorOptions = {
|
|
9
|
-
from: Languages;
|
|
10
|
-
to: Languages;
|
|
11
|
-
};
|
|
12
|
-
export type CameraTypes = {
|
|
13
|
-
callback: (data: string | Text[]) => void;
|
|
14
|
-
mode: 'translate' | 'recognize';
|
|
15
|
-
} & CameraProps & ({
|
|
16
|
-
mode: 'recognize';
|
|
17
|
-
options: TextRecognitionOptions;
|
|
18
|
-
} | {
|
|
19
|
-
mode: 'translate';
|
|
20
|
-
options: TranslatorOptions;
|
|
21
|
-
});
|
|
22
|
-
export type TextRecognitionPlugin = {
|
|
23
|
-
scanText: (frame: Frame) => Text[];
|
|
24
|
-
};
|
|
25
|
-
export type TranslatorPlugin = {
|
|
26
|
-
translate: (frame: Frame) => string;
|
|
27
|
-
};
|
|
28
|
-
export type Text = {
|
|
29
|
-
blocks: BlocksData;
|
|
30
|
-
resultText: string;
|
|
31
|
-
};
|
|
32
|
-
type BlocksData = [
|
|
33
|
-
blockFrame: FrameType,
|
|
34
|
-
blockCornerPoints: CornerPointsType,
|
|
35
|
-
lines: LinesData,
|
|
36
|
-
blockLanguages: string[] | [],
|
|
37
|
-
blockText: string
|
|
38
|
-
];
|
|
39
|
-
type CornerPointsType = [{
|
|
40
|
-
x: number;
|
|
41
|
-
y: number;
|
|
42
|
-
}];
|
|
43
|
-
type FrameType = {
|
|
44
|
-
boundingCenterX: number;
|
|
45
|
-
boundingCenterY: number;
|
|
46
|
-
height: number;
|
|
47
|
-
width: number;
|
|
48
|
-
x: number;
|
|
49
|
-
y: number;
|
|
50
|
-
};
|
|
51
|
-
type LinesData = [
|
|
52
|
-
lineCornerPoints: CornerPointsType,
|
|
53
|
-
elements: ElementsData,
|
|
54
|
-
lineFrame: FrameType,
|
|
55
|
-
lineLanguages: string[] | [],
|
|
56
|
-
lineText: string
|
|
57
|
-
];
|
|
58
|
-
type ElementsData = [
|
|
59
|
-
elementCornerPoints: CornerPointsType,
|
|
60
|
-
elementFrame: FrameType,
|
|
61
|
-
elementText: string
|
|
62
|
-
];
|
|
63
|
-
export type PhotoOptions = {
|
|
64
|
-
uri: string;
|
|
65
|
-
orientation?: 'landscapeRight' | 'portrait' | 'portraitUpsideDown' | 'landscapeLeft';
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sour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,EAAE,YAAY;IACtB,SAAS,EAAE,SAAS;IACpB,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE;IAC5B,QAAQ,EAAE,MAAM;CACjB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,mBAAmB,EAAE,gBAAgB;IACrC,YAAY,EAAE,SAAS;IACvB,WAAW,EAAE,MAAM;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EACR,gBAAgB,GAChB,UAAU,GACV,oBAAoB,GACpB,eAAe,CAAC;CACrB,CAAC"}
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
import type { Frame } from 'react-native-vision-camera';
|
|
2
|
-
|
|
3
|
-
interface Rect {
|
|
4
|
-
minX: number;
|
|
5
|
-
minY: number;
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Check if frame is blurry using Laplacian variance
|
|
12
|
-
* Uses both horizontal and vertical gradients for more accurate blur detection
|
|
13
|
-
* Lower variance indicates a blurrier image
|
|
14
|
-
* @param frame - The camera frame to analyze
|
|
15
|
-
* @param threshold - Variance threshold below which image is considered blurry (default: 10)
|
|
16
|
-
* @returns true if image is blurry, false otherwise
|
|
17
|
-
*/
|
|
18
|
-
const isBlurry = (frame: Frame, threshold: number = 10): boolean => {
|
|
19
|
-
'worklet';
|
|
20
|
-
const buffer = frame.toArrayBuffer();
|
|
21
|
-
const data = new Uint8Array(buffer);
|
|
22
|
-
const width = frame.width;
|
|
23
|
-
const height = frame.height;
|
|
24
|
-
|
|
25
|
-
let sum = 0;
|
|
26
|
-
let sumSq = 0;
|
|
27
|
-
let count = 0;
|
|
28
|
-
|
|
29
|
-
// Sample central 50% region (matching Flutter algorithm)
|
|
30
|
-
const startY = Math.floor(height / 4);
|
|
31
|
-
const endY = Math.floor((3 * height) / 4) - 1;
|
|
32
|
-
const startX = Math.floor(width / 4);
|
|
33
|
-
const endX = Math.floor((3 * width) / 4) - 1;
|
|
34
|
-
|
|
35
|
-
// Sample at 5-pixel intervals for better accuracy (matching Flutter)
|
|
36
|
-
for (let y = startY; y < endY; y += 5) {
|
|
37
|
-
for (let x = startX; x < endX; x += 5) {
|
|
38
|
-
const idx = y * width + x;
|
|
39
|
-
const idxRight = idx + 1;
|
|
40
|
-
const idxDown = idx + width;
|
|
41
|
-
|
|
42
|
-
// Check bounds for both horizontal and vertical neighbors
|
|
43
|
-
if (idxRight < data.length && idxDown < data.length &&
|
|
44
|
-
data[idx] !== undefined && data[idxRight] !== undefined && data[idxDown] !== undefined) {
|
|
45
|
-
// Horizontal gradient
|
|
46
|
-
const diffH = Math.abs(data[idx] - data[idxRight]);
|
|
47
|
-
// Vertical gradient
|
|
48
|
-
const diffV = Math.abs(data[idx] - data[idxDown]);
|
|
49
|
-
// Combined Laplacian-like measure
|
|
50
|
-
const laplacian = diffH + diffV;
|
|
51
|
-
|
|
52
|
-
sum += laplacian;
|
|
53
|
-
sumSq += laplacian * laplacian;
|
|
54
|
-
count++;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (count === 0) return false;
|
|
60
|
-
|
|
61
|
-
// Calculate variance: E[X²] - E[X]²
|
|
62
|
-
const mean = sum / count;
|
|
63
|
-
const variance = sumSq / count - mean * mean;
|
|
64
|
-
|
|
65
|
-
return variance < threshold;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Get average brightness for entire frame (center area)
|
|
70
|
-
*/
|
|
71
|
-
const getAverageBrightness = (frame: Frame): number => {
|
|
72
|
-
'worklet';
|
|
73
|
-
const buffer = frame.toArrayBuffer();
|
|
74
|
-
const data = new Uint8Array(buffer);
|
|
75
|
-
const width = frame.width;
|
|
76
|
-
const height = frame.height;
|
|
77
|
-
const centerX = Math.floor(width / 2);
|
|
78
|
-
const centerY = Math.floor(height / 2);
|
|
79
|
-
const halfSizeX = Math.floor(width / 2);
|
|
80
|
-
const halfSizeY = Math.floor(height / 2);
|
|
81
|
-
let luminanceSum = 0;
|
|
82
|
-
let pixelCount = 0;
|
|
83
|
-
|
|
84
|
-
for (let y = centerY - halfSizeY; y < centerY + halfSizeY; y++) {
|
|
85
|
-
for (let x = centerX - halfSizeX; x < centerX + halfSizeX; x++) {
|
|
86
|
-
const index = y * width + x;
|
|
87
|
-
if (data[index] !== undefined) {
|
|
88
|
-
luminanceSum += data[index];
|
|
89
|
-
pixelCount++;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return luminanceSum / pixelCount;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get average brightness for a specific circular region (for face detection)
|
|
99
|
-
* Calculates brightness only for pixels inside the circle defined by centerX, centerY, and radius
|
|
100
|
-
*/
|
|
101
|
-
const getCircularRegionBrightness = (
|
|
102
|
-
frame: Frame,
|
|
103
|
-
circleRect: Rect
|
|
104
|
-
): number => {
|
|
105
|
-
'worklet';
|
|
106
|
-
const buffer = frame.toArrayBuffer();
|
|
107
|
-
const data = new Uint8Array(buffer);
|
|
108
|
-
const width = frame.width;
|
|
109
|
-
const height = frame.height;
|
|
110
|
-
|
|
111
|
-
// Calculate circle parameters from rect
|
|
112
|
-
const centerX = Math.floor(circleRect.minX + circleRect.width / 2);
|
|
113
|
-
const centerY = Math.floor(circleRect.minY + circleRect.height / 2);
|
|
114
|
-
const radius = Math.floor(Math.min(circleRect.width, circleRect.height) / 2);
|
|
115
|
-
|
|
116
|
-
let luminanceSum = 0;
|
|
117
|
-
let pixelCount = 0;
|
|
118
|
-
|
|
119
|
-
// Calculate bounding box for the circle to optimize iteration
|
|
120
|
-
const minX = Math.max(0, centerX - radius);
|
|
121
|
-
const maxX = Math.min(width - 1, centerX + radius);
|
|
122
|
-
const minY = Math.max(0, centerY - radius);
|
|
123
|
-
const maxY = Math.min(height - 1, centerY + radius);
|
|
124
|
-
|
|
125
|
-
// Iterate only over pixels in the bounding box
|
|
126
|
-
for (let y = minY; y <= maxY; y++) {
|
|
127
|
-
for (let x = minX; x <= maxX; x++) {
|
|
128
|
-
// Check if pixel is inside the circle
|
|
129
|
-
const dx = x - centerX;
|
|
130
|
-
const dy = y - centerY;
|
|
131
|
-
const distanceSquared = dx * dx + dy * dy;
|
|
132
|
-
|
|
133
|
-
if (distanceSquared <= radius * radius) {
|
|
134
|
-
const index = y * width + x;
|
|
135
|
-
if (data[index] !== undefined) {
|
|
136
|
-
luminanceSum += data[index];
|
|
137
|
-
pixelCount++;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return pixelCount > 0 ? luminanceSum / pixelCount : 0;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const isFrameBright = (frame: Frame): boolean => {
|
|
147
|
-
'worklet';
|
|
148
|
-
return getAverageBrightness(frame) > 60;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Check if a circular region in the frame is bright enough
|
|
153
|
-
*/
|
|
154
|
-
const isCircularRegionBright = (frame: Frame, circleRect: Rect, threshold: number = 60): boolean => {
|
|
155
|
-
'worklet';
|
|
156
|
-
return getCircularRegionBrightness(frame, circleRect) > threshold;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Get average brightness for a specific rectangular region
|
|
161
|
-
*/
|
|
162
|
-
const getRegionBrightness = (frame: Frame, bounds: Rect): number => {
|
|
163
|
-
'worklet';
|
|
164
|
-
const buffer = frame.toArrayBuffer();
|
|
165
|
-
const data = new Uint8Array(buffer);
|
|
166
|
-
const width = frame.width;
|
|
167
|
-
const height = frame.height;
|
|
168
|
-
|
|
169
|
-
const minX = Math.max(0, Math.floor(bounds.minX));
|
|
170
|
-
const maxX = Math.min(width - 1, Math.floor(bounds.minX + bounds.width));
|
|
171
|
-
const minY = Math.max(0, Math.floor(bounds.minY));
|
|
172
|
-
const maxY = Math.min(height - 1, Math.floor(bounds.minY + bounds.height));
|
|
173
|
-
|
|
174
|
-
let luminanceSum = 0;
|
|
175
|
-
let pixelCount = 0;
|
|
176
|
-
|
|
177
|
-
for (let y = minY; y <= maxY; y++) {
|
|
178
|
-
for (let x = minX; x <= maxX; x++) {
|
|
179
|
-
const index = y * width + x;
|
|
180
|
-
if (data[index] !== undefined) {
|
|
181
|
-
luminanceSum += data[index];
|
|
182
|
-
pixelCount++;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return pixelCount > 0 ? luminanceSum / pixelCount : 0;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Calculate adaptive exposure step based on distance from target brightness
|
|
192
|
-
* Uses smooth scaling to prevent abrupt exposure changes that could cause dark frames
|
|
193
|
-
*/
|
|
194
|
-
const calculateExposureStep = (currentBrightness: number, targetBrightness: number): number => {
|
|
195
|
-
'worklet';
|
|
196
|
-
const difference = Math.abs(targetBrightness - currentBrightness);
|
|
197
|
-
// Use smaller steps for smoother transitions: max 2, min 1
|
|
198
|
-
// Use floor + 1 to ensure at least step of 1 and prevent over-correction
|
|
199
|
-
const step = Math.min(2, Math.max(1, Math.floor(difference / 25)));
|
|
200
|
-
return step;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Get the center point of the scan area
|
|
205
|
-
* Scan area is typically 36%-64% of vertical space
|
|
206
|
-
*/
|
|
207
|
-
const getScanAreaCenterPoint = (width: number, height: number): { x: number; y: number } => {
|
|
208
|
-
const scanAreaTop = height * 0.36;
|
|
209
|
-
const scanAreaBottom = height * 0.64;
|
|
210
|
-
const scanAreaCenterY = (scanAreaTop + scanAreaBottom) / 2;
|
|
211
|
-
const scanAreaCenterX = width / 2;
|
|
212
|
-
|
|
213
|
-
return {
|
|
214
|
-
x: scanAreaCenterX,
|
|
215
|
-
y: scanAreaCenterY,
|
|
216
|
-
};
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Document dimensions (in mm) for reference
|
|
221
|
-
*/
|
|
222
|
-
const DOCUMENT_DIMENSIONS = {
|
|
223
|
-
ID_CARD: { width: 85.6, height: 53.98, ratio: 1.586 },
|
|
224
|
-
PASSPORT: { width: 125, height: 88, ratio: 1.42 },
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Detected document information
|
|
229
|
-
*/
|
|
230
|
-
export interface DetectedDocument {
|
|
231
|
-
type: 'ID_CARD' | 'PASSPORT' | 'UNKNOWN';
|
|
232
|
-
size: 'TOO_SMALL' | 'TOO_LARGE' | 'GOOD';
|
|
233
|
-
aspectRatio: number;
|
|
234
|
-
confidence: number; // 0-1, how confident we are in the detection
|
|
235
|
-
framePercentage: number; // How much of frame the document occupies
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Detect document contours and estimate document type based on aspect ratio
|
|
240
|
-
* This is a simplified detection that looks for rectangular contours in the scan area
|
|
241
|
-
* @param frame - The camera frame to analyze
|
|
242
|
-
* @param scanAreaBounds - The bounds of the scan area {x, y, width, height}
|
|
243
|
-
* @returns Detected document info or null if no document detected
|
|
244
|
-
*/
|
|
245
|
-
const detectDocumentInFrame = (
|
|
246
|
-
frame: Frame,
|
|
247
|
-
scanAreaBounds: { x: number; y: number; width: number; height: number }
|
|
248
|
-
): DetectedDocument | null => {
|
|
249
|
-
'worklet';
|
|
250
|
-
|
|
251
|
-
// For now, we'll use a simple edge-based detection
|
|
252
|
-
// In production, this would integrate with OpenCV findContours
|
|
253
|
-
// This is a placeholder that estimates based on brightness patterns
|
|
254
|
-
|
|
255
|
-
const buffer = frame.toArrayBuffer();
|
|
256
|
-
const data = new Uint8Array(buffer);
|
|
257
|
-
const frameWidth = frame.width;
|
|
258
|
-
const frameHeight = frame.height;
|
|
259
|
-
|
|
260
|
-
// Sample edges of scan area to detect document boundaries
|
|
261
|
-
const scanX = Math.floor(scanAreaBounds.x * frameWidth);
|
|
262
|
-
const scanY = Math.floor(scanAreaBounds.y * frameHeight);
|
|
263
|
-
const scanWidth = Math.floor(scanAreaBounds.width * frameWidth);
|
|
264
|
-
const scanHeight = Math.floor(scanAreaBounds.height * frameHeight);
|
|
265
|
-
|
|
266
|
-
// Calculate average brightness in scan area to detect presence of document
|
|
267
|
-
// Documents typically have good contrast against backgrounds
|
|
268
|
-
let totalBrightness = 0;
|
|
269
|
-
let sampleCount = 0;
|
|
270
|
-
const sampleStep = 20; // Sample every 20 pixels for performance
|
|
271
|
-
|
|
272
|
-
// Sample brightness across the scan area
|
|
273
|
-
for (let y = scanY; y < scanY + scanHeight; y += sampleStep) {
|
|
274
|
-
for (let x = scanX; x < scanX + scanWidth; x += sampleStep) {
|
|
275
|
-
const idx = y * frameWidth + x;
|
|
276
|
-
if (idx >= 0 && idx < data.length) {
|
|
277
|
-
totalBrightness += data[idx];
|
|
278
|
-
sampleCount++;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const avgBrightness = sampleCount > 0 ? totalBrightness / sampleCount : 0;
|
|
284
|
-
|
|
285
|
-
// Calculate standard deviation to measure contrast
|
|
286
|
-
let variance = 0;
|
|
287
|
-
for (let y = scanY; y < scanY + scanHeight; y += sampleStep) {
|
|
288
|
-
for (let x = scanX; x < scanX + scanWidth; x += sampleStep) {
|
|
289
|
-
const idx = y * frameWidth + x;
|
|
290
|
-
if (idx >= 0 && idx < data.length) {
|
|
291
|
-
const diff = data[idx] - avgBrightness;
|
|
292
|
-
variance += diff * diff;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
const stdDev = sampleCount > 0 ? Math.sqrt(variance / sampleCount) : 0;
|
|
297
|
-
|
|
298
|
-
// Document is present if there's ANY reasonable content in scan area
|
|
299
|
-
// Lower threshold: stdDev > 10 indicates some content (not blank surface)
|
|
300
|
-
// Brightness between 20-240 covers most lighting conditions
|
|
301
|
-
const documentPresent = stdDev > 10 && avgBrightness > 20 && avgBrightness < 240;
|
|
302
|
-
|
|
303
|
-
if (!documentPresent) {
|
|
304
|
-
return null;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// Default to ID_CARD since scan area matches ID card proportions
|
|
308
|
-
// Passport detection would require actual contour detection
|
|
309
|
-
const type: 'ID_CARD' | 'PASSPORT' | 'UNKNOWN' = 'ID_CARD';
|
|
310
|
-
const confidence = Math.min(1, stdDev / 50);
|
|
311
|
-
|
|
312
|
-
// Calculate how much of frame the document occupies
|
|
313
|
-
const framePercentage = (scanWidth * scanHeight) / (frameWidth * frameHeight);
|
|
314
|
-
const aspectRatio = scanWidth / scanHeight;
|
|
315
|
-
|
|
316
|
-
// Determine size feedback based on contrast level
|
|
317
|
-
// Higher contrast usually means document is closer/larger
|
|
318
|
-
let size: 'TOO_SMALL' | 'TOO_LARGE' | 'GOOD' = 'GOOD';
|
|
319
|
-
if (stdDev < 25) {
|
|
320
|
-
size = 'TOO_SMALL'; // Low contrast - probably far away
|
|
321
|
-
} else if (stdDev > 80) {
|
|
322
|
-
size = 'TOO_LARGE'; // Very high contrast - probably too close
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return {
|
|
326
|
-
type,
|
|
327
|
-
size,
|
|
328
|
-
aspectRatio,
|
|
329
|
-
confidence: Math.min(1, confidence),
|
|
330
|
-
framePercentage,
|
|
331
|
-
};
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
export {
|
|
335
|
-
isBlurry,
|
|
336
|
-
isFrameBright,
|
|
337
|
-
getAverageBrightness,
|
|
338
|
-
getCircularRegionBrightness,
|
|
339
|
-
isCircularRegionBright,
|
|
340
|
-
getRegionBrightness,
|
|
341
|
-
calculateExposureStep,
|
|
342
|
-
getScanAreaCenterPoint,
|
|
343
|
-
detectDocumentInFrame,
|
|
344
|
-
DOCUMENT_DIMENSIONS,
|
|
345
|
-
};
|