@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.
Files changed (254) hide show
  1. package/README.md +2 -9
  2. package/TrustchexSDK.podspec +5 -4
  3. package/android/build.gradle +6 -4
  4. package/android/src/main/AndroidManifest.xml +1 -1
  5. package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKPackage.kt +45 -25
  6. package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraManager.kt +168 -0
  7. package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraView.kt +871 -0
  8. package/android/src/main/java/com/trustchex/reactnativesdk/mlkit/MLKitModule.kt +245 -0
  9. package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidationModule.kt +785 -0
  10. package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidator.kt +419 -0
  11. package/android/src/main/java/com/trustchex/reactnativesdk/opencv/OpenCVModule.kt +818 -0
  12. package/ios/Camera/TrustchexCameraManager.m +37 -0
  13. package/ios/Camera/TrustchexCameraManager.swift +125 -0
  14. package/ios/Camera/TrustchexCameraView.swift +1176 -0
  15. package/ios/MLKit/MLKitModule.m +23 -0
  16. package/ios/MLKit/MLKitModule.swift +250 -0
  17. package/ios/MRZValidation.m +39 -0
  18. package/ios/MRZValidation.swift +802 -0
  19. package/ios/MRZValidator.swift +466 -0
  20. package/ios/OpenCV/OpenCVModule.h +4 -0
  21. package/ios/OpenCV/OpenCVModule.mm +810 -0
  22. package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +2 -3
  23. package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +1 -2
  24. package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +418 -193
  25. package/lib/module/Screens/Static/OTPVerificationScreen.js +11 -11
  26. package/lib/module/Screens/Static/QrCodeScanningScreen.js +5 -1
  27. package/lib/module/Screens/Static/ResultScreen.js +25 -2
  28. package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +25 -7
  29. package/lib/module/Shared/Components/DebugNavigationPanel.js +234 -24
  30. package/lib/module/Shared/Components/EIDScanner.js +99 -9
  31. package/lib/module/Shared/Components/FaceCamera.js +170 -179
  32. package/lib/module/Shared/Components/IdentityDocumentCamera.js +2151 -771
  33. package/lib/module/Shared/Components/QrCodeScannerCamera.js +109 -107
  34. package/lib/module/Shared/Components/TrustchexCamera.js +122 -0
  35. package/lib/module/Shared/EIDReader/tlv/tlv.helpers.js +91 -0
  36. package/lib/module/Shared/EIDReader/tlv/tlv.utils.js +2 -124
  37. package/lib/module/Shared/EIDReader/tlv/tlvInputStream.js +4 -4
  38. package/lib/module/Shared/EIDReader/tlv/tlvOutputState.js +4 -4
  39. package/lib/module/Shared/EIDReader/tlv/tlvOutputStream.js +4 -4
  40. package/lib/module/Shared/Libs/analytics.utils.js +2 -2
  41. package/lib/module/Shared/Libs/debug.utils.js +132 -0
  42. package/lib/module/Shared/Libs/deeplink.utils.js +6 -5
  43. package/lib/module/Shared/Libs/demo.utils.js +13 -3
  44. package/lib/module/Shared/Libs/mrz.utils.js +1 -175
  45. package/lib/module/Shared/Libs/native-device-info.utils.js +12 -6
  46. package/lib/module/Shared/Libs/tts.utils.js +40 -6
  47. package/lib/module/Shared/Services/AnalyticsService.js +9 -8
  48. package/lib/module/Shared/Types/mrzFields.js +1 -0
  49. package/lib/module/Translation/Resources/en.js +87 -88
  50. package/lib/module/Translation/Resources/tr.js +84 -85
  51. package/lib/module/Trustchex.js +9 -2
  52. package/lib/module/index.js +1 -0
  53. package/lib/module/version.js +1 -1
  54. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -1
  55. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -1
  56. package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
  57. package/lib/typescript/src/Screens/Static/OTPVerificationScreen.d.ts.map +1 -1
  58. package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts.map +1 -1
  59. package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
  60. package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -1
  61. package/lib/typescript/src/Shared/Components/DebugNavigationPanel.d.ts.map +1 -1
  62. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts +2 -2
  63. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
  64. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts +18 -4
  65. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
  66. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts +3 -4
  67. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
  68. package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts +2 -1
  69. package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
  70. package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts +124 -0
  71. package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts.map +1 -0
  72. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts +11 -0
  73. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts.map +1 -0
  74. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts +2 -39
  75. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts.map +1 -1
  76. package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts.map +1 -1
  77. package/lib/typescript/src/Shared/Libs/debug.utils.d.ts +42 -0
  78. package/lib/typescript/src/Shared/Libs/debug.utils.d.ts.map +1 -0
  79. package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts.map +1 -1
  80. package/lib/typescript/src/Shared/Libs/demo.utils.d.ts.map +1 -1
  81. package/lib/typescript/src/Shared/Libs/http-client.d.ts.map +1 -1
  82. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts +0 -4
  83. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts.map +1 -1
  84. package/lib/typescript/src/Shared/Libs/native-device-info.utils.d.ts.map +1 -1
  85. package/lib/typescript/src/Shared/Libs/tts.utils.d.ts +4 -3
  86. package/lib/typescript/src/Shared/Libs/tts.utils.d.ts.map +1 -1
  87. package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts.map +1 -1
  88. package/lib/typescript/src/Shared/Types/identificationInfo.d.ts +2 -2
  89. package/lib/typescript/src/Shared/Types/identificationInfo.d.ts.map +1 -1
  90. package/lib/typescript/src/Shared/Types/mrzFields.d.ts +11 -0
  91. package/lib/typescript/src/Shared/Types/mrzFields.d.ts.map +1 -0
  92. package/lib/typescript/src/Translation/Resources/en.d.ts +4 -5
  93. package/lib/typescript/src/Translation/Resources/en.d.ts.map +1 -1
  94. package/lib/typescript/src/Translation/Resources/tr.d.ts +4 -5
  95. package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
  96. package/lib/typescript/src/Trustchex.d.ts +2 -0
  97. package/lib/typescript/src/Trustchex.d.ts.map +1 -1
  98. package/lib/typescript/src/index.d.ts +1 -0
  99. package/lib/typescript/src/index.d.ts.map +1 -1
  100. package/lib/typescript/src/version.d.ts +1 -1
  101. package/package.json +4 -35
  102. package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +1 -1
  103. package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +7 -5
  104. package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +2 -3
  105. package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +498 -216
  106. package/src/Screens/Static/OTPVerificationScreen.tsx +37 -31
  107. package/src/Screens/Static/QrCodeScanningScreen.tsx +8 -1
  108. package/src/Screens/Static/ResultScreen.tsx +136 -88
  109. package/src/Screens/Static/VerificationSessionCheckScreen.tsx +46 -13
  110. package/src/Shared/Components/DebugNavigationPanel.tsx +290 -34
  111. package/src/Shared/Components/EIDScanner.tsx +94 -16
  112. package/src/Shared/Components/FaceCamera.tsx +236 -203
  113. package/src/Shared/Components/IdentityDocumentCamera.tsx +3073 -1030
  114. package/src/Shared/Components/QrCodeScannerCamera.tsx +133 -127
  115. package/src/Shared/Components/TrustchexCamera.tsx +289 -0
  116. package/src/Shared/Config/camera-enhancement.config.ts +2 -2
  117. package/src/Shared/EIDReader/tlv/tlv.helpers.ts +96 -0
  118. package/src/Shared/EIDReader/tlv/tlv.utils.ts +2 -125
  119. package/src/Shared/EIDReader/tlv/tlvInputStream.ts +4 -4
  120. package/src/Shared/EIDReader/tlv/tlvOutputState.ts +4 -4
  121. package/src/Shared/EIDReader/tlv/tlvOutputStream.ts +4 -4
  122. package/src/Shared/Libs/analytics.utils.ts +48 -20
  123. package/src/Shared/Libs/debug.utils.ts +149 -0
  124. package/src/Shared/Libs/deeplink.utils.ts +7 -5
  125. package/src/Shared/Libs/demo.utils.ts +4 -0
  126. package/src/Shared/Libs/http-client.ts +12 -8
  127. package/src/Shared/Libs/mrz.utils.ts +1 -163
  128. package/src/Shared/Libs/native-device-info.utils.ts +12 -6
  129. package/src/Shared/Libs/tts.utils.ts +48 -6
  130. package/src/Shared/Services/AnalyticsService.ts +69 -24
  131. package/src/Shared/Types/identificationInfo.ts +2 -2
  132. package/src/Shared/Types/mrzFields.ts +29 -0
  133. package/src/Translation/Resources/en.ts +90 -100
  134. package/src/Translation/Resources/tr.ts +89 -97
  135. package/src/Translation/index.ts +1 -1
  136. package/src/Trustchex.tsx +21 -4
  137. package/src/index.tsx +14 -0
  138. package/src/version.ts +1 -1
  139. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/barcodescanner/BarcodeScannerFrameProcessorPlugin.kt +0 -301
  140. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/BitmapUtils.kt +0 -205
  141. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/CropperPlugin.kt +0 -72
  142. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/FrameMetadata.kt +0 -4
  143. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/facedetector/FaceDetectorFrameProcessorPlugin.kt +0 -303
  144. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/textrecognition/TextRecognitionFrameProcessorPlugin.kt +0 -115
  145. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin-Bridging-Header.h +0 -9
  146. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.mm +0 -22
  147. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.swift +0 -188
  148. package/ios/VisionCameraPlugins/Cropper/Cropper-Bridging-Header.h +0 -13
  149. package/ios/VisionCameraPlugins/Cropper/Cropper.h +0 -20
  150. package/ios/VisionCameraPlugins/Cropper/Cropper.mm +0 -22
  151. package/ios/VisionCameraPlugins/Cropper/Cropper.swift +0 -145
  152. package/ios/VisionCameraPlugins/Cropper/CropperUtils.swift +0 -49
  153. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin-Bridging-Header.h +0 -4
  154. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.mm +0 -22
  155. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.swift +0 -320
  156. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin-Bridging-Header.h +0 -4
  157. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.mm +0 -27
  158. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.swift +0 -144
  159. package/lib/module/Shared/Libs/camera.utils.js +0 -308
  160. package/lib/module/Shared/Libs/frame-enhancement.utils.js +0 -133
  161. package/lib/module/Shared/Libs/opencv.utils.js +0 -21
  162. package/lib/module/Shared/Libs/worklet.utils.js +0 -68
  163. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.js +0 -46
  164. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.js +0 -35
  165. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/index.js +0 -19
  166. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.js +0 -26
  167. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/types.js +0 -3
  168. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.js +0 -197
  169. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.js +0 -101
  170. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.js +0 -60
  171. package/lib/module/Shared/VisionCameraPlugins/Cropper/index.js +0 -47
  172. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/Camera.js +0 -42
  173. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/detectFaces.js +0 -35
  174. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/index.js +0 -4
  175. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/types.js +0 -3
  176. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/Camera.js +0 -56
  177. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.js +0 -20
  178. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.js +0 -9
  179. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/index.js +0 -6
  180. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/scanText.js +0 -20
  181. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/translateText.js +0 -19
  182. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/types.js +0 -3
  183. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +0 -87
  184. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +0 -1
  185. package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts +0 -25
  186. package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts.map +0 -1
  187. package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts +0 -3
  188. package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts.map +0 -1
  189. package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts +0 -9
  190. package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts.map +0 -1
  191. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts +0 -13
  192. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts.map +0 -1
  193. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts +0 -6
  194. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts.map +0 -1
  195. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts +0 -12
  196. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts.map +0 -1
  197. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts +0 -3
  198. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts.map +0 -1
  199. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts +0 -52
  200. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts.map +0 -1
  201. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts +0 -62
  202. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts.map +0 -1
  203. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts +0 -34
  204. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts.map +0 -1
  205. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts +0 -32
  206. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts.map +0 -1
  207. package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts +0 -23
  208. package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts.map +0 -1
  209. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts +0 -9
  210. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts.map +0 -1
  211. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts +0 -3
  212. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts.map +0 -1
  213. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts +0 -3
  214. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts.map +0 -1
  215. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts +0 -79
  216. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts.map +0 -1
  217. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts +0 -6
  218. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts.map +0 -1
  219. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts +0 -3
  220. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts.map +0 -1
  221. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts +0 -3
  222. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts.map +0 -1
  223. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts +0 -5
  224. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts.map +0 -1
  225. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts +0 -3
  226. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts.map +0 -1
  227. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts +0 -3
  228. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts.map +0 -1
  229. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts +0 -67
  230. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts.map +0 -1
  231. package/src/Shared/Libs/camera.utils.ts +0 -345
  232. package/src/Shared/Libs/frame-enhancement.utils.ts +0 -217
  233. package/src/Shared/Libs/opencv.utils.ts +0 -40
  234. package/src/Shared/Libs/worklet.utils.ts +0 -72
  235. package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.ts +0 -79
  236. package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.ts +0 -46
  237. package/src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts +0 -60
  238. package/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts +0 -32
  239. package/src/Shared/VisionCameraPlugins/BarcodeScanner/types.ts +0 -82
  240. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.ts +0 -195
  241. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.ts +0 -135
  242. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.ts +0 -84
  243. package/src/Shared/VisionCameraPlugins/Cropper/index.ts +0 -78
  244. package/src/Shared/VisionCameraPlugins/FaceDetector/Camera.tsx +0 -63
  245. package/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.ts +0 -44
  246. package/src/Shared/VisionCameraPlugins/FaceDetector/index.ts +0 -3
  247. package/src/Shared/VisionCameraPlugins/FaceDetector/types.ts +0 -99
  248. package/src/Shared/VisionCameraPlugins/TextRecognition/Camera.tsx +0 -76
  249. package/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.ts +0 -18
  250. package/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.ts +0 -7
  251. package/src/Shared/VisionCameraPlugins/TextRecognition/index.ts +0 -7
  252. package/src/Shared/VisionCameraPlugins/TextRecognition/scanText.ts +0 -27
  253. package/src/Shared/VisionCameraPlugins/TextRecognition/translateText.ts +0 -21
  254. package/src/Shared/VisionCameraPlugins/TextRecognition/types.ts +0 -141
