@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,195 +0,0 @@
|
|
|
1
|
-
import type { BarcodeType } from '../types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ML Kit Android barcode format constants
|
|
5
|
-
*/
|
|
6
|
-
export const AndroidBarcodeFormat = {
|
|
7
|
-
UNKNOWN: -1,
|
|
8
|
-
ALL_FORMATS: 0,
|
|
9
|
-
CODE_128: 1,
|
|
10
|
-
CODE_39: 2,
|
|
11
|
-
CODE_93: 4,
|
|
12
|
-
CODABAR: 8,
|
|
13
|
-
DATA_MATRIX: 16,
|
|
14
|
-
EAN_13: 32,
|
|
15
|
-
EAN_8: 64,
|
|
16
|
-
ITF: 128,
|
|
17
|
-
QR_CODE: 256,
|
|
18
|
-
UPC_A: 512,
|
|
19
|
-
UPC_E: 1024,
|
|
20
|
-
PDF417: 2048,
|
|
21
|
-
AZTEC: 4096,
|
|
22
|
-
} as const;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* iOS Vision framework barcode symbology constants
|
|
26
|
-
*/
|
|
27
|
-
export const IOSBarcodeSymbology = {
|
|
28
|
-
aztec: 'VNBarcodeSymbologyAztec',
|
|
29
|
-
code128: 'VNBarcodeSymbologyCode128',
|
|
30
|
-
code39: 'VNBarcodeSymbologyCode39',
|
|
31
|
-
code39Checksum: 'VNBarcodeSymbologyCode39Checksum',
|
|
32
|
-
code39FullASCII: 'VNBarcodeSymbologyCode39FullASCII',
|
|
33
|
-
code39FullASCIIChecksum: 'VNBarcodeSymbologyCode39FullASCIIChecksum',
|
|
34
|
-
code93: 'VNBarcodeSymbologyCode93',
|
|
35
|
-
code93i: 'VNBarcodeSymbologyCode93i',
|
|
36
|
-
dataMatrix: 'VNBarcodeSymbologyDataMatrix',
|
|
37
|
-
ean13: 'VNBarcodeSymbologyEAN13',
|
|
38
|
-
ean8: 'VNBarcodeSymbologyEAN8',
|
|
39
|
-
face: 'VNBarcodeSymbologyFace',
|
|
40
|
-
i2of5: 'VNBarcodeSymbologyI2of5',
|
|
41
|
-
i2of5Checksum: 'VNBarcodeSymbologyI2of5Checksum',
|
|
42
|
-
itf14: 'VNBarcodeSymbologyITF14',
|
|
43
|
-
pdf417: 'VNBarcodeSymbologyPDF417',
|
|
44
|
-
qr: 'VNBarcodeSymbologyQR',
|
|
45
|
-
upce: 'VNBarcodeSymbologyUPCE',
|
|
46
|
-
codabar: 'VNBarcodeSymbologyCodabar',
|
|
47
|
-
} as const;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Convert our BarcodeType to Android ML Kit format
|
|
51
|
-
*/
|
|
52
|
-
export const barcodeTypeToAndroidFormat = (type: BarcodeType): number => {
|
|
53
|
-
switch (type) {
|
|
54
|
-
case 'aztec':
|
|
55
|
-
return AndroidBarcodeFormat.AZTEC;
|
|
56
|
-
case 'codabar':
|
|
57
|
-
return AndroidBarcodeFormat.CODABAR;
|
|
58
|
-
case 'code-128':
|
|
59
|
-
return AndroidBarcodeFormat.CODE_128;
|
|
60
|
-
case 'code-39':
|
|
61
|
-
return AndroidBarcodeFormat.CODE_39;
|
|
62
|
-
case 'code-93':
|
|
63
|
-
return AndroidBarcodeFormat.CODE_93;
|
|
64
|
-
case 'data-matrix':
|
|
65
|
-
return AndroidBarcodeFormat.DATA_MATRIX;
|
|
66
|
-
case 'ean-13':
|
|
67
|
-
return AndroidBarcodeFormat.EAN_13;
|
|
68
|
-
case 'ean-8':
|
|
69
|
-
return AndroidBarcodeFormat.EAN_8;
|
|
70
|
-
case 'itf':
|
|
71
|
-
return AndroidBarcodeFormat.ITF;
|
|
72
|
-
case 'pdf-417':
|
|
73
|
-
return AndroidBarcodeFormat.PDF417;
|
|
74
|
-
case 'qr':
|
|
75
|
-
return AndroidBarcodeFormat.QR_CODE;
|
|
76
|
-
case 'upc-a':
|
|
77
|
-
return AndroidBarcodeFormat.UPC_A;
|
|
78
|
-
case 'upc-e':
|
|
79
|
-
return AndroidBarcodeFormat.UPC_E;
|
|
80
|
-
default:
|
|
81
|
-
return AndroidBarcodeFormat.UNKNOWN;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Convert our BarcodeType to iOS Vision framework symbology
|
|
87
|
-
*/
|
|
88
|
-
export const barcodeTypeToIOSSymbology = (type: BarcodeType): string => {
|
|
89
|
-
switch (type) {
|
|
90
|
-
case 'aztec':
|
|
91
|
-
return IOSBarcodeSymbology.aztec;
|
|
92
|
-
case 'codabar':
|
|
93
|
-
return IOSBarcodeSymbology.codabar;
|
|
94
|
-
case 'code-128':
|
|
95
|
-
return IOSBarcodeSymbology.code128;
|
|
96
|
-
case 'code-39':
|
|
97
|
-
return IOSBarcodeSymbology.code39;
|
|
98
|
-
case 'code-93':
|
|
99
|
-
return IOSBarcodeSymbology.code93;
|
|
100
|
-
case 'data-matrix':
|
|
101
|
-
return IOSBarcodeSymbology.dataMatrix;
|
|
102
|
-
case 'ean-13':
|
|
103
|
-
return IOSBarcodeSymbology.ean13;
|
|
104
|
-
case 'ean-8':
|
|
105
|
-
return IOSBarcodeSymbology.ean8;
|
|
106
|
-
case 'itf':
|
|
107
|
-
return IOSBarcodeSymbology.i2of5;
|
|
108
|
-
case 'pdf-417':
|
|
109
|
-
return IOSBarcodeSymbology.pdf417;
|
|
110
|
-
case 'qr':
|
|
111
|
-
return IOSBarcodeSymbology.qr;
|
|
112
|
-
case 'upc-a':
|
|
113
|
-
return IOSBarcodeSymbology.ean13; // UPC-A is subset of EAN-13
|
|
114
|
-
case 'upc-e':
|
|
115
|
-
return IOSBarcodeSymbology.upce;
|
|
116
|
-
default:
|
|
117
|
-
return IOSBarcodeSymbology.qr; // Default fallback
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Convert Android ML Kit format to our BarcodeType
|
|
123
|
-
*/
|
|
124
|
-
export const androidFormatToBarcodeType = (format: number): BarcodeType => {
|
|
125
|
-
switch (format) {
|
|
126
|
-
case AndroidBarcodeFormat.AZTEC:
|
|
127
|
-
return 'aztec';
|
|
128
|
-
case AndroidBarcodeFormat.CODABAR:
|
|
129
|
-
return 'codabar';
|
|
130
|
-
case AndroidBarcodeFormat.CODE_128:
|
|
131
|
-
return 'code-128';
|
|
132
|
-
case AndroidBarcodeFormat.CODE_39:
|
|
133
|
-
return 'code-39';
|
|
134
|
-
case AndroidBarcodeFormat.CODE_93:
|
|
135
|
-
return 'code-93';
|
|
136
|
-
case AndroidBarcodeFormat.DATA_MATRIX:
|
|
137
|
-
return 'data-matrix';
|
|
138
|
-
case AndroidBarcodeFormat.EAN_13:
|
|
139
|
-
return 'ean-13';
|
|
140
|
-
case AndroidBarcodeFormat.EAN_8:
|
|
141
|
-
return 'ean-8';
|
|
142
|
-
case AndroidBarcodeFormat.ITF:
|
|
143
|
-
return 'itf';
|
|
144
|
-
case AndroidBarcodeFormat.PDF417:
|
|
145
|
-
return 'pdf-417';
|
|
146
|
-
case AndroidBarcodeFormat.QR_CODE:
|
|
147
|
-
return 'qr';
|
|
148
|
-
case AndroidBarcodeFormat.UPC_A:
|
|
149
|
-
return 'upc-a';
|
|
150
|
-
case AndroidBarcodeFormat.UPC_E:
|
|
151
|
-
return 'upc-e';
|
|
152
|
-
default:
|
|
153
|
-
return 'unknown';
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Convert iOS Vision framework symbology to our BarcodeType
|
|
159
|
-
*/
|
|
160
|
-
export const iosSymbologyToBarcodeType = (symbology: string): BarcodeType => {
|
|
161
|
-
switch (symbology) {
|
|
162
|
-
case IOSBarcodeSymbology.aztec:
|
|
163
|
-
return 'aztec';
|
|
164
|
-
case IOSBarcodeSymbology.codabar:
|
|
165
|
-
return 'codabar';
|
|
166
|
-
case IOSBarcodeSymbology.code128:
|
|
167
|
-
return 'code-128';
|
|
168
|
-
case IOSBarcodeSymbology.code39:
|
|
169
|
-
case IOSBarcodeSymbology.code39Checksum:
|
|
170
|
-
case IOSBarcodeSymbology.code39FullASCII:
|
|
171
|
-
case IOSBarcodeSymbology.code39FullASCIIChecksum:
|
|
172
|
-
return 'code-39';
|
|
173
|
-
case IOSBarcodeSymbology.code93:
|
|
174
|
-
case IOSBarcodeSymbology.code93i:
|
|
175
|
-
return 'code-93';
|
|
176
|
-
case IOSBarcodeSymbology.dataMatrix:
|
|
177
|
-
return 'data-matrix';
|
|
178
|
-
case IOSBarcodeSymbology.ean13:
|
|
179
|
-
return 'ean-13';
|
|
180
|
-
case IOSBarcodeSymbology.ean8:
|
|
181
|
-
return 'ean-8';
|
|
182
|
-
case IOSBarcodeSymbology.i2of5:
|
|
183
|
-
case IOSBarcodeSymbology.i2of5Checksum:
|
|
184
|
-
case IOSBarcodeSymbology.itf14:
|
|
185
|
-
return 'itf';
|
|
186
|
-
case IOSBarcodeSymbology.pdf417:
|
|
187
|
-
return 'pdf-417';
|
|
188
|
-
case IOSBarcodeSymbology.qr:
|
|
189
|
-
return 'qr';
|
|
190
|
-
case IOSBarcodeSymbology.upce:
|
|
191
|
-
return 'upc-e';
|
|
192
|
-
default:
|
|
193
|
-
return 'unknown';
|
|
194
|
-
}
|
|
195
|
-
};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import type { Barcode, Point, Rect } from '../types';
|
|
2
|
-
|
|
3
|
-
export interface FrameDimensions {
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface ScreenDimensions {
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Convert frame coordinates to screen coordinates
|
|
15
|
-
*/
|
|
16
|
-
export const convertFrameToScreen = (
|
|
17
|
-
point: Point,
|
|
18
|
-
frameDimensions: FrameDimensions,
|
|
19
|
-
screenDimensions: ScreenDimensions
|
|
20
|
-
): Point => {
|
|
21
|
-
const scaleX = screenDimensions.width / frameDimensions.width;
|
|
22
|
-
const scaleY = screenDimensions.height / frameDimensions.height;
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
x: point.x * scaleX,
|
|
26
|
-
y: point.y * scaleY,
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Convert screen coordinates to frame coordinates
|
|
32
|
-
*/
|
|
33
|
-
export const convertScreenToFrame = (
|
|
34
|
-
point: Point,
|
|
35
|
-
frameDimensions: FrameDimensions,
|
|
36
|
-
screenDimensions: ScreenDimensions
|
|
37
|
-
): Point => {
|
|
38
|
-
const scaleX = frameDimensions.width / screenDimensions.width;
|
|
39
|
-
const scaleY = frameDimensions.height / screenDimensions.height;
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
x: point.x * scaleX,
|
|
43
|
-
y: point.y * scaleY,
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Convert barcode corner points to screen coordinates
|
|
49
|
-
*/
|
|
50
|
-
export const convertBarcodeToScreen = (
|
|
51
|
-
barcode: Barcode,
|
|
52
|
-
frameDimensions: FrameDimensions,
|
|
53
|
-
screenDimensions: ScreenDimensions
|
|
54
|
-
): Barcode => {
|
|
55
|
-
const convertedCornerPoints = barcode.cornerPoints?.map((point) =>
|
|
56
|
-
convertFrameToScreen(point, frameDimensions, screenDimensions)
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
const convertedBoundingBox = barcode.boundingBox
|
|
60
|
-
? {
|
|
61
|
-
origin: convertFrameToScreen(
|
|
62
|
-
barcode.boundingBox.origin,
|
|
63
|
-
frameDimensions,
|
|
64
|
-
screenDimensions
|
|
65
|
-
),
|
|
66
|
-
size: {
|
|
67
|
-
width:
|
|
68
|
-
(barcode.boundingBox.size.width * screenDimensions.width) /
|
|
69
|
-
frameDimensions.width,
|
|
70
|
-
height:
|
|
71
|
-
(barcode.boundingBox.size.height * screenDimensions.height) /
|
|
72
|
-
frameDimensions.height,
|
|
73
|
-
},
|
|
74
|
-
}
|
|
75
|
-
: barcode.boundingBox;
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
...barcode,
|
|
79
|
-
cornerPoints: convertedCornerPoints,
|
|
80
|
-
boundingBox: convertedBoundingBox,
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Calculate center point of a rectangle
|
|
86
|
-
*/
|
|
87
|
-
export const getRectCenter = (rect: Rect): Point => {
|
|
88
|
-
return {
|
|
89
|
-
x: rect.x + rect.width / 2,
|
|
90
|
-
y: rect.y + rect.height / 2,
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Calculate center point from corner points
|
|
96
|
-
*/
|
|
97
|
-
export const getCornerPointsCenter = (cornerPoints: Point[]): Point => {
|
|
98
|
-
if (cornerPoints.length === 0) {
|
|
99
|
-
return { x: 0, y: 0 };
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const sum = cornerPoints.reduce(
|
|
103
|
-
(acc, point) => ({
|
|
104
|
-
x: acc.x + point.x,
|
|
105
|
-
y: acc.y + point.y,
|
|
106
|
-
}),
|
|
107
|
-
{ x: 0, y: 0 }
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
x: sum.x / cornerPoints.length,
|
|
112
|
-
y: sum.y / cornerPoints.length,
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Calculate bounding rectangle from corner points
|
|
118
|
-
*/
|
|
119
|
-
export const getBoundsFromCornerPoints = (cornerPoints: Point[]): Rect => {
|
|
120
|
-
if (cornerPoints.length === 0) {
|
|
121
|
-
return { x: 0, y: 0, width: 0, height: 0 };
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const minX = Math.min(...cornerPoints.map((p) => p.x));
|
|
125
|
-
const maxX = Math.max(...cornerPoints.map((p) => p.x));
|
|
126
|
-
const minY = Math.min(...cornerPoints.map((p) => p.y));
|
|
127
|
-
const maxY = Math.max(...cornerPoints.map((p) => p.y));
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
x: minX,
|
|
131
|
-
y: minY,
|
|
132
|
-
width: maxX - minX,
|
|
133
|
-
height: maxY - minY,
|
|
134
|
-
};
|
|
135
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { Barcode, Highlight, BoundingBox, Point } from '../types';
|
|
2
|
-
import {
|
|
3
|
-
convertBarcodeToScreen,
|
|
4
|
-
type FrameDimensions,
|
|
5
|
-
type ScreenDimensions,
|
|
6
|
-
} from './geometry';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Convert a BoundingBox to a Highlight with a key
|
|
10
|
-
*/
|
|
11
|
-
export const boundingBoxToHighlight = (
|
|
12
|
-
boundingBox: BoundingBox,
|
|
13
|
-
key: string | number
|
|
14
|
-
): Highlight => {
|
|
15
|
-
return {
|
|
16
|
-
...boundingBox,
|
|
17
|
-
key,
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Convert barcodes to highlights for rendering
|
|
23
|
-
*/
|
|
24
|
-
export const barcodesToHighlights = (
|
|
25
|
-
barcodes: Barcode[],
|
|
26
|
-
frameDimensions: FrameDimensions,
|
|
27
|
-
screenDimensions: ScreenDimensions
|
|
28
|
-
): Highlight[] => {
|
|
29
|
-
return barcodes.map((barcode, index) => {
|
|
30
|
-
const convertedBarcode = convertBarcodeToScreen(
|
|
31
|
-
barcode,
|
|
32
|
-
frameDimensions,
|
|
33
|
-
screenDimensions
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return boundingBoxToHighlight(
|
|
37
|
-
convertedBarcode.boundingBox,
|
|
38
|
-
barcode.value || `barcode-${index}`
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Get highlight styles for rendering overlay
|
|
45
|
-
*/
|
|
46
|
-
export const getHighlightStyle = (
|
|
47
|
-
highlight: Highlight,
|
|
48
|
-
color: string = '#00FF00',
|
|
49
|
-
borderWidth: number = 2
|
|
50
|
-
) => {
|
|
51
|
-
return {
|
|
52
|
-
position: 'absolute' as const,
|
|
53
|
-
left: highlight.origin.x,
|
|
54
|
-
top: highlight.origin.y,
|
|
55
|
-
width: highlight.size.width,
|
|
56
|
-
height: highlight.size.height,
|
|
57
|
-
borderColor: color,
|
|
58
|
-
borderWidth,
|
|
59
|
-
backgroundColor: 'transparent',
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Create polygon path from corner points for more precise highlighting
|
|
65
|
-
*/
|
|
66
|
-
export const cornerPointsToPath = (cornerPoints: Point[]): string => {
|
|
67
|
-
if (cornerPoints.length === 0) {
|
|
68
|
-
return '';
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const pathCommands = cornerPoints.map((point, index) => {
|
|
72
|
-
const command = index === 0 ? 'M' : 'L';
|
|
73
|
-
return `${command} ${point.x} ${point.y}`;
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return `${pathCommands.join(' ')} Z`;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Get SVG polygon points string from corner points
|
|
81
|
-
*/
|
|
82
|
-
export const cornerPointsToPolygonPoints = (cornerPoints: Point[]): string => {
|
|
83
|
-
return cornerPoints.map((point) => `${point.x},${point.y}`).join(' ');
|
|
84
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { VisionCameraProxy, type Frame } from 'react-native-vision-camera';
|
|
2
|
-
|
|
3
|
-
const LINKING_ERROR = `Can't load plugin crop. Try cleaning cache or reinstall plugin.`;
|
|
4
|
-
|
|
5
|
-
export function createCropperPlugin(): CropperPlugin {
|
|
6
|
-
const plugin = VisionCameraProxy.initFrameProcessorPlugin('crop', {});
|
|
7
|
-
|
|
8
|
-
if (!plugin) {
|
|
9
|
-
throw new Error(LINKING_ERROR);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
crop: (frame: Frame, config?: CropConfig): CropResult => {
|
|
14
|
-
'worklet';
|
|
15
|
-
|
|
16
|
-
if (config) {
|
|
17
|
-
const record: Record<string, any> = {};
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
config.includeImageBase64 !== undefined &&
|
|
21
|
-
config.includeImageBase64 !== null
|
|
22
|
-
) {
|
|
23
|
-
record.includeImageBase64 = config.includeImageBase64;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (config.saveAsFile !== undefined && config.saveAsFile !== null) {
|
|
27
|
-
record.saveAsFile = config.saveAsFile;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (config.saveBitmap !== undefined && config.saveBitmap !== null) {
|
|
31
|
-
record.saveBitmap = config.saveBitmap;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (config.cropRegion) {
|
|
35
|
-
const cropRegionRecord: Record<string, any> = {};
|
|
36
|
-
cropRegionRecord.left = config.cropRegion.left;
|
|
37
|
-
cropRegionRecord.top = config.cropRegion.top;
|
|
38
|
-
cropRegionRecord.width = config.cropRegion.width;
|
|
39
|
-
cropRegionRecord.height = config.cropRegion.height;
|
|
40
|
-
record.cropRegion = cropRegionRecord;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return plugin.call(frame, record) as CropResult;
|
|
44
|
-
} else {
|
|
45
|
-
return plugin.call(frame) as CropResult;
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Create default plugin instance and export crop function
|
|
52
|
-
const defaultPlugin = createCropperPlugin();
|
|
53
|
-
export const crop = defaultPlugin.crop;
|
|
54
|
-
|
|
55
|
-
// Types
|
|
56
|
-
export interface CropperPlugin {
|
|
57
|
-
crop: (frame: Frame, config?: CropConfig) => CropResult;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// The value is in percentage
|
|
61
|
-
export interface CropRegion {
|
|
62
|
-
left: number;
|
|
63
|
-
top: number;
|
|
64
|
-
width: number;
|
|
65
|
-
height: number;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface CropConfig {
|
|
69
|
-
cropRegion?: CropRegion;
|
|
70
|
-
includeImageBase64?: boolean;
|
|
71
|
-
saveBitmap?: boolean;
|
|
72
|
-
saveAsFile?: boolean;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface CropResult {
|
|
76
|
-
base64?: string;
|
|
77
|
-
path?: string;
|
|
78
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, type ForwardedRef, useMemo } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Camera as VisionCamera,
|
|
4
|
-
useFrameProcessor,
|
|
5
|
-
} from 'react-native-vision-camera';
|
|
6
|
-
import { createFaceDetectorPlugin } from './detectFaces';
|
|
7
|
-
import { useRunOnJS } from 'react-native-worklets-core';
|
|
8
|
-
import type {
|
|
9
|
-
CameraTypes,
|
|
10
|
-
Face,
|
|
11
|
-
Frame,
|
|
12
|
-
ReadonlyFrameProcessor,
|
|
13
|
-
FaceDetectorPlugin,
|
|
14
|
-
FaceDetectorOptions,
|
|
15
|
-
} from './types';
|
|
16
|
-
|
|
17
|
-
export const Camera = forwardRef(function Camera(
|
|
18
|
-
props: CameraTypes,
|
|
19
|
-
ref: ForwardedRef<any>
|
|
20
|
-
) {
|
|
21
|
-
const { device, callback, options, ...p } = props;
|
|
22
|
-
|
|
23
|
-
const { detectFaces } = useFaceDetector(options);
|
|
24
|
-
|
|
25
|
-
const runOnJS = useRunOnJS(
|
|
26
|
-
(data: Face[]): void => {
|
|
27
|
-
callback(data);
|
|
28
|
-
},
|
|
29
|
-
[options]
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const frameProcessor: ReadonlyFrameProcessor = useFrameProcessor(
|
|
33
|
-
(frame: Frame) => {
|
|
34
|
-
'worklet';
|
|
35
|
-
const faces: Face[] = detectFaces(frame);
|
|
36
|
-
runOnJS(faces);
|
|
37
|
-
},
|
|
38
|
-
[]
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<>
|
|
43
|
-
{!!device && (
|
|
44
|
-
<VisionCamera
|
|
45
|
-
pixelFormat="yuv"
|
|
46
|
-
ref={ref}
|
|
47
|
-
frameProcessor={frameProcessor}
|
|
48
|
-
device={device}
|
|
49
|
-
{...p}
|
|
50
|
-
/>
|
|
51
|
-
)}
|
|
52
|
-
</>
|
|
53
|
-
);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export function useFaceDetector(
|
|
57
|
-
options?: FaceDetectorOptions
|
|
58
|
-
): FaceDetectorPlugin {
|
|
59
|
-
return useMemo(() => {
|
|
60
|
-
const plugin = createFaceDetectorPlugin(options);
|
|
61
|
-
return plugin;
|
|
62
|
-
}, [options]);
|
|
63
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { VisionCameraProxy } from 'react-native-vision-camera';
|
|
2
|
-
import type {
|
|
3
|
-
Frame,
|
|
4
|
-
FaceDetectorPlugin,
|
|
5
|
-
FaceDetectorOptions,
|
|
6
|
-
Face,
|
|
7
|
-
} from './types';
|
|
8
|
-
|
|
9
|
-
const LINKING_ERROR = `Can't load plugin detectFaces. Try cleaning cache or reinstall plugin.`;
|
|
10
|
-
|
|
11
|
-
export function createFaceDetectorPlugin(
|
|
12
|
-
options?: FaceDetectorOptions
|
|
13
|
-
): FaceDetectorPlugin {
|
|
14
|
-
const plugin = VisionCameraProxy.initFrameProcessorPlugin('detectFaces', {
|
|
15
|
-
performanceMode: 'accurate',
|
|
16
|
-
landmarkMode: 'none',
|
|
17
|
-
contourMode: 'none',
|
|
18
|
-
classificationMode: 'none',
|
|
19
|
-
minFaceSize: 0.1,
|
|
20
|
-
trackingEnabled: false,
|
|
21
|
-
autoScale: true,
|
|
22
|
-
windowWidth: 1.0,
|
|
23
|
-
windowHeight: 1.0,
|
|
24
|
-
...options,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
if (!plugin) {
|
|
28
|
-
throw new Error(LINKING_ERROR);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
detectFaces: (frame: Frame): Face[] => {
|
|
33
|
-
'worklet';
|
|
34
|
-
try {
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
const result = plugin.call(frame) as Face[];
|
|
37
|
-
return result || [];
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.warn('detectFaces: Plugin call failed:', error);
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
Frame,
|
|
3
|
-
ReadonlyFrameProcessor,
|
|
4
|
-
FrameProcessorPlugin,
|
|
5
|
-
FrameInternal,
|
|
6
|
-
CameraProps,
|
|
7
|
-
CameraDevice,
|
|
8
|
-
} from 'react-native-vision-camera';
|
|
9
|
-
export type { ForwardedRef } from 'react';
|
|
10
|
-
import type { CameraProps, Frame } from 'react-native-vision-camera';
|
|
11
|
-
|
|
12
|
-
export type FaceDetectorOptions = {
|
|
13
|
-
performanceMode?: 'fast' | 'accurate';
|
|
14
|
-
landmarkMode?: 'none' | 'all';
|
|
15
|
-
contourMode?: 'none' | 'all';
|
|
16
|
-
classificationMode?: 'none' | 'all';
|
|
17
|
-
minFaceSize?: number;
|
|
18
|
-
trackingEnabled?: boolean;
|
|
19
|
-
autoScale?: boolean;
|
|
20
|
-
windowWidth?: number;
|
|
21
|
-
windowHeight?: number;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type CameraTypes = {
|
|
25
|
-
callback: (data: Face[]) => void;
|
|
26
|
-
mode: 'detectFaces';
|
|
27
|
-
options?: FaceDetectorOptions;
|
|
28
|
-
} & CameraProps;
|
|
29
|
-
|
|
30
|
-
export type FaceDetectorPlugin = {
|
|
31
|
-
detectFaces: (frame: Frame) => Face[];
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type Face = {
|
|
35
|
-
bounds: Bounds;
|
|
36
|
-
landmarks?: FaceLandmarks;
|
|
37
|
-
contours?: FaceContours;
|
|
38
|
-
trackingId?: number;
|
|
39
|
-
leftEyeOpenProbability?: number;
|
|
40
|
-
rightEyeOpenProbability?: number;
|
|
41
|
-
smilingProbability?: number;
|
|
42
|
-
headEulerAngleX?: number;
|
|
43
|
-
headEulerAngleY?: number;
|
|
44
|
-
headEulerAngleZ?: number;
|
|
45
|
-
// Aliases for backwards compatibility with external library API
|
|
46
|
-
pitchAngle?: number;
|
|
47
|
-
yawAngle?: number;
|
|
48
|
-
rollAngle?: number;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export type Bounds = {
|
|
52
|
-
x: number;
|
|
53
|
-
y: number;
|
|
54
|
-
width: number;
|
|
55
|
-
height: number;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export type Point = {
|
|
59
|
-
x: number;
|
|
60
|
-
y: number;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export type FaceLandmarks = {
|
|
64
|
-
leftEye?: Point;
|
|
65
|
-
rightEye?: Point;
|
|
66
|
-
noseBase?: Point;
|
|
67
|
-
leftCheek?: Point;
|
|
68
|
-
rightCheek?: Point;
|
|
69
|
-
leftEar?: Point;
|
|
70
|
-
rightEar?: Point;
|
|
71
|
-
leftMouth?: Point;
|
|
72
|
-
rightMouth?: Point;
|
|
73
|
-
bottomMouth?: Point;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export type FaceContours = {
|
|
77
|
-
face?: Point[];
|
|
78
|
-
leftEyebrow?: Point[];
|
|
79
|
-
rightEyebrow?: Point[];
|
|
80
|
-
leftEye?: Point[];
|
|
81
|
-
rightEye?: Point[];
|
|
82
|
-
upperLipTop?: Point[];
|
|
83
|
-
upperLipBottom?: Point[];
|
|
84
|
-
lowerLipTop?: Point[];
|
|
85
|
-
lowerLipBottom?: Point[];
|
|
86
|
-
noseBridge?: Point[];
|
|
87
|
-
noseBottom?: Point[];
|
|
88
|
-
leftCheek?: Point[];
|
|
89
|
-
rightCheek?: Point[];
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export type PhotoOptions = {
|
|
93
|
-
uri: string;
|
|
94
|
-
orientation?:
|
|
95
|
-
| 'landscapeRight'
|
|
96
|
-
| 'portrait'
|
|
97
|
-
| 'portraitUpsideDown'
|
|
98
|
-
| 'landscapeLeft';
|
|
99
|
-
};
|