@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,144 +0,0 @@
1
- import Foundation
2
- import VisionCamera
3
- import MLKitVision
4
- import MLKitTextRecognition
5
-
6
- import Foundation
7
- import VisionCamera
8
- import MLKitVision
9
- import MLKitTextRecognition
10
-
11
- @objc(TextRecognitionFrameProcessorPlugin)
12
- public class TextRecognitionFrameProcessorPlugin: FrameProcessorPlugin {
13
-
14
- private var textRecognizer = TextRecognizer()
15
- private static let latinOptions = TextRecognizerOptions()
16
- private var data: [String: Any] = [:]
17
-
18
-
19
- public override init(proxy: VisionCameraProxyHolder, options: [AnyHashable: Any]! = [:]) {
20
- super.init(proxy: proxy, options: options)
21
- self.textRecognizer = TextRecognizer.textRecognizer(options: TextRecognitionFrameProcessorPlugin.latinOptions)
22
- }
23
-
24
-
25
- public override func callback(_ frame: Frame, withArguments arguments: [AnyHashable: Any]?) -> Any {
26
- let buffer = frame.buffer
27
- let image = VisionImage(buffer: buffer)
28
- image.orientation = getOrientation(orientation: frame.orientation)
29
-
30
- do {
31
- let result = try self.textRecognizer.results(in: image)
32
- let blocks = TextRecognitionFrameProcessorPlugin.processBlocks(blocks: result.blocks)
33
- data["resultText"] = result.text
34
- data["blocks"] = blocks
35
- if result.text.isEmpty {
36
- return [:]
37
- }else{
38
- return data
39
- }
40
- } catch {
41
- print("Failed to recognize text: \(error.localizedDescription).")
42
- return [:]
43
- }
44
- }
45
-
46
- static func processBlocks(blocks:[TextBlock]) -> Array<Any> {
47
- var blocksArray : [Any] = []
48
- for block in blocks {
49
- var blockData : [String:Any] = [:]
50
- blockData["blockText"] = block.text
51
- blockData["blockCornerPoints"] = processCornerPoints(block.cornerPoints)
52
- blockData["blockFrame"] = processFrame(block.frame)
53
- blockData["lines"] = processLines(lines: block.lines)
54
- blocksArray.append(blockData)
55
- }
56
- return blocksArray
57
- }
58
-
59
- private static func processLines(lines:[TextLine]) -> Array<Any> {
60
- var linesArray : [Any] = []
61
- for line in lines {
62
- var lineData : [String:Any] = [:]
63
- lineData["lineText"] = line.text
64
- lineData["lineLanguages"] = processRecognizedLanguages(line.recognizedLanguages)
65
- lineData["lineCornerPoints"] = processCornerPoints(line.cornerPoints)
66
- lineData["lineFrame"] = processFrame(line.frame)
67
- lineData["elements"] = processElements(elements: line.elements)
68
- linesArray.append(lineData)
69
- }
70
- return linesArray
71
- }
72
-
73
- private static func processElements(elements:[TextElement]) -> Array<Any> {
74
- var elementsArray : [Any] = []
75
-
76
- for element in elements {
77
- var elementData : [String:Any] = [:]
78
- elementData["elementText"] = element.text
79
- elementData["elementCornerPoints"] = processCornerPoints(element.cornerPoints)
80
- elementData["elementFrame"] = processFrame(element.frame)
81
-
82
- elementsArray.append(elementData)
83
- }
84
-
85
- return elementsArray
86
- }
87
-
88
- private static func processRecognizedLanguages(_ languages: [TextRecognizedLanguage]) -> [String] {
89
-
90
- var languageArray: [String] = []
91
-
92
- for language in languages {
93
- guard let code = language.languageCode else {
94
- print("No language code exists")
95
- break;
96
- }
97
- if code.isEmpty{
98
- languageArray.append("und")
99
- }else {
100
- languageArray.append(code)
101
-
102
- }
103
- }
104
-
105
- return languageArray
106
- }
107
-
108
- private static func processCornerPoints(_ cornerPoints: [NSValue]) -> [[String: CGFloat]] {
109
- return cornerPoints.compactMap { $0.cgPointValue }.map { ["x": $0.x, "y": $0.y] }
110
- }
111
-
112
- private static func processFrame(_ frameRect: CGRect) -> [String: CGFloat] {
113
- let offsetX = (frameRect.midX - ceil(frameRect.width)) / 2.0
114
- let offsetY = (frameRect.midY - ceil(frameRect.height)) / 2.0
115
-
116
- let x = frameRect.maxX + offsetX
117
- let y = frameRect.minY + offsetY
118
-
119
- return [
120
- "x": frameRect.midX + (frameRect.midX - x),
121
- "y": frameRect.midY + (y - frameRect.midY),
122
- "width": frameRect.width,
123
- "height": frameRect.height,
124
- "boundingCenterX": frameRect.midX,
125
- "boundingCenterY": frameRect.midY
126
- ]
127
- }
128
-
129
- private func getOrientation(orientation: UIImage.Orientation) -> UIImage.Orientation {
130
- switch orientation {
131
- case .up:
132
- return .up
133
- case .left:
134
- return .right
135
- case .down:
136
- return .down
137
- case .right:
138
- return .left
139
- default:
140
- return .up
141
- }
142
- }
143
-
144
- }
@@ -1,308 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Check if frame is blurry using Laplacian variance
5
- * Uses both horizontal and vertical gradients for more accurate blur detection
6
- * Lower variance indicates a blurrier image
7
- * @param frame - The camera frame to analyze
8
- * @param threshold - Variance threshold below which image is considered blurry (default: 10)
9
- * @returns true if image is blurry, false otherwise
10
- */
11
- const isBlurry = (frame, threshold = 10) => {
12
- 'worklet';
13
-
14
- const buffer = frame.toArrayBuffer();
15
- const data = new Uint8Array(buffer);
16
- const width = frame.width;
17
- const height = frame.height;
18
- let sum = 0;
19
- let sumSq = 0;
20
- let count = 0;
21
-
22
- // Sample central 50% region (matching Flutter algorithm)
23
- const startY = Math.floor(height / 4);
24
- const endY = Math.floor(3 * height / 4) - 1;
25
- const startX = Math.floor(width / 4);
26
- const endX = Math.floor(3 * width / 4) - 1;
27
-
28
- // Sample at 5-pixel intervals for better accuracy (matching Flutter)
29
- for (let y = startY; y < endY; y += 5) {
30
- for (let x = startX; x < endX; x += 5) {
31
- const idx = y * width + x;
32
- const idxRight = idx + 1;
33
- const idxDown = idx + width;
34
-
35
- // Check bounds for both horizontal and vertical neighbors
36
- if (idxRight < data.length && idxDown < data.length && data[idx] !== undefined && data[idxRight] !== undefined && data[idxDown] !== undefined) {
37
- // Horizontal gradient
38
- const diffH = Math.abs(data[idx] - data[idxRight]);
39
- // Vertical gradient
40
- const diffV = Math.abs(data[idx] - data[idxDown]);
41
- // Combined Laplacian-like measure
42
- const laplacian = diffH + diffV;
43
- sum += laplacian;
44
- sumSq += laplacian * laplacian;
45
- count++;
46
- }
47
- }
48
- }
49
- if (count === 0) return false;
50
-
51
- // Calculate variance: E[X²] - E[X]²
52
- const mean = sum / count;
53
- const variance = sumSq / count - mean * mean;
54
- return variance < threshold;
55
- };
56
-
57
- /**
58
- * Get average brightness for entire frame (center area)
59
- */
60
- const getAverageBrightness = frame => {
61
- 'worklet';
62
-
63
- const buffer = frame.toArrayBuffer();
64
- const data = new Uint8Array(buffer);
65
- const width = frame.width;
66
- const height = frame.height;
67
- const centerX = Math.floor(width / 2);
68
- const centerY = Math.floor(height / 2);
69
- const halfSizeX = Math.floor(width / 2);
70
- const halfSizeY = Math.floor(height / 2);
71
- let luminanceSum = 0;
72
- let pixelCount = 0;
73
- for (let y = centerY - halfSizeY; y < centerY + halfSizeY; y++) {
74
- for (let x = centerX - halfSizeX; x < centerX + halfSizeX; x++) {
75
- const index = y * width + x;
76
- if (data[index] !== undefined) {
77
- luminanceSum += data[index];
78
- pixelCount++;
79
- }
80
- }
81
- }
82
- return luminanceSum / pixelCount;
83
- };
84
-
85
- /**
86
- * Get average brightness for a specific circular region (for face detection)
87
- * Calculates brightness only for pixels inside the circle defined by centerX, centerY, and radius
88
- */
89
- const getCircularRegionBrightness = (frame, circleRect) => {
90
- 'worklet';
91
-
92
- const buffer = frame.toArrayBuffer();
93
- const data = new Uint8Array(buffer);
94
- const width = frame.width;
95
- const height = frame.height;
96
-
97
- // Calculate circle parameters from rect
98
- const centerX = Math.floor(circleRect.minX + circleRect.width / 2);
99
- const centerY = Math.floor(circleRect.minY + circleRect.height / 2);
100
- const radius = Math.floor(Math.min(circleRect.width, circleRect.height) / 2);
101
- let luminanceSum = 0;
102
- let pixelCount = 0;
103
-
104
- // Calculate bounding box for the circle to optimize iteration
105
- const minX = Math.max(0, centerX - radius);
106
- const maxX = Math.min(width - 1, centerX + radius);
107
- const minY = Math.max(0, centerY - radius);
108
- const maxY = Math.min(height - 1, centerY + radius);
109
-
110
- // Iterate only over pixels in the bounding box
111
- for (let y = minY; y <= maxY; y++) {
112
- for (let x = minX; x <= maxX; x++) {
113
- // Check if pixel is inside the circle
114
- const dx = x - centerX;
115
- const dy = y - centerY;
116
- const distanceSquared = dx * dx + dy * dy;
117
- if (distanceSquared <= radius * radius) {
118
- const index = y * width + x;
119
- if (data[index] !== undefined) {
120
- luminanceSum += data[index];
121
- pixelCount++;
122
- }
123
- }
124
- }
125
- }
126
- return pixelCount > 0 ? luminanceSum / pixelCount : 0;
127
- };
128
- const isFrameBright = frame => {
129
- 'worklet';
130
-
131
- return getAverageBrightness(frame) > 60;
132
- };
133
-
134
- /**
135
- * Check if a circular region in the frame is bright enough
136
- */
137
- const isCircularRegionBright = (frame, circleRect, threshold = 60) => {
138
- 'worklet';
139
-
140
- return getCircularRegionBrightness(frame, circleRect) > threshold;
141
- };
142
-
143
- /**
144
- * Get average brightness for a specific rectangular region
145
- */
146
- const getRegionBrightness = (frame, bounds) => {
147
- 'worklet';
148
-
149
- const buffer = frame.toArrayBuffer();
150
- const data = new Uint8Array(buffer);
151
- const width = frame.width;
152
- const height = frame.height;
153
- const minX = Math.max(0, Math.floor(bounds.minX));
154
- const maxX = Math.min(width - 1, Math.floor(bounds.minX + bounds.width));
155
- const minY = Math.max(0, Math.floor(bounds.minY));
156
- const maxY = Math.min(height - 1, Math.floor(bounds.minY + bounds.height));
157
- let luminanceSum = 0;
158
- let pixelCount = 0;
159
- for (let y = minY; y <= maxY; y++) {
160
- for (let x = minX; x <= maxX; x++) {
161
- const index = y * width + x;
162
- if (data[index] !== undefined) {
163
- luminanceSum += data[index];
164
- pixelCount++;
165
- }
166
- }
167
- }
168
- return pixelCount > 0 ? luminanceSum / pixelCount : 0;
169
- };
170
-
171
- /**
172
- * Calculate adaptive exposure step based on distance from target brightness
173
- * Uses smooth scaling to prevent abrupt exposure changes that could cause dark frames
174
- */
175
- const calculateExposureStep = (currentBrightness, targetBrightness) => {
176
- 'worklet';
177
-
178
- const difference = Math.abs(targetBrightness - currentBrightness);
179
- // Use smaller steps for smoother transitions: max 2, min 1
180
- // Use floor + 1 to ensure at least step of 1 and prevent over-correction
181
- const step = Math.min(2, Math.max(1, Math.floor(difference / 25)));
182
- return step;
183
- };
184
-
185
- /**
186
- * Get the center point of the scan area
187
- * Scan area is typically 36%-64% of vertical space
188
- */
189
- const getScanAreaCenterPoint = (width, height) => {
190
- const scanAreaTop = height * 0.36;
191
- const scanAreaBottom = height * 0.64;
192
- const scanAreaCenterY = (scanAreaTop + scanAreaBottom) / 2;
193
- const scanAreaCenterX = width / 2;
194
- return {
195
- x: scanAreaCenterX,
196
- y: scanAreaCenterY
197
- };
198
- };
199
-
200
- /**
201
- * Document dimensions (in mm) for reference
202
- */
203
- const DOCUMENT_DIMENSIONS = {
204
- ID_CARD: {
205
- width: 85.6,
206
- height: 53.98,
207
- ratio: 1.586
208
- },
209
- PASSPORT: {
210
- width: 125,
211
- height: 88,
212
- ratio: 1.42
213
- }
214
- };
215
-
216
- /**
217
- * Detected document information
218
- */
219
-
220
- /**
221
- * Detect document contours and estimate document type based on aspect ratio
222
- * This is a simplified detection that looks for rectangular contours in the scan area
223
- * @param frame - The camera frame to analyze
224
- * @param scanAreaBounds - The bounds of the scan area {x, y, width, height}
225
- * @returns Detected document info or null if no document detected
226
- */
227
- const detectDocumentInFrame = (frame, scanAreaBounds) => {
228
- 'worklet';
229
-
230
- // For now, we'll use a simple edge-based detection
231
- // In production, this would integrate with OpenCV findContours
232
- // This is a placeholder that estimates based on brightness patterns
233
- const buffer = frame.toArrayBuffer();
234
- const data = new Uint8Array(buffer);
235
- const frameWidth = frame.width;
236
- const frameHeight = frame.height;
237
-
238
- // Sample edges of scan area to detect document boundaries
239
- const scanX = Math.floor(scanAreaBounds.x * frameWidth);
240
- const scanY = Math.floor(scanAreaBounds.y * frameHeight);
241
- const scanWidth = Math.floor(scanAreaBounds.width * frameWidth);
242
- const scanHeight = Math.floor(scanAreaBounds.height * frameHeight);
243
-
244
- // Calculate average brightness in scan area to detect presence of document
245
- // Documents typically have good contrast against backgrounds
246
- let totalBrightness = 0;
247
- let sampleCount = 0;
248
- const sampleStep = 20; // Sample every 20 pixels for performance
249
-
250
- // Sample brightness across the scan area
251
- for (let y = scanY; y < scanY + scanHeight; y += sampleStep) {
252
- for (let x = scanX; x < scanX + scanWidth; x += sampleStep) {
253
- const idx = y * frameWidth + x;
254
- if (idx >= 0 && idx < data.length) {
255
- totalBrightness += data[idx];
256
- sampleCount++;
257
- }
258
- }
259
- }
260
- const avgBrightness = sampleCount > 0 ? totalBrightness / sampleCount : 0;
261
-
262
- // Calculate standard deviation to measure contrast
263
- let variance = 0;
264
- for (let y = scanY; y < scanY + scanHeight; y += sampleStep) {
265
- for (let x = scanX; x < scanX + scanWidth; x += sampleStep) {
266
- const idx = y * frameWidth + x;
267
- if (idx >= 0 && idx < data.length) {
268
- const diff = data[idx] - avgBrightness;
269
- variance += diff * diff;
270
- }
271
- }
272
- }
273
- const stdDev = sampleCount > 0 ? Math.sqrt(variance / sampleCount) : 0;
274
-
275
- // Document is present if there's ANY reasonable content in scan area
276
- // Lower threshold: stdDev > 10 indicates some content (not blank surface)
277
- // Brightness between 20-240 covers most lighting conditions
278
- const documentPresent = stdDev > 10 && avgBrightness > 20 && avgBrightness < 240;
279
- if (!documentPresent) {
280
- return null;
281
- }
282
-
283
- // Default to ID_CARD since scan area matches ID card proportions
284
- // Passport detection would require actual contour detection
285
- const type = 'ID_CARD';
286
- const confidence = Math.min(1, stdDev / 50);
287
-
288
- // Calculate how much of frame the document occupies
289
- const framePercentage = scanWidth * scanHeight / (frameWidth * frameHeight);
290
- const aspectRatio = scanWidth / scanHeight;
291
-
292
- // Determine size feedback based on contrast level
293
- // Higher contrast usually means document is closer/larger
294
- let size = 'GOOD';
295
- if (stdDev < 25) {
296
- size = 'TOO_SMALL'; // Low contrast - probably far away
297
- } else if (stdDev > 80) {
298
- size = 'TOO_LARGE'; // Very high contrast - probably too close
299
- }
300
- return {
301
- type,
302
- size,
303
- aspectRatio,
304
- confidence: Math.min(1, confidence),
305
- framePercentage
306
- };
307
- };
308
- export { isBlurry, isFrameBright, getAverageBrightness, getCircularRegionBrightness, isCircularRegionBright, getRegionBrightness, calculateExposureStep, getScanAreaCenterPoint, detectDocumentInFrame, DOCUMENT_DIMENSIONS };
@@ -1,133 +0,0 @@
1
- "use strict";
2
-
3
- import { ColorConversionCodes, DataTypes, ObjectType, OpenCV } from 'react-native-fast-opencv';
4
- import { ENHANCEMENT_CONFIG } from "../Config/camera-enhancement.config.js";
5
-
6
- // Cast OpenCV for methods not in type definitions
7
- const OpenCVAny = OpenCV;
8
-
9
- /**
10
- * Convert YUV frame to BGR Mat for OpenCV processing
11
- */
12
- const convertYUVToBGR = frame => {
13
- 'worklet';
14
-
15
- const buffer = frame.toArrayBuffer();
16
- const data = new Uint8Array(buffer);
17
- const width = frame.width;
18
- const height = frame.height;
19
-
20
- // Create YUV Mat from frame buffer
21
- const yuvMat = OpenCV.createObject(ObjectType.Mat, height + height / 2, width, DataTypes.CV_8UC1);
22
-
23
- // Copy frame data to YUV Mat
24
- OpenCVAny.invoke('matSetData', yuvMat, data);
25
-
26
- // Convert YUV to BGR
27
- const bgrMat = OpenCV.createObject(ObjectType.Mat, height, width, DataTypes.CV_8UC3);
28
- OpenCV.invoke('cvtColor', yuvMat, bgrMat, ColorConversionCodes.COLOR_YUV2BGR_NV21);
29
- return bgrMat;
30
- };
31
-
32
- /**
33
- * Apply CLAHE (Contrast Limited Adaptive Histogram Equalization) to enhance frame
34
- * This improves text and face recognition in varying lighting conditions
35
- */
36
- const enhanceFrameForOCR = (frame, options) => {
37
- 'worklet';
38
-
39
- const clipLimit = options?.clipLimit ?? ENHANCEMENT_CONFIG.contrast.clahe.clipLimit;
40
- const tileGridSize = options?.tileGridSize ?? ENHANCEMENT_CONFIG.contrast.clahe.tileGridSize[0];
41
- try {
42
- // 1. Convert YUV to BGR
43
- const bgrMat = convertYUVToBGR(frame);
44
-
45
- // 2. Convert BGR to LAB color space (better for luminance enhancement)
46
- const labMat = OpenCV.createObject(ObjectType.Mat, frame.height, frame.width, DataTypes.CV_8UC3);
47
- OpenCV.invoke('cvtColor', bgrMat, labMat, ColorConversionCodes.COLOR_BGR2Lab);
48
-
49
- // 3. Split LAB channels
50
- const channels = OpenCVAny.invoke('split', labMat);
51
- const lChannel = channels[0]; // Luminance channel
52
- const aChannel = channels[1]; // a channel
53
- const bChannel = channels[2]; // b channel
54
-
55
- // 4. Apply CLAHE to L channel
56
- const clahe = OpenCVAny.invoke('createCLAHE', clipLimit, [tileGridSize, tileGridSize]);
57
- const enhancedL = OpenCV.createObject(ObjectType.Mat, frame.height, frame.width, DataTypes.CV_8UC1);
58
- OpenCVAny.invoke('apply', clahe, lChannel, enhancedL);
59
-
60
- // 5. Merge enhanced L channel with original a and b channels
61
- const enhancedLab = OpenCVAny.invoke('merge', [enhancedL, aChannel, bChannel]);
62
-
63
- // 6. Convert back to BGR
64
- const enhancedBGR = OpenCV.createObject(ObjectType.Mat, frame.height, frame.width, DataTypes.CV_8UC3);
65
- OpenCV.invoke('cvtColor', enhancedLab, enhancedBGR, ColorConversionCodes.COLOR_Lab2BGR);
66
-
67
- // Cleanup intermediate Mats
68
- OpenCVAny.invoke('delete', bgrMat);
69
- OpenCVAny.invoke('delete', labMat);
70
- OpenCVAny.invoke('delete', lChannel);
71
- OpenCVAny.invoke('delete', aChannel);
72
- OpenCVAny.invoke('delete', bChannel);
73
- OpenCVAny.invoke('delete', enhancedL);
74
- OpenCVAny.invoke('delete', enhancedLab);
75
- return enhancedBGR;
76
- } catch (error) {
77
- console.warn('Error enhancing frame:', error);
78
- // Return original frame converted to BGR if enhancement fails
79
- return convertYUVToBGR(frame);
80
- }
81
- };
82
-
83
- /**
84
- * Apply sharpening to enhance text clarity
85
- * Uses unsharp mask technique
86
- */
87
- const sharpenForText = (mat, amount = 1.5) => {
88
- 'worklet';
89
-
90
- try {
91
- const blurred = OpenCV.createObject(ObjectType.Mat, 0, 0, DataTypes.CV_8UC3);
92
-
93
- // Apply Gaussian blur
94
- OpenCVAny.invoke('GaussianBlur', mat, blurred, [0, 0], 3.0);
95
-
96
- // Create sharpened image: original * (1 + amount) - blurred * amount
97
- const sharpened = OpenCV.createObject(ObjectType.Mat, 0, 0, DataTypes.CV_8UC3);
98
- OpenCV.invoke('addWeighted', mat, 1.0 + amount, blurred, -amount, 0, sharpened);
99
-
100
- // Cleanup
101
- OpenCVAny.invoke('delete', blurred);
102
- return sharpened;
103
- } catch (error) {
104
- console.warn('Error sharpening frame:', error);
105
- return mat;
106
- }
107
- };
108
-
109
- /**
110
- * Determine if frame should be enhanced based on current scanning state
111
- */
112
- const shouldEnhanceFrame = (nextStep, detectedFaces, mrzRetryCount) => {
113
- 'worklet';
114
-
115
- const config = ENHANCEMENT_CONFIG.contrast.applyWhen;
116
-
117
- // Always enhance for document back side (MRZ scanning)
118
- if (config.documentBackSide && nextStep === 'SCAN_ID_BACK') {
119
- return true;
120
- }
121
-
122
- // Enhance if faces are failing to detect on front/passport
123
- if (config.faceFailing && nextStep === 'SCAN_ID_FRONT_OR_PASSPORT' && detectedFaces === 0) {
124
- return true;
125
- }
126
-
127
- // Enhance if MRZ detection is failing
128
- if (config.mrzFailing && mrzRetryCount >= config.retryThreshold) {
129
- return true;
130
- }
131
- return false;
132
- };
133
- export { convertYUVToBGR, enhanceFrameForOCR, sharpenForText, shouldEnhanceFrame };
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- import { ColorConversionCodes, DataTypes, ObjectType, OpenCV } from 'react-native-fast-opencv';
4
- const isImageBright = (width, height, frameBuffer) => {
5
- 'worklet';
6
-
7
- try {
8
- const imageMat = OpenCV.frameBufferToMat(height, width, 3, frameBuffer);
9
- const grayMat = OpenCV.createObject(ObjectType.Mat, 0, 0, DataTypes.CV_8U);
10
- OpenCV.invoke('cvtColor', imageMat, grayMat, ColorConversionCodes.COLOR_BGR2GRAY);
11
- const meanMat = OpenCV.createObject(ObjectType.Mat, 0, 0, DataTypes.CV_64F);
12
- const stdDevMat = OpenCV.createObject(ObjectType.Mat, 0, 0, DataTypes.CV_64F);
13
- OpenCV.invoke('meanStdDev', grayMat, meanMat, stdDevMat);
14
- const minMax = OpenCV.invoke('minMaxLoc', meanMat);
15
- return minMax.maxVal >= 90;
16
- } catch (e) {
17
- // console.log('error', e);
18
- }
19
- return false;
20
- };
21
- export { isImageBright };
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- import { Worklets } from 'react-native-worklets-core';
4
-
5
- /**
6
- * A synchronized Shared Value to indicate whether the async context is currently executing
7
- */
8
- let isAsyncContextBusy;
9
-
10
- /**
11
- * Runs the given function on the async context, and sets isAsyncContextBusy to false after it finished executing.
12
- */
13
- let runOnAsyncContext;
14
- try {
15
- isAsyncContextBusy = Worklets.createSharedValue(false);
16
- const asyncContext = Worklets.defaultContext;
17
- runOnAsyncContext = asyncContext.createRunAsync((frame, func) => {
18
- 'worklet';
19
-
20
- try {
21
- // Call long-running function
22
- func();
23
- } catch (e) {
24
- // Re-throw error on JS Thread
25
- throw e;
26
- } finally {
27
- // Potentially delete Frame if we were the last ref
28
- const internal = frame;
29
- internal.decrementRefCount();
30
-
31
- // free up async context again, new calls can be made
32
- isAsyncContextBusy.value = false;
33
- }
34
- });
35
- } catch (e) {
36
- // react-native-worklets-core is not installed!
37
- // Just use dummy implementations that will throw when the user tries to use Frame Processors.
38
- isAsyncContextBusy = {
39
- value: false
40
- };
41
- runOnAsyncContext = () => {
42
- throw new Error('react-native-worklets-core is not installed! Please install it to use Frame Processors.');
43
- };
44
- }
45
-
46
- /**
47
- * Runs the given func asynchronously on a separate thread,
48
- * allowing the Frame Processor to continue executing without dropping a Frame.
49
- *
50
- * @note This is a custom implementation. For most cases, use runAsync from react-native-vision-camera.
51
- */
52
- export function runAsync(frame, func) {
53
- 'worklet';
54
-
55
- if (isAsyncContextBusy.value) {
56
- // async context is currently busy, we cannot schedule new work in time.
57
- // drop this frame/runAsync call.
58
- return;
59
- }
60
-
61
- // Increment ref count by one
62
- const internal = frame;
63
- internal.incrementRefCount();
64
- isAsyncContextBusy.value = true;
65
-
66
- // Call in separate background context
67
- runOnAsyncContext(frame, func);
68
- }