@@ -1,303 +0,0 @@
1
- package com.trustchex.reactnativesdk.visioncameraplugins.facedetector
2
-
3
- import android.graphics.Rect
4
- import android.util.Log
5
- import com.google.android.gms.tasks.Tasks
6
- import com.google.mlkit.vision.common.InputImage
7
- import com.google.mlkit.vision.face.*
8
- import com.mrousavy.camera.core.FrameInvalidError
9
- import com.mrousavy.camera.core.types.Orientation
10
- import com.mrousavy.camera.frameprocessors.Frame
11
- import com.mrousavy.camera.frameprocessors.FrameProcessorPlugin
12
-
13
- class FaceDetectorFrameProcessorPlugin(options: Map<String, Any>?) :
14
- FrameProcessorPlugin() {
15
-
16
- // Detection properties
17
- private var autoScale = false
18
- private var faceDetector: FaceDetector? = null
19
- private var runLandmarks = false
20
- private var runClassifications = false
21
- private var runContours = false
22
- private var trackingEnabled = false
23
- private var windowWidth = 1.0
24
- private var windowHeight = 1.0
25
-
26
- init {
27
- // Handle auto scaling and window dimensions
28
- autoScale = options?.get("autoScale").toString() == "true"
29
- windowWidth = (options?.get("windowWidth") ?: 1.0) as Double
30
- windowHeight = (options?.get("windowHeight") ?: 1.0) as Double
31
-
32
- // Initialize faceDetector on creation
33
- var performanceModeValue = FaceDetectorOptions.PERFORMANCE_MODE_FAST
34
- var landmarkModeValue = FaceDetectorOptions.LANDMARK_MODE_NONE
35
- var classificationModeValue = FaceDetectorOptions.CLASSIFICATION_MODE_NONE
36
- var contourModeValue = FaceDetectorOptions.CONTOUR_MODE_NONE
37
-
38
- if (options?.get("performanceMode").toString() == "accurate") {
39
- performanceModeValue = FaceDetectorOptions.PERFORMANCE_MODE_ACCURATE
40
- }
41
-
42
- if (options?.get("landmarkMode").toString() == "all") {
43
- runLandmarks = true
44
- landmarkModeValue = FaceDetectorOptions.LANDMARK_MODE_ALL
45
- }
46
-
47
- if (options?.get("classificationMode").toString() == "all") {
48
- runClassifications = true
49
- classificationModeValue = FaceDetectorOptions.CLASSIFICATION_MODE_ALL
50
- }
51
-
52
- if (options?.get("contourMode").toString() == "all") {
53
- runContours = true
54
- contourModeValue = FaceDetectorOptions.CONTOUR_MODE_ALL
55
- }
56
-
57
- val minFaceSize: Double = (options?.get("minFaceSize") ?: 0.15) as Double
58
- val optionsBuilder = FaceDetectorOptions.Builder()
59
- .setPerformanceMode(performanceModeValue)
60
- .setLandmarkMode(landmarkModeValue)
61
- .setContourMode(contourModeValue)
62
- .setClassificationMode(classificationModeValue)
63
- .setMinFaceSize(minFaceSize.toFloat())
64
-
65
- if (options?.get("trackingEnabled").toString() == "true") {
66
- trackingEnabled = true
67
- optionsBuilder.enableTracking()
68
- }
69
-
70
- faceDetector = FaceDetection.getClient(optionsBuilder.build())
71
- }
72
-
73
- override fun callback(frame: Frame, params: Map<String, Any>?): Any {
74
- val result = ArrayList<Map<String, Any>>()
75
-
76
- try {
77
- val orientation = getOrientation(frame.orientation)
78
- val image = InputImage.fromMediaImage(frame.image, orientation)
79
- // We need to invert sizes as frame is always -90deg rotated
80
- val width = image.height.toDouble()
81
- val height = image.width.toDouble()
82
- val scaleX = if(autoScale) windowWidth / width else 1.0
83
- val scaleY = if(autoScale) windowHeight / height else 1.0
84
-
85
- val task = faceDetector!!.process(image)
86
- val faces = Tasks.await(task)
87
-
88
- Log.d(TAG, "Detected ${faces.size} faces")
89
-
90
- faces.forEach { face ->
91
- val map: MutableMap<String, Any> = HashMap()
92
-
93
- if (runLandmarks) {
94
- map["landmarks"] = processLandmarks(face, scaleX, scaleY)
95
- }
96
-
97
- if (runClassifications) {
98
- map["leftEyeOpenProbability"] = face.leftEyeOpenProbability?.toDouble() ?: -1
99
- map["rightEyeOpenProbability"] = face.rightEyeOpenProbability?.toDouble() ?: -1
100
- map["smilingProbability"] = face.smilingProbability?.toDouble() ?: -1
101
- }
102
-
103
- if (runContours) {
104
- map["contours"] = processFaceContours(face, scaleX, scaleY)
105
- }
106
-
107
- if (trackingEnabled) {
108
- map["trackingId"] = face.trackingId ?: -1
109
- }
110
-
111
- map["rollAngle"] = face.headEulerAngleZ.toDouble()
112
- map["pitchAngle"] = face.headEulerAngleX.toDouble()
113
- map["yawAngle"] = face.headEulerAngleY.toDouble()
114
- map["bounds"] = processBoundingBox(
115
- face.boundingBox,
116
- width,
117
- height,
118
- frame.orientation,
119
- scaleX,
120
- scaleY
121
- )
122
- result.add(map)
123
- }
124
- } catch (e: Exception) {
125
- Log.e(TAG, "Error processing face detection: ", e)
126
- } catch (e: FrameInvalidError) {
127
- Log.e(TAG, "Frame invalid error: ", e)
128
- }
129
-
130
- return result
131
- }
132
-
133
- private fun processBoundingBox(
134
- boundingBox: Rect,
135
- sourceWidth: Double,
136
- sourceHeight: Double,
137
- orientation: Orientation,
138
- scaleX: Double,
139
- scaleY: Double
140
- ): Map<String, Any> {
141
- val bounds: MutableMap<String, Any> = HashMap()
142
- val width = boundingBox.width().toDouble() * scaleX
143
- val height = boundingBox.height().toDouble() * scaleY
144
- val x = boundingBox.left.toDouble() * scaleX
145
- val y = boundingBox.top.toDouble() * scaleY
146
-
147
- when(orientation) {
148
- Orientation.PORTRAIT -> {
149
- // device is landscape left
150
- bounds["x"] = (-y + sourceWidth * scaleX) - width
151
- bounds["y"] = (-x + sourceHeight * scaleY) - height
152
- }
153
- Orientation.LANDSCAPE_LEFT -> {
154
- // device is portrait
155
- bounds["x"] = (-x + sourceWidth * scaleX) - width
156
- bounds["y"] = y
157
- }
158
- Orientation.PORTRAIT_UPSIDE_DOWN -> {
159
- // device is landscape right
160
- bounds["x"] = y
161
- bounds["y"] = x
162
- }
163
- Orientation.LANDSCAPE_RIGHT -> {
164
- // device is upside down
165
- bounds["x"] = x
166
- bounds["y"] = (-y + sourceHeight * scaleY) - height
167
- }
168
- }
169
-
170
- bounds["width"] = width
171
- bounds["height"] = height
172
- return bounds
173
- }
174
-
175
- private fun processLandmarks(
176
- face: Face,
177
- scaleX: Double,
178
- scaleY: Double
179
- ): Map<String, Any> {
180
- val faceLandmarksTypes = intArrayOf(
181
- FaceLandmark.LEFT_CHEEK,
182
- FaceLandmark.LEFT_EAR,
183
- FaceLandmark.LEFT_EYE,
184
- FaceLandmark.MOUTH_BOTTOM,
185
- FaceLandmark.MOUTH_LEFT,
186
- FaceLandmark.MOUTH_RIGHT,
187
- FaceLandmark.NOSE_BASE,
188
- FaceLandmark.RIGHT_CHEEK,
189
- FaceLandmark.RIGHT_EAR,
190
- FaceLandmark.RIGHT_EYE
191
- )
192
- val faceLandmarksTypesStrings = arrayOf(
193
- "LEFT_CHEEK",
194
- "LEFT_EAR",
195
- "LEFT_EYE",
196
- "MOUTH_BOTTOM",
197
- "MOUTH_LEFT",
198
- "MOUTH_RIGHT",
199
- "NOSE_BASE",
200
- "RIGHT_CHEEK",
201
- "RIGHT_EAR",
202
- "RIGHT_EYE"
203
- )
204
- val faceLandmarksTypesMap: MutableMap<String, Any> = HashMap()
205
- for (i in faceLandmarksTypesStrings.indices) {
206
- val landmark = face.getLandmark(faceLandmarksTypes[i])
207
- val landmarkName = faceLandmarksTypesStrings[i]
208
- Log.d(TAG, "Getting '$landmarkName' landmark")
209
- if (landmark == null) {
210
- Log.d(TAG, "Landmark '$landmarkName' is null - going next")
211
- continue
212
- }
213
- val point = landmark.position
214
- val currentPointsMap: MutableMap<String, Double> = HashMap()
215
- currentPointsMap["x"] = point.x.toDouble() * scaleX
216
- currentPointsMap["y"] = point.y.toDouble() * scaleY
217
- faceLandmarksTypesMap[landmarkName] = currentPointsMap
218
- }
219
-
220
- return faceLandmarksTypesMap
221
- }
222
-
223
- private fun processFaceContours(
224
- face: Face,
225
- scaleX: Double,
226
- scaleY: Double
227
- ): Map<String, Any> {
228
- val faceContoursTypes = intArrayOf(
229
- FaceContour.FACE,
230
- FaceContour.LEFT_CHEEK,
231
- FaceContour.LEFT_EYE,
232
- FaceContour.LEFT_EYEBROW_BOTTOM,
233
- FaceContour.LEFT_EYEBROW_TOP,
234
- FaceContour.LOWER_LIP_BOTTOM,
235
- FaceContour.LOWER_LIP_TOP,
236
- FaceContour.NOSE_BOTTOM,
237
- FaceContour.NOSE_BRIDGE,
238
- FaceContour.RIGHT_CHEEK,
239
- FaceContour.RIGHT_EYE,
240
- FaceContour.RIGHT_EYEBROW_BOTTOM,
241
- FaceContour.RIGHT_EYEBROW_TOP,
242
- FaceContour.UPPER_LIP_BOTTOM,
243
- FaceContour.UPPER_LIP_TOP
244
- )
245
- val faceContoursTypesStrings = arrayOf(
246
- "FACE",
247
- "LEFT_CHEEK",
248
- "LEFT_EYE",
249
- "LEFT_EYEBROW_BOTTOM",
250
- "LEFT_EYEBROW_TOP",
251
- "LOWER_LIP_BOTTOM",
252
- "LOWER_LIP_TOP",
253
- "NOSE_BOTTOM",
254
- "NOSE_BRIDGE",
255
- "RIGHT_CHEEK",
256
- "RIGHT_EYE",
257
- "RIGHT_EYEBROW_BOTTOM",
258
- "RIGHT_EYEBROW_TOP",
259
- "UPPER_LIP_BOTTOM",
260
- "UPPER_LIP_TOP"
261
- )
262
- val faceContoursTypesMap: MutableMap<String, Any> = HashMap()
263
- for (i in faceContoursTypesStrings.indices) {
264
- val contour = face.getContour(faceContoursTypes[i])
265
- val contourName = faceContoursTypesStrings[i]
266
- Log.d(TAG, "Getting '$contourName' contour")
267
- if (contour == null) {
268
- Log.d(TAG, "Face contour '$contourName' is null - going next")
269
- continue
270
- }
271
- val points = contour.points
272
- val pointsMap: MutableMap<String, Map<String, Double>> = HashMap()
273
- for (j in points.indices) {
274
- val currentPointsMap: MutableMap<String, Double> = HashMap()
275
- currentPointsMap["x"] = points[j].x.toDouble() * scaleX
276
- currentPointsMap["y"] = points[j].y.toDouble() * scaleY
277
- pointsMap[j.toString()] = currentPointsMap
278
- }
279
-
280
- faceContoursTypesMap[contourName] = pointsMap
281
- }
282
- return faceContoursTypesMap
283
- }
284
-
285
- private fun getOrientation(
286
- orientation: Orientation
287
- ): Int {
288
- return when (orientation) {
289
- // device is landscape left
290
- Orientation.PORTRAIT -> 0
291
- // device is portrait
292
- Orientation.LANDSCAPE_LEFT -> 270
293
- // device is landscape right
294
- Orientation.PORTRAIT_UPSIDE_DOWN -> 180
295
- // device is upside-down
296
- Orientation.LANDSCAPE_RIGHT -> 90
297
- }
298
- }
299
-
300
- companion object {
301
- private const val TAG = "FaceDetectorFrameProcessorPlugin"
302
- }
303
- }
@@ -1,115 +0,0 @@
1
- package com.trustchex.reactnativesdk.visioncameraplugins.textrecognition
2
-
3
- import android.graphics.Point
4
- import android.graphics.Rect
5
- import android.media.Image
6
- import com.facebook.react.bridge.WritableNativeArray
7
- import com.facebook.react.bridge.WritableNativeMap
8
- import com.google.android.gms.tasks.Task
9
- import com.google.android.gms.tasks.Tasks
10
- import com.google.mlkit.vision.common.InputImage
11
- import com.google.mlkit.vision.text.Text
12
- import com.google.mlkit.vision.text.TextRecognition
13
- import com.google.mlkit.vision.text.latin.TextRecognizerOptions
14
- import com.mrousavy.camera.frameprocessors.Frame
15
- import com.mrousavy.camera.frameprocessors.FrameProcessorPlugin
16
- import com.mrousavy.camera.frameprocessors.VisionCameraProxy
17
- import java.util.HashMap
18
-
19
- class TextRecognitionFrameProcessorPlugin(proxy: VisionCameraProxy, options: Map<String, Any>?) :
20
- FrameProcessorPlugin() {
21
-
22
- private var recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
23
-
24
- override fun callback(frame: Frame, arguments: Map<String, Any>?): HashMap<String, Any?>? {
25
- val data = WritableNativeMap()
26
- val mediaImage: Image = frame.image
27
- val image =
28
- InputImage.fromMediaImage(mediaImage, frame.imageProxy.imageInfo.rotationDegrees)
29
- val task: Task<Text> = recognizer.process(image)
30
- try {
31
- val text: Text = Tasks.await(task)
32
- if (text.text.isEmpty()) {
33
- return WritableNativeMap().toHashMap()
34
- }
35
- data.putString("resultText", text.text)
36
- data.putArray("blocks", getBlocks(text.textBlocks))
37
- return data.toHashMap()
38
- } catch (e: Exception) {
39
- e.printStackTrace()
40
- return null
41
- }
42
- }
43
-
44
- companion object {
45
- fun getBlocks(blocks: MutableList<Text.TextBlock>): WritableNativeArray {
46
- val blockArray = WritableNativeArray()
47
- blocks.forEach { block ->
48
- val blockMap = WritableNativeMap().apply {
49
- putString("blockText", block.text)
50
- putArray("blockCornerPoints", block.cornerPoints?.let { getCornerPoints(it) })
51
- putMap("blockFrame", getFrame(block.boundingBox))
52
- putArray("lines", getLines(block.lines))
53
- }
54
- blockArray.pushMap(blockMap)
55
- }
56
- return blockArray
57
- }
58
-
59
- private fun getLines(lines: MutableList<Text.Line>): WritableNativeArray {
60
- val lineArray = WritableNativeArray()
61
- lines.forEach { line ->
62
- val lineMap = WritableNativeMap().apply {
63
- putString("lineText", line.text)
64
- putArray("lineCornerPoints", line.cornerPoints?.let { getCornerPoints(it) })
65
- putMap("lineFrame", getFrame(line.boundingBox))
66
- putArray(
67
- "lineLanguages",
68
- WritableNativeArray().apply { pushString(line.recognizedLanguage) })
69
- putArray("elements", getElements(line.elements))
70
- }
71
- lineArray.pushMap(lineMap)
72
- }
73
- return lineArray
74
- }
75
-
76
- private fun getElements(elements: MutableList<Text.Element>): WritableNativeArray {
77
- val elementArray = WritableNativeArray()
78
- elements.forEach { element ->
79
- val elementMap = WritableNativeMap().apply {
80
- putString("elementText", element.text)
81
- putArray(
82
- "elementCornerPoints",
83
- element.cornerPoints?.let { getCornerPoints(it) })
84
- putMap("elementFrame", getFrame(element.boundingBox))
85
- }
86
- elementArray.pushMap(elementMap)
87
- }
88
- return elementArray
89
- }
90
-
91
- private fun getCornerPoints(points: Array<Point>): WritableNativeArray {
92
- val cornerPoints = WritableNativeArray()
93
- points.forEach { point ->
94
- cornerPoints.pushMap(WritableNativeMap().apply {
95
- putInt("x", point.x)
96
- putInt("y", point.y)
97
- })
98
- }
99
- return cornerPoints
100
- }
101
-
102
- private fun getFrame(boundingBox: Rect?): WritableNativeMap {
103
- return WritableNativeMap().apply {
104
- boundingBox?.let {
105
- putDouble("x", it.exactCenterX().toDouble())
106
- putDouble("y", it.exactCenterY().toDouble())
107
- putInt("width", it.width())
108
- putInt("height", it.height())
109
- putInt("boundingCenterX", it.centerX())
110
- putInt("boundingCenterY", it.centerY())
111
- }
112
- }
113
- }
114
- }
115
- }
@@ -1,9 +0,0 @@
1
- #ifndef BarcodeScannerFrameProcessorPlugin_Bridging_Header_h
2
- #define BarcodeScannerFrameProcessorPlugin_Bridging_Header_h
3
-
4
- #if VISION_CAMERA_ENABLE_FRAME_PROCESSORS
5
- #import <VisionCamera/FrameProcessorPlugin.h>
6
- #import <VisionCamera/Frame.h>
7
- #endif
8
-
9
- #endif /* BarcodeScannerFrameProcessorPlugin_Bridging_Header_h */
@@ -1,22 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
- #import <VisionCamera/FrameProcessorPlugin.h>
3
- #import <VisionCamera/FrameProcessorPluginRegistry.h>
4
- #import <VisionCamera/Frame.h>
5
-
6
- #if __has_include("TrustchexSDK/TrustchexSDK-Swift.h")
7
- #import "TrustchexSDK/TrustchexSDK-Swift.h"
8
- #else
9
- #import "TrustchexSDK-Swift.h"
10
- #endif
11
-
12
- @interface BarcodeScannerFrameProcessorPlugin (FrameProcessorPluginLoader)
13
- @end
14
-
15
- @implementation BarcodeScannerFrameProcessorPlugin (FrameProcessorPluginLoader)
16
- + (void)load {
17
- [FrameProcessorPluginRegistry addFrameProcessorPlugin:@"scanCodes"
18
- withInitializer:^FrameProcessorPlugin*(VisionCameraProxyHolder* proxy, NSDictionary* options) {
19
- return [[BarcodeScannerFrameProcessorPlugin alloc] initWithProxy:proxy withOptions:options];
20
- }];
21
- }
22
- @end
@@ -1,188 +0,0 @@
1
- import Foundation
2
- import Vision
3
- import VisionCamera
4
-
5
- @objc(BarcodeScannerFrameProcessorPlugin)
6
- public class BarcodeScannerFrameProcessorPlugin: FrameProcessorPlugin {
7
-
8
- public override init(proxy: VisionCameraProxyHolder, options: [AnyHashable: Any]! = [:]) {
9
- super.init(proxy: proxy, options: options)
10
- print(
11
- "BarcodeScannerFrameProcessorPlugin: Initialized with options: \(String(describing: options))"
12
- )
13
- }
14
-
15
- public override func callback(_ frame: Frame, withArguments arguments: [AnyHashable: Any]?)
16
- -> Any?
17
- {
18
- print("BarcodeScannerFrameProcessorPlugin: callback called")
19
-
20
- // Get the pixel buffer from the frame
21
- guard let imageBuffer = CMSampleBufferGetImageBuffer(frame.buffer) else {
22
- print("BarcodeScannerFrameProcessorPlugin: Could not get pixel buffer from frame")
23
- return []
24
- }
25
-
26
- // Parse barcode types from arguments (default to QR codes)
27
- var symbologies: [VNBarcodeSymbology] = [.qr]
28
-
29
- if let arguments = arguments,
30
- let barcodeTypes = arguments["barcodeTypes"] as? [String]
31
- {
32
- symbologies = barcodeTypes.compactMap { type in
33
- switch type {
34
- case "aztec": return .aztec
35
- case "codabar": return .codabar
36
- case "code-128": return .code128
37
- case "code-39": return .code39
38
- case "code-93": return .code93
39
- case "data-matrix": return .dataMatrix
40
- case "ean-13": return .ean13
41
- case "ean-8": return .ean8
42
- case "itf": return .i2of5
43
- case "pdf-417": return .pdf417
44
- case "qr": return .qr
45
- case "upc-a": return .ean13 // UPC-A is subset of EAN-13
46
- case "upc-e": return .upce
47
- default: return nil
48
- }
49
- }
50
- }
51
-
52
- // Use semaphore to make async Vision calls synchronous for frame processor
53
- let semaphore = DispatchSemaphore(value: 0)
54
- var detectedBarcodes: [VNBarcodeObservation] = []
55
- var visionError: Error? = nil
56
-
57
- // Create Vision request handler
58
- let handler = VNImageRequestHandler(cvPixelBuffer: imageBuffer, options: [:])
59
-
60
- // Create barcode detection request
61
- let request = VNDetectBarcodesRequest { (request, error) in
62
- defer { semaphore.signal() }
63
-
64
- if let error = error {
65
- print("BarcodeScannerFrameProcessorPlugin: Vision error: \(error.localizedDescription)")
66
- visionError = error
67
- return
68
- }
69
-
70
- detectedBarcodes = request.results as? [VNBarcodeObservation] ?? []
71
- print("BarcodeScannerFrameProcessorPlugin: Detected \(detectedBarcodes.count) barcodes")
72
- }
73
-
74
- // Set symbologies
75
- request.symbologies = symbologies
76
-
77
- // Perform the request
78
- do {
79
- try handler.perform([request])
80
- } catch {
81
- print(
82
- "BarcodeScannerFrameProcessorPlugin: Error performing Vision request: \(error.localizedDescription)"
83
- )
84
- return []
85
- }
86
-
87
- // Wait for completion with timeout
88
- let waitResult = semaphore.wait(timeout: .now() + 0.1) // 100ms timeout
89
- if waitResult == .timedOut {
90
- print("BarcodeScannerFrameProcessorPlugin: Vision request timed out")
91
- return []
92
- }
93
-
94
- // Check for errors
95
- if let error = visionError {
96
- print(
97
- "BarcodeScannerFrameProcessorPlugin: Vision processing failed: \(error.localizedDescription)"
98
- )
99
- return []
100
- }
101
-
102
- // Convert results to pixel coordinates at iOS level
103
- let result = detectedBarcodes.compactMap { barcode -> [String: Any]? in
104
- guard let barcodeValue = barcode.payloadStringValue, !barcodeValue.isEmpty else {
105
- return nil
106
- }
107
-
108
- print("BarcodeScannerFrameProcessorPlugin: Processing barcode: \(barcodeValue)")
109
-
110
- var map: [String: Any] = [:]
111
-
112
- // Main value that TypeScript interface expects
113
- map["value"] = barcodeValue
114
-
115
- // Convert from normalized (0-1) coordinates to pixel coordinates
116
- let frameWidth = frame.width
117
- let frameHeight = frame.height
118
- let boundingBox = barcode.boundingBox
119
-
120
- // Convert from normalized (0-1) with bottom-left origin to pixel coordinates with top-left origin
121
- let left = boundingBox.origin.x * CGFloat(frameWidth)
122
- let bottom = boundingBox.origin.y * CGFloat(frameHeight)
123
- let width = boundingBox.size.width * CGFloat(frameWidth)
124
- let height = boundingBox.size.height * CGFloat(frameHeight)
125
- let top = CGFloat(frameHeight) - bottom - height // Flip Y coordinate from bottom-left to top-left
126
-
127
- // Create bounding box in pixel coordinates with top-left origin
128
- map["boundingBox"] = [
129
- "origin": [
130
- "x": Int(left),
131
- "y": Int(top),
132
- ],
133
- "size": [
134
- "width": Int(width),
135
- "height": Int(height),
136
- ],
137
- ]
138
-
139
- // Convert corner points to pixel coordinates with top-left origin
140
- let cornerPoints = [
141
- [
142
- "x": Int(barcode.topLeft.x * CGFloat(frameWidth)),
143
- "y": Int((1.0 - barcode.topLeft.y) * CGFloat(frameHeight)),
144
- ],
145
- [
146
- "x": Int(barcode.topRight.x * CGFloat(frameWidth)),
147
- "y": Int((1.0 - barcode.topRight.y) * CGFloat(frameHeight)),
148
- ],
149
- [
150
- "x": Int(barcode.bottomRight.x * CGFloat(frameWidth)),
151
- "y": Int((1.0 - barcode.bottomRight.y) * CGFloat(frameHeight)),
152
- ],
153
- [
154
- "x": Int(barcode.bottomLeft.x * CGFloat(frameWidth)),
155
- "y": Int((1.0 - barcode.bottomLeft.y) * CGFloat(frameHeight)),
156
- ],
157
- ]
158
- map["cornerPoints"] = cornerPoints
159
-
160
- // Map barcode symbology to TypeScript BarcodeType strings
161
- let typeString: String
162
- switch barcode.symbology {
163
- case .aztec: typeString = "aztec"
164
- case .codabar: typeString = "codabar"
165
- case .code128: typeString = "code-128"
166
- case .code39: typeString = "code-39"
167
- case .code93: typeString = "code-93"
168
- case .dataMatrix: typeString = "data-matrix"
169
- case .ean13: typeString = "ean-13"
170
- case .ean8: typeString = "ean-8"
171
- case .i2of5, .i2of5Checksum, .itf14: typeString = "itf"
172
- case .pdf417: typeString = "pdf-417"
173
- case .qr: typeString = "qr"
174
- case .upce: typeString = "upc-e"
175
- default: typeString = "unknown"
176
- }
177
- map["type"] = typeString
178
-
179
- print(
180
- "BarcodeScannerFrameProcessorPlugin: Converted barcode - value: \(barcodeValue), type: \(typeString), boundingBox: \(map["boundingBox"] ?? "nil")"
181
- )
182
- return map
183
- }
184
-
185
- print("BarcodeScannerFrameProcessorPlugin: Returning \(result.count) processed barcodes")
186
- return result
187
- }
188
- }
@@ -1,13 +0,0 @@
1
- //
2
- // VisionCameraCropper-Bridging-Header.h
3
- // TrustchexSDK
4
- //
5
-
6
- #ifndef VisionCameraCropper_Bridging_Header_h
7
- #define VisionCameraCropper_Bridging_Header_h
8
-
9
- #import <React/RCTBridgeModule.h>
10
- #import <React/RCTLog.h>
11
- #import <React/RCTUtils.h>
12
-
13
- #endif /* VisionCameraCropper_Bridging_Header_h */
@@ -1,20 +0,0 @@
1
- //
2
- // VisionCameraCropper.h
3
- // TrustchexSDK
4
- //
5
-
6
- #ifndef VisionCameraCropper_h
7
- #define VisionCameraCropper_h
8
-
9
- #import <React/RCTBridgeModule.h>
10
- #import <UIKit/UIKit.h>
11
-
12
- @interface VisionCameraCropper : NSObject <RCTBridgeModule>
13
-
14
- + (UIImage *)rotateImage:(UIImage *)image degree:(float)degree;
15
- + (NSString *)getBase64FromImage:(UIImage *)image;
16
- + (UIImage *)convertBase64ToImage:(NSString *)base64String;
17
-
18
- @end
19
-
20
- #endif /* VisionCameraCropper_h */
@@ -1,22 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
- #import <VisionCamera/FrameProcessorPlugin.h>
3
- #import <VisionCamera/FrameProcessorPluginRegistry.h>
4
- #import <VisionCamera/Frame.h>
5
-
6
- #if __has_include("TrustchexSDK/TrustchexSDK-Swift.h")
7
- #import "TrustchexSDK/TrustchexSDK-Swift.h"
8
- #else
9
- #import "TrustchexSDK-Swift.h"
10
- #endif
11
-
12
- @interface VisionCameraCropper (FrameProcessorPluginLoader)
13
- @end
14
-
15
- @implementation VisionCameraCropper (FrameProcessorPluginLoader)
16
- + (void)load {
17
- [FrameProcessorPluginRegistry addFrameProcessorPlugin:@"crop"
18
- withInitializer:^FrameProcessorPlugin*(VisionCameraProxyHolder* proxy, NSDictionary* options) {
19
- return [[VisionCameraCropper alloc] initWithProxy:proxy withOptions:options];
20
- }];
21
- }
22
- @end