@arfuhad/react-native-smart-camera 0.1.2 → 0.1.5

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 (265) hide show
  1. package/CHANGELOG.md +75 -3
  2. package/README.md +259 -206
  3. package/android/build.gradle +14 -39
  4. package/android/src/main/java/com/smartcamera/FaceDetectorFrameProcessorPlugin.kt +324 -0
  5. package/android/src/main/java/com/smartcamera/SmartCameraPackage.kt +28 -0
  6. package/build/detection/blinkProcessor.js +2 -1
  7. package/build/detection/blinkProcessor.js.map +1 -1
  8. package/build/detection/faceDetector.d.ts +4 -4
  9. package/build/detection/faceDetector.d.ts.map +1 -1
  10. package/build/detection/faceDetector.js +31 -11
  11. package/build/detection/faceDetector.js.map +1 -1
  12. package/build/detection/index.d.ts +1 -1
  13. package/build/detection/index.d.ts.map +1 -1
  14. package/build/detection/index.js +1 -1
  15. package/build/detection/index.js.map +1 -1
  16. package/build/detection/staticImageDetector.d.ts +11 -11
  17. package/build/detection/staticImageDetector.d.ts.map +1 -1
  18. package/build/detection/staticImageDetector.js +19 -23
  19. package/build/detection/staticImageDetector.js.map +1 -1
  20. package/build/hooks/index.d.ts +6 -0
  21. package/build/hooks/index.d.ts.map +1 -1
  22. package/build/hooks/index.js +8 -0
  23. package/build/hooks/index.js.map +1 -1
  24. package/build/hooks/useBlinkDetection.d.ts +27 -16
  25. package/build/hooks/useBlinkDetection.d.ts.map +1 -1
  26. package/build/hooks/useBlinkDetection.js +63 -37
  27. package/build/hooks/useBlinkDetection.js.map +1 -1
  28. package/build/hooks/useFaceDetection.js +3 -2
  29. package/build/hooks/useFaceDetection.js.map +1 -1
  30. package/build/hooks/useFaceDetector.d.ts +123 -0
  31. package/build/hooks/useFaceDetector.d.ts.map +1 -0
  32. package/build/hooks/useFaceDetector.js +133 -0
  33. package/build/hooks/useFaceDetector.js.map +1 -0
  34. package/build/hooks/useSmartCamera.js.map +1 -1
  35. package/build/hooks/useSmartCameraWebRTC.d.ts +3 -5
  36. package/build/hooks/useSmartCameraWebRTC.d.ts.map +1 -1
  37. package/build/hooks/useSmartCameraWebRTC.js +19 -87
  38. package/build/hooks/useSmartCameraWebRTC.js.map +1 -1
  39. package/build/hooks/useWebRTC.d.ts +88 -0
  40. package/build/hooks/useWebRTC.d.ts.map +1 -0
  41. package/build/hooks/useWebRTC.js +394 -0
  42. package/build/hooks/useWebRTC.js.map +1 -0
  43. package/build/hooks/useWebRTCWithDetection.d.ts +89 -0
  44. package/build/hooks/useWebRTCWithDetection.d.ts.map +1 -0
  45. package/build/hooks/useWebRTCWithDetection.js +131 -0
  46. package/build/hooks/useWebRTCWithDetection.js.map +1 -0
  47. package/build/index.d.ts +24 -10
  48. package/build/index.d.ts.map +1 -1
  49. package/build/index.js +38 -13
  50. package/build/index.js.map +1 -1
  51. package/build/types.d.ts +28 -12
  52. package/build/types.d.ts.map +1 -1
  53. package/build/types.js.map +1 -1
  54. package/build/utils/index.js.map +1 -1
  55. package/build/webrtc/WebRTCBridge.d.ts +3 -0
  56. package/build/webrtc/WebRTCBridge.d.ts.map +1 -1
  57. package/build/webrtc/WebRTCBridge.js +12 -15
  58. package/build/webrtc/WebRTCBridge.js.map +1 -1
  59. package/build/webrtc/WebRTCManager.d.ts +148 -0
  60. package/build/webrtc/WebRTCManager.d.ts.map +1 -0
  61. package/build/webrtc/WebRTCManager.js +383 -0
  62. package/build/webrtc/WebRTCManager.js.map +1 -0
  63. package/build/webrtc/index.d.ts +3 -1
  64. package/build/webrtc/index.d.ts.map +1 -1
  65. package/build/webrtc/index.js +5 -0
  66. package/build/webrtc/index.js.map +1 -1
  67. package/build/webrtc/types.d.ts +212 -4
  68. package/build/webrtc/types.d.ts.map +1 -1
  69. package/build/webrtc/types.js +34 -1
  70. package/build/webrtc/types.js.map +1 -1
  71. package/ios/FaceDetectorFrameProcessorPlugin.m +11 -0
  72. package/ios/FaceDetectorFrameProcessorPlugin.swift +304 -0
  73. package/package.json +11 -11
  74. package/react-native-smart-camera.podspec +32 -0
  75. package/src/detection/blinkProcessor.ts +127 -0
  76. package/src/detection/faceDetector.ts +78 -0
  77. package/src/detection/index.ts +3 -0
  78. package/src/detection/staticImageDetector.ts +53 -0
  79. package/src/hooks/index.ts +26 -0
  80. package/src/hooks/useBlinkDetection.ts +127 -0
  81. package/src/hooks/useFaceDetection.ts +105 -0
  82. package/src/hooks/useFaceDetector.ts +191 -0
  83. package/src/hooks/useSmartCamera.ts +83 -0
  84. package/src/hooks/useSmartCameraWebRTC.ts +120 -0
  85. package/src/hooks/useWebRTC.ts +453 -0
  86. package/src/hooks/useWebRTCWithDetection.ts +181 -0
  87. package/src/index.ts +170 -0
  88. package/src/types.ts +636 -0
  89. package/src/utils/index.ts +355 -0
  90. package/src/webrtc/WebRTCBridge.ts +127 -0
  91. package/src/webrtc/WebRTCManager.ts +453 -0
  92. package/src/webrtc/index.ts +50 -0
  93. package/src/webrtc/types.ts +361 -0
  94. package/android/build/.transforms/e0a0b120a9ccc3a8de4f5784bc36b161/results.bin +0 -1
  95. package/android/build/.transforms/e0a0b120a9ccc3a8de4f5784bc36b161/transformed/classes/classes_dex/classes.dex +0 -0
  96. package/android/build/generated/source/buildConfig/debug/expo/modules/smartcamera/BuildConfig.java +0 -10
  97. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -7
  98. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
  99. package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -6
  100. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
  101. package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
  102. package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
  103. package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -0
  104. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
  105. package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
  106. package/android/build/intermediates/java_res/debug/out/META-INF/arfuhad-react-native-smart-camera_debug.kotlin_module +0 -0
  107. package/android/build/intermediates/javac/debug/classes/expo/modules/smartcamera/BuildConfig.class +0 -0
  108. package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
  109. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -7
  110. package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -7
  111. package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
  112. package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
  113. package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -1
  114. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  115. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
  116. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
  117. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
  118. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  119. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
  120. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
  121. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  122. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  123. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  124. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  125. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  126. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  127. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
  128. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  129. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  130. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  131. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  132. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  133. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  134. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
  135. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  136. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  137. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  138. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  139. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  140. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  141. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
  142. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab +0 -0
  143. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream +0 -0
  144. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream.len +0 -0
  145. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.len +0 -0
  146. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.values.at +0 -0
  147. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i +0 -0
  148. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i.len +0 -0
  149. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  150. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  151. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  152. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  153. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  154. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  155. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
  156. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  157. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
  158. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
  159. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
  160. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  161. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
  162. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
  163. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  164. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
  165. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
  166. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
  167. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  168. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
  169. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
  170. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  171. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  172. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  173. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
  174. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  175. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  176. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
  177. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
  178. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
  179. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
  180. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
  181. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
  182. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  183. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
  184. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
  185. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
  186. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
  187. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  188. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
  189. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  190. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
  191. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
  192. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  193. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  194. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  195. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  196. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  197. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  198. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
  199. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  200. package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
  201. package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
  202. package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -16
  203. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  204. package/android/build/tmp/kotlin-classes/debug/META-INF/arfuhad-react-native-smart-camera_debug.kotlin_module +0 -0
  205. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/DetectedFace.class +0 -0
  206. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceBounds.class +0 -0
  207. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceContoursData.class +0 -0
  208. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceDetectionOptions.class +0 -0
  209. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceLandmarksData.class +0 -0
  210. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader$Companion.class +0 -0
  211. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader$loadImage$2.class +0 -0
  212. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader.class +0 -0
  213. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector$detectFaces$2$1.class +0 -0
  214. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector$detectFaces$2$2.class +0 -0
  215. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector.class +0 -0
  216. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetectorKt$sam$com_google_android_gms_tasks_OnSuccessListener$0.class +0 -0
  217. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetectorKt.class +0 -0
  218. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/PointData.class +0 -0
  219. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$Companion.class +0 -0
  220. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$1$1.class +0 -0
  221. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$3$1.class +0 -0
  222. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$4$1.class +0 -0
  223. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$1.class +0 -0
  224. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$2.class +0 -0
  225. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$3.class +0 -0
  226. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$1.class +0 -0
  227. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$2.class +0 -0
  228. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$3.class +0 -0
  229. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$4.class +0 -0
  230. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$1.class +0 -0
  231. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$2.class +0 -0
  232. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$3.class +0 -0
  233. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$4.class +0 -0
  234. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$FunctionWithoutArgs$1.class +0 -0
  235. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$FunctionWithoutArgs$2.class +0 -0
  236. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnActivityEntersBackground$1.class +0 -0
  237. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnActivityEntersForeground$1.class +0 -0
  238. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnDestroy$1.class +0 -0
  239. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule.class +0 -0
  240. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraView.class +0 -0
  241. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/WebRTCFrameBridge$Companion.class +0 -0
  242. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/WebRTCFrameBridge.class +0 -0
  243. package/android/src/main/java/expo/modules/smartcamera/ImageLoader.kt +0 -106
  244. package/android/src/main/java/expo/modules/smartcamera/MLKitFaceDetector.kt +0 -273
  245. package/android/src/main/java/expo/modules/smartcamera/SmartCameraModule.kt +0 -205
  246. package/android/src/main/java/expo/modules/smartcamera/SmartCameraView.kt +0 -153
  247. package/android/src/main/java/expo/modules/smartcamera/WebRTCFrameBridge.kt +0 -184
  248. package/build/SmartCamera.d.ts +0 -17
  249. package/build/SmartCamera.d.ts.map +0 -1
  250. package/build/SmartCamera.js +0 -270
  251. package/build/SmartCamera.js.map +0 -1
  252. package/build/SmartCameraModule.d.ts +0 -112
  253. package/build/SmartCameraModule.d.ts.map +0 -1
  254. package/build/SmartCameraModule.js +0 -121
  255. package/build/SmartCameraModule.js.map +0 -1
  256. package/build/SmartCameraView.d.ts +0 -8
  257. package/build/SmartCameraView.d.ts.map +0 -1
  258. package/build/SmartCameraView.js +0 -7
  259. package/build/SmartCameraView.js.map +0 -1
  260. package/expo-module.config.json +0 -9
  261. package/ios/MLKitFaceDetector.swift +0 -310
  262. package/ios/SmartCamera.podspec +0 -33
  263. package/ios/SmartCameraModule.swift +0 -225
  264. package/ios/SmartCameraView.swift +0 -146
  265. package/ios/WebRTCFrameBridge.swift +0 -150
@@ -1,4 +1,3 @@
1
- import SmartCameraModule from '../SmartCameraModule';
2
1
  /**
3
2
  * Default options for static image face detection
4
3
  */
@@ -13,36 +12,33 @@ const DEFAULT_OPTIONS = {
13
12
  /**
14
13
  * Detect faces in a static image
15
14
  *
15
+ * NOTE: Static image detection is currently not supported in the frame processor-only version.
16
+ * This feature requires native module implementation.
17
+ * For real-time face detection, use the `detectFaces` function with VisionCamera frame processor.
18
+ *
16
19
  * @param options - Image source and detection options
17
20
  * @returns Promise resolving to array of detected faces
18
21
  *
19
22
  * @example
20
23
  * ```tsx
21
- * // Using require
22
- * const faces = await detectFacesInImage({
23
- * image: require('./photo.jpg'),
24
- * performanceMode: 'accurate',
25
- * landmarkMode: 'all',
26
- * });
24
+ * // This feature is not yet implemented
25
+ * // For real-time detection, use:
26
+ * import { detectFaces } from '@arfuhad/react-native-smart-camera';
27
27
  *
28
- * // Using URI
29
- * const faces = await detectFacesInImage({
30
- * image: { uri: 'https://example.com/photo.jpg' },
31
- * classificationMode: 'all',
32
- * });
28
+ * const frameProcessor = useFrameProcessor((frame) => {
29
+ * 'worklet';
30
+ * const faces = detectFaces(frame);
31
+ * }, []);
33
32
  * ```
34
33
  */
35
34
  export async function detectFacesInImage(options) {
36
- const mergedOptions = {
37
- ...DEFAULT_OPTIONS,
38
- ...options,
39
- };
40
- try {
41
- return await SmartCameraModule.detectFacesInImage(mergedOptions);
42
- }
43
- catch (error) {
44
- console.error('[SmartCamera] Error detecting faces in image:', error);
45
- throw error;
46
- }
35
+ const mergedOptions = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
36
+ // TODO: Implement static image detection
37
+ // This requires either:
38
+ // 1. A separate native module for static image processing
39
+ // 2. Using react-native-ml-kit directly
40
+ console.warn('[SmartCamera] Static image detection is not yet implemented. ' +
41
+ 'For real-time face detection, use the detectFaces function with VisionCamera frame processor.');
42
+ return [];
47
43
  }
48
44
  //# sourceMappingURL=staticImageDetector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"staticImageDetector.js","sourceRoot":"","sources":["../../src/detection/staticImageDetector.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAGrD;;GAEG;AACH,MAAM,eAAe,GAAgC;IACnD,eAAe,EAAE,UAAU;IAC3B,YAAY,EAAE,MAAM;IACpB,WAAW,EAAE,MAAM;IACnB,kBAAkB,EAAE,MAAM;IAC1B,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE,KAAK;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAA2B;IAClE,MAAM,aAAa,GAAuB;QACxC,GAAG,eAAe;QAClB,GAAG,OAAO;KACX,CAAC;IAEF,IAAI,CAAC;QACH,OAAO,MAAM,iBAAiB,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;IACnE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;QACtE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import SmartCameraModule from '../SmartCameraModule';\nimport type { Face, StaticImageOptions } from '../types';\n\n/**\n * Default options for static image face detection\n */\nconst DEFAULT_OPTIONS: Partial<StaticImageOptions> = {\n performanceMode: 'accurate',\n landmarkMode: 'none',\n contourMode: 'none',\n classificationMode: 'none',\n minFaceSize: 0.15,\n trackingEnabled: false,\n};\n\n/**\n * Detect faces in a static image\n * \n * @param options - Image source and detection options\n * @returns Promise resolving to array of detected faces\n * \n * @example\n * ```tsx\n * // Using require\n * const faces = await detectFacesInImage({\n * image: require('./photo.jpg'),\n * performanceMode: 'accurate',\n * landmarkMode: 'all',\n * });\n * \n * // Using URI\n * const faces = await detectFacesInImage({\n * image: { uri: 'https://example.com/photo.jpg' },\n * classificationMode: 'all',\n * });\n * ```\n */\nexport async function detectFacesInImage(options: StaticImageOptions): Promise<Face[]> {\n const mergedOptions: StaticImageOptions = {\n ...DEFAULT_OPTIONS,\n ...options,\n };\n\n try {\n return await SmartCameraModule.detectFacesInImage(mergedOptions);\n } catch (error) {\n console.error('[SmartCamera] Error detecting faces in image:', error);\n throw error;\n }\n}\n\n"]}
1
+ {"version":3,"file":"staticImageDetector.js","sourceRoot":"","sources":["../../src/detection/staticImageDetector.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,eAAe,GAAgC;IACnD,eAAe,EAAE,UAAU;IAC3B,YAAY,EAAE,MAAM;IACpB,WAAW,EAAE,MAAM;IACnB,kBAAkB,EAAE,MAAM;IAC1B,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE,KAAK;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAA2B;IAClE,MAAM,aAAa,mCACd,eAAe,GACf,OAAO,CACX,CAAC;IAEF,yCAAyC;IACzC,wBAAwB;IACxB,0DAA0D;IAC1D,wCAAwC;IACxC,OAAO,CAAC,IAAI,CACV,+DAA+D;QAC/D,+FAA+F,CAChG,CAAC;IAEF,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -1,5 +1,11 @@
1
1
  export { useSmartCamera, getAvailableCameras } from './useSmartCamera';
2
2
  export { useFaceDetection, type UseFaceDetectionOptions } from './useFaceDetection';
3
+ export { useFaceDetector, useFaceDetectorWithCallback, type UseFaceDetectorOptions, type UseFaceDetectorResult, type UseFaceDetectorWithCallbackOptions, type FaceDetectionCallback, } from './useFaceDetector';
3
4
  export { useBlinkDetection, type UseBlinkDetectionOptions } from './useBlinkDetection';
5
+ export { useWebRTC } from './useWebRTC';
6
+ export type { UseWebRTCOptions, UseWebRTCResult } from './useWebRTC';
7
+ export { useWebRTCWithDetection } from './useWebRTCWithDetection';
8
+ export type { UseWebRTCWithDetectionOptions } from './useWebRTCWithDetection';
9
+ export type { UseWebRTCWithDetectionResult } from './useWebRTCWithDetection';
4
10
  export { useSmartCameraWebRTC, type UseSmartCameraWebRTCOptions } from './useSmartCameraWebRTC';
5
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvE,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACpF,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,kCAAkC,EACvC,KAAK,qBAAqB,GAC3B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAGvF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAC9E,YAAY,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAG7E,OAAO,EAAE,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,5 +1,13 @@
1
+ // Camera management
1
2
  export { useSmartCamera, getAvailableCameras } from './useSmartCamera';
3
+ // Face detection
2
4
  export { useFaceDetection } from './useFaceDetection';
5
+ export { useFaceDetector, useFaceDetectorWithCallback, } from './useFaceDetector';
6
+ // Eye/Blink detection
3
7
  export { useBlinkDetection } from './useBlinkDetection';
8
+ // WebRTC video calling
9
+ export { useWebRTC } from './useWebRTC';
10
+ export { useWebRTCWithDetection } from './useWebRTCWithDetection';
11
+ // Legacy WebRTC hook (deprecated, use useWebRTC instead)
4
12
  export { useSmartCameraWebRTC } from './useSmartCameraWebRTC';
5
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAgC,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAiC,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAoC,MAAM,wBAAwB,CAAC","sourcesContent":["export { useSmartCamera, getAvailableCameras } from './useSmartCamera';\nexport { useFaceDetection, type UseFaceDetectionOptions } from './useFaceDetection';\nexport { useBlinkDetection, type UseBlinkDetectionOptions } from './useBlinkDetection';\nexport { useSmartCameraWebRTC, type UseSmartCameraWebRTCOptions } from './useSmartCameraWebRTC';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,iBAAiB;AACjB,OAAO,EAAE,gBAAgB,EAAgC,MAAM,oBAAoB,CAAC;AACpF,OAAO,EACL,eAAe,EACf,2BAA2B,GAK5B,MAAM,mBAAmB,CAAC;AAE3B,sBAAsB;AACtB,OAAO,EAAE,iBAAiB,EAAiC,MAAM,qBAAqB,CAAC;AAEvF,uBAAuB;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,yDAAyD;AACzD,OAAO,EAAE,oBAAoB,EAAoC,MAAM,wBAAwB,CAAC"}
@@ -1,35 +1,46 @@
1
- import type { BlinkEvent, UseBlinkDetectionResult } from '../types';
1
+ import type { EyeStatusResult, UseBlinkDetectionResult } from '../types';
2
2
  /**
3
3
  * Options for useBlinkDetection hook
4
4
  */
5
5
  export interface UseBlinkDetectionOptions {
6
- /** Whether blink detection is enabled. Default: true */
6
+ /** Whether eye tracking is enabled. Default: true */
7
7
  enabled?: boolean;
8
- /** Minimum time between blinks in milliseconds. Default: 300 */
9
- debounceMs?: number;
10
- /** Callback when a blink is detected */
11
- onBlink?: (event: BlinkEvent) => void;
8
+ /** Threshold below which an eye is considered closed (0-1). Default: 0.5 */
9
+ eyeClosedThreshold?: number;
10
+ /** Callback when eye status changes */
11
+ onEyeStatusChange?: (status: EyeStatusResult) => void;
12
12
  }
13
13
  /**
14
- * Hook for managing blink detection state
14
+ * Hook for tracking eye status from detected faces
15
15
  *
16
- * @param options - Blink detection options
17
- * @returns Blink detection state and controls
16
+ * This hook provides real-time eye open/closed status based on face detection results.
17
+ * The user can set their own threshold for determining when an eye is considered closed.
18
+ *
19
+ * @param options - Eye tracking options
20
+ * @returns Eye status and controls
18
21
  *
19
22
  * @example
20
23
  * ```tsx
21
- * function BlinkCounter() {
22
- * const { lastBlink, blinkCount, resetCount } = useBlinkDetection({
23
- * debounceMs: 300,
24
- * onBlink: (event) => {
25
- * console.log('Blink detected at', event.timestamp);
24
+ * function EyeTracker() {
25
+ * const { eyeStatus, processEyeStatus } = useBlinkDetection({
26
+ * eyeClosedThreshold: 0.3, // Consider eye closed when probability < 0.3
27
+ * onEyeStatusChange: (status) => {
28
+ * // Handle blink detection yourself based on status
29
+ * if (status.leftEye.isClosed && status.rightEye.isClosed) {
30
+ * console.log('Both eyes closed!');
31
+ * }
26
32
  * },
27
33
  * });
28
34
  *
35
+ * // In your face detection callback:
36
+ * const handleFaces = (faces: Face[]) => {
37
+ * processEyeStatus(faces);
38
+ * };
39
+ *
29
40
  * return (
30
41
  * <View>
31
- * <Text>Blinks: {blinkCount}</Text>
32
- * <Button onPress={resetCount} title="Reset" />
42
+ * <Text>Left Eye: {eyeStatus?.leftEye.openProbability.toFixed(2)}</Text>
43
+ * <Text>Right Eye: {eyeStatus?.rightEye.openProbability.toFixed(2)}</Text>
33
44
  * </View>
34
45
  * );
35
46
  * }
@@ -1 +1 @@
1
- {"version":3,"file":"useBlinkDetection.d.ts","sourceRoot":"","sources":["../../src/hooks/useBlinkDetection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,wCAAwC;IACxC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,wBAA6B,GACrC,uBAAuB,CA+CzB"}
1
+ {"version":3,"file":"useBlinkDetection.d.ts","sourceRoot":"","sources":["../../src/hooks/useBlinkDetection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,eAAe,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,qDAAqD;IACrD,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,4EAA4E;IAC5E,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,uCAAuC;IACvC,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CACvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,wBAA6B,GACrC,uBAAuB,CAsEzB"}
@@ -1,67 +1,93 @@
1
1
  import { useState, useCallback, useRef, useEffect } from 'react';
2
2
  /**
3
- * Hook for managing blink detection state
3
+ * Hook for tracking eye status from detected faces
4
4
  *
5
- * @param options - Blink detection options
6
- * @returns Blink detection state and controls
5
+ * This hook provides real-time eye open/closed status based on face detection results.
6
+ * The user can set their own threshold for determining when an eye is considered closed.
7
+ *
8
+ * @param options - Eye tracking options
9
+ * @returns Eye status and controls
7
10
  *
8
11
  * @example
9
12
  * ```tsx
10
- * function BlinkCounter() {
11
- * const { lastBlink, blinkCount, resetCount } = useBlinkDetection({
12
- * debounceMs: 300,
13
- * onBlink: (event) => {
14
- * console.log('Blink detected at', event.timestamp);
13
+ * function EyeTracker() {
14
+ * const { eyeStatus, processEyeStatus } = useBlinkDetection({
15
+ * eyeClosedThreshold: 0.3, // Consider eye closed when probability < 0.3
16
+ * onEyeStatusChange: (status) => {
17
+ * // Handle blink detection yourself based on status
18
+ * if (status.leftEye.isClosed && status.rightEye.isClosed) {
19
+ * console.log('Both eyes closed!');
20
+ * }
15
21
  * },
16
22
  * });
17
23
  *
24
+ * // In your face detection callback:
25
+ * const handleFaces = (faces: Face[]) => {
26
+ * processEyeStatus(faces);
27
+ * };
28
+ *
18
29
  * return (
19
30
  * <View>
20
- * <Text>Blinks: {blinkCount}</Text>
21
- * <Button onPress={resetCount} title="Reset" />
31
+ * <Text>Left Eye: {eyeStatus?.leftEye.openProbability.toFixed(2)}</Text>
32
+ * <Text>Right Eye: {eyeStatus?.rightEye.openProbability.toFixed(2)}</Text>
22
33
  * </View>
23
34
  * );
24
35
  * }
25
36
  * ```
26
37
  */
27
38
  export function useBlinkDetection(options = {}) {
28
- const { enabled = true, debounceMs = 300, onBlink } = options;
29
- const [lastBlink, setLastBlink] = useState(null);
30
- const [blinkCount, setBlinkCount] = useState(0);
31
- const callbackRef = useRef(onBlink);
32
- const lastBlinkTimeRef = useRef(0);
39
+ const { enabled = true, eyeClosedThreshold = 0.5, onEyeStatusChange } = options;
40
+ const [eyeStatus, setEyeStatus] = useState(null);
41
+ const callbackRef = useRef(onEyeStatusChange);
33
42
  // Keep callback ref updated
34
43
  useEffect(() => {
35
- callbackRef.current = onBlink;
36
- }, [onBlink]);
37
- // Handle blink event (called from frame processor)
38
- const handleBlink = useCallback((event) => {
39
- const now = Date.now();
40
- // Apply debounce
41
- if (now - lastBlinkTimeRef.current < debounceMs) {
44
+ callbackRef.current = onEyeStatusChange;
45
+ }, [onEyeStatusChange]);
46
+ // Process faces to get eye status (call this from JS thread with detected faces)
47
+ const processEyeStatus = useCallback((faces) => {
48
+ var _a;
49
+ if (!enabled || faces.length === 0) {
42
50
  return;
43
51
  }
44
- lastBlinkTimeRef.current = now;
45
- setLastBlink(event);
46
- setBlinkCount((prev) => prev + 1);
47
- callbackRef.current?.(event);
48
- }, [debounceMs]);
49
- // Reset blink count
50
- const resetCount = useCallback(() => {
51
- setBlinkCount(0);
52
- setLastBlink(null);
53
- lastBlinkTimeRef.current = 0;
52
+ // Use the first face (most prominent)
53
+ const face = faces[0];
54
+ // Ensure we have eye classification data
55
+ if (face.leftEyeOpenProbability === undefined ||
56
+ face.rightEyeOpenProbability === undefined) {
57
+ return;
58
+ }
59
+ const leftOpenProbability = face.leftEyeOpenProbability;
60
+ const rightOpenProbability = face.rightEyeOpenProbability;
61
+ const now = Date.now();
62
+ const status = {
63
+ leftEye: {
64
+ openProbability: leftOpenProbability,
65
+ isClosed: leftOpenProbability < eyeClosedThreshold,
66
+ },
67
+ rightEye: {
68
+ openProbability: rightOpenProbability,
69
+ isClosed: rightOpenProbability < eyeClosedThreshold,
70
+ },
71
+ faceId: face.trackingId,
72
+ timestamp: now,
73
+ };
74
+ setEyeStatus(status);
75
+ (_a = callbackRef.current) === null || _a === void 0 ? void 0 : _a.call(callbackRef, status);
76
+ }, [enabled, eyeClosedThreshold]);
77
+ // Reset eye status
78
+ const reset = useCallback(() => {
79
+ setEyeStatus(null);
54
80
  }, []);
55
81
  // Reset on disable
56
82
  useEffect(() => {
57
83
  if (!enabled) {
58
- resetCount();
84
+ reset();
59
85
  }
60
- }, [enabled, resetCount]);
86
+ }, [enabled, reset]);
61
87
  return {
62
- lastBlink,
63
- blinkCount,
64
- resetCount,
88
+ eyeStatus,
89
+ processEyeStatus,
90
+ reset,
65
91
  };
66
92
  }
67
93
  //# sourceMappingURL=useBlinkDetection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBlinkDetection.js","sourceRoot":"","sources":["../../src/hooks/useBlinkDetection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAiBjE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAAoC,EAAE;IAEtC,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,UAAU,GAAG,GAAG,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE9D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAoB,IAAI,CAAC,CAAC;IACpE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,gBAAgB,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAEnC,4BAA4B;IAC5B,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;IAChC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,mDAAmD;IACnD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,KAAiB,EAAE,EAAE;QACpD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,iBAAiB;QACjB,IAAI,GAAG,GAAG,gBAAgB,CAAC,OAAO,GAAG,UAAU,EAAE,CAAC;YAChD,OAAO;QACT,CAAC;QAED,gBAAgB,CAAC,OAAO,GAAG,GAAG,CAAC;QAC/B,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,aAAa,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;QAClC,WAAW,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,oBAAoB;IACpB,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;QAClC,aAAa,CAAC,CAAC,CAAC,CAAC;QACjB,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,gBAAgB,CAAC,OAAO,GAAG,CAAC,CAAC;IAC/B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,mBAAmB;IACnB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;IAE1B,OAAO;QACL,SAAS;QACT,UAAU;QACV,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["import { useState, useCallback, useRef, useEffect } from 'react';\nimport type { BlinkEvent, UseBlinkDetectionResult } from '../types';\n\n/**\n * Options for useBlinkDetection hook\n */\nexport interface UseBlinkDetectionOptions {\n /** Whether blink detection is enabled. Default: true */\n enabled?: boolean;\n \n /** Minimum time between blinks in milliseconds. Default: 300 */\n debounceMs?: number;\n \n /** Callback when a blink is detected */\n onBlink?: (event: BlinkEvent) => void;\n}\n\n/**\n * Hook for managing blink detection state\n * \n * @param options - Blink detection options\n * @returns Blink detection state and controls\n * \n * @example\n * ```tsx\n * function BlinkCounter() {\n * const { lastBlink, blinkCount, resetCount } = useBlinkDetection({\n * debounceMs: 300,\n * onBlink: (event) => {\n * console.log('Blink detected at', event.timestamp);\n * },\n * });\n * \n * return (\n * <View>\n * <Text>Blinks: {blinkCount}</Text>\n * <Button onPress={resetCount} title=\"Reset\" />\n * </View>\n * );\n * }\n * ```\n */\nexport function useBlinkDetection(\n options: UseBlinkDetectionOptions = {}\n): UseBlinkDetectionResult {\n const { enabled = true, debounceMs = 300, onBlink } = options;\n \n const [lastBlink, setLastBlink] = useState<BlinkEvent | null>(null);\n const [blinkCount, setBlinkCount] = useState(0);\n const callbackRef = useRef(onBlink);\n const lastBlinkTimeRef = useRef(0);\n\n // Keep callback ref updated\n useEffect(() => {\n callbackRef.current = onBlink;\n }, [onBlink]);\n\n // Handle blink event (called from frame processor)\n const handleBlink = useCallback((event: BlinkEvent) => {\n const now = Date.now();\n \n // Apply debounce\n if (now - lastBlinkTimeRef.current < debounceMs) {\n return;\n }\n \n lastBlinkTimeRef.current = now;\n setLastBlink(event);\n setBlinkCount((prev) => prev + 1);\n callbackRef.current?.(event);\n }, [debounceMs]);\n\n // Reset blink count\n const resetCount = useCallback(() => {\n setBlinkCount(0);\n setLastBlink(null);\n lastBlinkTimeRef.current = 0;\n }, []);\n\n // Reset on disable\n useEffect(() => {\n if (!enabled) {\n resetCount();\n }\n }, [enabled, resetCount]);\n\n return {\n lastBlink,\n blinkCount,\n resetCount,\n };\n}\n\n"]}
1
+ {"version":3,"file":"useBlinkDetection.js","sourceRoot":"","sources":["../../src/hooks/useBlinkDetection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAiBjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAAoC,EAAE;IAEtC,MAAM,EACJ,OAAO,GAAG,IAAI,EACd,kBAAkB,GAAG,GAAG,EACxB,iBAAiB,EAClB,GAAG,OAAO,CAAC;IAEZ,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAyB,IAAI,CAAC,CAAC;IACzE,MAAM,WAAW,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAE9C,4BAA4B;IAC5B,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,OAAO,GAAG,iBAAiB,CAAC;IAC1C,CAAC,EAAE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EAAE,CAAC;QACV,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;IAErB,OAAO;QACL,SAAS;QACT,gBAAgB;QAChB,KAAK;KACN,CAAC;AACJ,CAAC"}
@@ -43,15 +43,16 @@ export function useFaceDetection(options = {}) {
43
43
  }, [onFacesChanged]);
44
44
  // Update faces (called from frame processor via native bridge)
45
45
  const updateFaces = useCallback((newFaces) => {
46
+ var _a;
46
47
  // Limit number of faces
47
48
  const limitedFaces = newFaces.slice(0, maxFaces);
48
49
  // Only update if faces changed
49
50
  const facesChanged = limitedFaces.length !== facesRef.current.length ||
50
- limitedFaces.some((face, i) => face.trackingId !== facesRef.current[i]?.trackingId);
51
+ limitedFaces.some((face, i) => { var _a; return face.trackingId !== ((_a = facesRef.current[i]) === null || _a === void 0 ? void 0 : _a.trackingId); });
51
52
  if (facesChanged) {
52
53
  facesRef.current = limitedFaces;
53
54
  setFaces(limitedFaces);
54
- callbackRef.current?.(limitedFaces);
55
+ (_a = callbackRef.current) === null || _a === void 0 ? void 0 : _a.call(callbackRef, limitedFaces);
55
56
  }
56
57
  }, [maxFaces]);
57
58
  // Detection state management
@@ -1 +1 @@
1
- {"version":3,"file":"useFaceDetection.js","sourceRoot":"","sources":["../../src/hooks/useFaceDetection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAiBjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAmC,EAAE;IACpE,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,QAAQ,GAAG,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAEjE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;IAC/C,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GA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;IACxB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,yDAAyD;IACzD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,EAAE,CAAC;YACZ,cAAc,EAAE,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,aAAa,EAAE,CAAC;QAClB,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;IAE7C,OAAO;QACL,KAAK;QACL,WAAW;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import { useState, useCallback, useRef, useEffect } from 'react';\nimport type { Face, FaceDetectionOptions, UseFaceDetectionResult } from '../types';\n\n/**\n * Options for useFaceDetection hook\n */\nexport interface UseFaceDetectionOptions extends FaceDetectionOptions {\n /** Whether detection is enabled. Default: true */\n enabled?: boolean;\n \n /** Maximum number of faces to track. Default: 5 */\n maxFaces?: number;\n \n /** Callback when faces change */\n onFacesChanged?: (faces: Face[]) => void;\n}\n\n/**\n * Hook for managing face detection state\n * \n * Use this hook to get face detection results outside of the SmartCamera component.\n * \n * @param options - Face detection options\n * @returns Face detection state\n * \n * @example\n * ```tsx\n * function FaceTracker() {\n * const { faces, isDetecting } = useFaceDetection({\n * performanceMode: 'fast',\n * classificationMode: 'all',\n * onFacesChanged: (faces) => {\n * console.log('Detected faces:', faces.length);\n * },\n * });\n * \n * return (\n * <View>\n * <Text>Faces detected: {faces.length}</Text>\n * {faces.map((face, i) => (\n * <Text key={i}>\n * Smiling: {(face.smilingProbability ?? 0) * 100}%\n * </Text>\n * ))}\n * </View>\n * );\n * }\n * ```\n */\nexport function useFaceDetection(options: UseFaceDetectionOptions = {}): UseFaceDetectionResult {\n const { enabled = true, maxFaces = 5, onFacesChanged } = options;\n \n const [faces, setFaces] = useState<Face[]>([]);\n const [isDetecting, setIsDetecting] = useState(false);\n const facesRef = useRef<Face[]>([]);\n const callbackRef = useRef(onFacesChanged);\n\n // Keep callback ref updated\n useEffect(() => {\n callbackRef.current = onFacesChanged;\n }, [onFacesChanged]);\n\n // Update faces (called from frame processor via native bridge)\n const updateFaces = useCallback((newFaces: Face[]) => {\n // Limit number of faces\n const limitedFaces = newFaces.slice(0, maxFaces);\n \n // Only update if faces changed\n const facesChanged = \n limitedFaces.length !== facesRef.current.length ||\n limitedFaces.some((face, i) => face.trackingId !== facesRef.current[i]?.trackingId);\n \n if (facesChanged) {\n facesRef.current = limitedFaces;\n setFaces(limitedFaces);\n callbackRef.current?.(limitedFaces);\n }\n }, [maxFaces]);\n\n // Detection state management\n const startDetecting = useCallback(() => {\n setIsDetecting(true);\n }, []);\n\n const stopDetecting = useCallback(() => {\n setIsDetecting(false);\n setFaces([]);\n facesRef.current = [];\n }, []);\n\n // Effect to manage detection state based on enabled prop\n useEffect(() => {\n if (enabled) {\n startDetecting();\n } else {\n stopDetecting();\n }\n }, [enabled, startDetecting, stopDetecting]);\n\n return {\n faces,\n isDetecting,\n };\n}\n\n"]}
1
+ {"version":3,"file":"useFaceDetection.js","sourceRoot":"","sources":["../../src/hooks/useFaceDetection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAiBjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAmC,EAAE;IACpE,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,QAAQ,GAAG,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAEjE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;IAC/C,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,MAAM,CAAS,EAAE,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;IAE3C,4BAA4B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AE,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,aAAa,EAAE,CAAC;QAClB,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;IAE7C,OAAO;QACL,KAAK;QACL,WAAW;KACZ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,123 @@
1
+ import type { Frame } from 'react-native-vision-camera';
2
+ import type { Face, FaceDetectionOptions, CameraFacing } from '../types';
3
+ /**
4
+ * Face detection options for useFaceDetector hook
5
+ * Matches the API of react-native-vision-camera-face-detector
6
+ */
7
+ export interface UseFaceDetectorOptions extends FaceDetectionOptions {
8
+ /**
9
+ * Current active camera
10
+ * @default 'front'
11
+ */
12
+ cameraFacing?: CameraFacing;
13
+ /**
14
+ * Should handle auto scale on native side?
15
+ * If disabled, results are relative to frame coordinates, not screen/preview.
16
+ * Don't use this if you want to draw with Skia Frame Processor.
17
+ * @default false
18
+ */
19
+ autoMode?: boolean;
20
+ /**
21
+ * Screen width for coordinate scaling (required when autoMode is true)
22
+ * @default 1.0
23
+ */
24
+ windowWidth?: number;
25
+ /**
26
+ * Screen height for coordinate scaling (required when autoMode is true)
27
+ * @default 1.0
28
+ */
29
+ windowHeight?: number;
30
+ }
31
+ /**
32
+ * Return type for useFaceDetector hook
33
+ */
34
+ export interface UseFaceDetectorResult {
35
+ /**
36
+ * Detect faces in a frame (for use in frame processor)
37
+ */
38
+ detectFaces: (frame: Frame) => Face[];
39
+ }
40
+ /**
41
+ * Hook for face detection in VisionCamera frame processors.
42
+ *
43
+ * This hook provides a `detectFaces` function that can be used directly
44
+ * in a frame processor to detect faces in each frame.
45
+ *
46
+ * @param options - Face detection options
47
+ * @returns Object with detectFaces function
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * import { useFaceDetector } from '@arfuhad/react-native-smart-camera';
52
+ * import { useFrameProcessor } from 'react-native-vision-camera';
53
+ * import Worklets from 'react-native-worklets-core';
54
+ *
55
+ * function FaceDetectionCamera() {
56
+ * const { detectFaces } = useFaceDetector({
57
+ * performanceMode: 'fast',
58
+ * classificationMode: 'all', // Required for blink detection
59
+ * });
60
+ *
61
+ * const handleFaces = Worklets.createRunOnJS((faces: Face[]) => {
62
+ * console.log('Detected faces:', faces.length);
63
+ * // Check for blinks using leftEyeOpenProbability / rightEyeOpenProbability
64
+ * });
65
+ *
66
+ * const frameProcessor = useFrameProcessor((frame) => {
67
+ * 'worklet';
68
+ * const faces = detectFaces(frame);
69
+ * handleFaces(faces);
70
+ * }, [detectFaces, handleFaces]);
71
+ *
72
+ * return <Camera frameProcessor={frameProcessor} />;
73
+ * }
74
+ * ```
75
+ */
76
+ export declare function useFaceDetector(options?: UseFaceDetectorOptions): UseFaceDetectorResult;
77
+ /**
78
+ * Callback type for face detection
79
+ */
80
+ export type FaceDetectionCallback = (faces: Face[]) => void;
81
+ /**
82
+ * Options for useFaceDetectorWithCallback hook
83
+ */
84
+ export interface UseFaceDetectorWithCallbackOptions extends UseFaceDetectorOptions {
85
+ /**
86
+ * Callback when faces are detected
87
+ */
88
+ onFacesDetected?: FaceDetectionCallback;
89
+ }
90
+ /**
91
+ * Hook for face detection with automatic callback handling
92
+ *
93
+ * This is a convenience hook that wraps useFaceDetector and automatically
94
+ * calls your callback function when faces are detected.
95
+ *
96
+ * @param options - Face detection options with callback
97
+ * @returns Object with detectFaces function for use in frame processor
98
+ *
99
+ * @example
100
+ * ```tsx
101
+ * import { useFaceDetectorWithCallback } from '@arfuhad/react-native-smart-camera';
102
+ *
103
+ * function FaceDetectionCamera() {
104
+ * const [faces, setFaces] = useState<Face[]>([]);
105
+ *
106
+ * const { detectFaces } = useFaceDetectorWithCallback({
107
+ * classificationMode: 'all',
108
+ * onFacesDetected: (detectedFaces) => {
109
+ * setFaces(detectedFaces);
110
+ * },
111
+ * });
112
+ *
113
+ * const frameProcessor = useFrameProcessor((frame) => {
114
+ * 'worklet';
115
+ * detectFaces(frame); // Automatically calls onFacesDetected
116
+ * }, [detectFaces]);
117
+ *
118
+ * return <Camera frameProcessor={frameProcessor} />;
119
+ * }
120
+ * ```
121
+ */
122
+ export declare function useFaceDetectorWithCallback(options?: UseFaceDetectorWithCallbackOptions): UseFaceDetectorResult;
123
+ //# sourceMappingURL=useFaceDetector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFaceDetector.d.ts","sourceRoot":"","sources":["../../src/hooks/useFaceDetector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAAE,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,qBAAqB,CA4B3F;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,kCAAmC,SAAQ,sBAAsB;IAChF;;OAEG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC;CACzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,kCAAuC,GAC/C,qBAAqB,CA0BvB"}
@@ -0,0 +1,133 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { useCallback, useRef, useEffect } from 'react';
13
+ import { useRunOnJS } from 'react-native-worklets-core';
14
+ import { detectFaces } from '../detection/faceDetector';
15
+ /**
16
+ * Hook for face detection in VisionCamera frame processors.
17
+ *
18
+ * This hook provides a `detectFaces` function that can be used directly
19
+ * in a frame processor to detect faces in each frame.
20
+ *
21
+ * @param options - Face detection options
22
+ * @returns Object with detectFaces function
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * import { useFaceDetector } from '@arfuhad/react-native-smart-camera';
27
+ * import { useFrameProcessor } from 'react-native-vision-camera';
28
+ * import Worklets from 'react-native-worklets-core';
29
+ *
30
+ * function FaceDetectionCamera() {
31
+ * const { detectFaces } = useFaceDetector({
32
+ * performanceMode: 'fast',
33
+ * classificationMode: 'all', // Required for blink detection
34
+ * });
35
+ *
36
+ * const handleFaces = Worklets.createRunOnJS((faces: Face[]) => {
37
+ * console.log('Detected faces:', faces.length);
38
+ * // Check for blinks using leftEyeOpenProbability / rightEyeOpenProbability
39
+ * });
40
+ *
41
+ * const frameProcessor = useFrameProcessor((frame) => {
42
+ * 'worklet';
43
+ * const faces = detectFaces(frame);
44
+ * handleFaces(faces);
45
+ * }, [detectFaces, handleFaces]);
46
+ *
47
+ * return <Camera frameProcessor={frameProcessor} />;
48
+ * }
49
+ * ```
50
+ */
51
+ export function useFaceDetector(options = {}) {
52
+ const optionsRef = useRef(options);
53
+ // Keep options ref updated
54
+ useEffect(() => {
55
+ optionsRef.current = options;
56
+ }, [options]);
57
+ // Create detect function that uses current options
58
+ const detect = useCallback((frame) => {
59
+ 'worklet';
60
+ return detectFaces(frame, {
61
+ performanceMode: optionsRef.current.performanceMode,
62
+ landmarkMode: optionsRef.current.landmarkMode,
63
+ contourMode: optionsRef.current.contourMode,
64
+ classificationMode: optionsRef.current.classificationMode,
65
+ minFaceSize: optionsRef.current.minFaceSize,
66
+ trackingEnabled: optionsRef.current.trackingEnabled,
67
+ cameraFacing: optionsRef.current.cameraFacing,
68
+ autoMode: optionsRef.current.autoMode,
69
+ windowWidth: optionsRef.current.windowWidth,
70
+ windowHeight: optionsRef.current.windowHeight,
71
+ });
72
+ }, []);
73
+ return {
74
+ detectFaces: detect,
75
+ };
76
+ }
77
+ /**
78
+ * Hook for face detection with automatic callback handling
79
+ *
80
+ * This is a convenience hook that wraps useFaceDetector and automatically
81
+ * calls your callback function when faces are detected.
82
+ *
83
+ * @param options - Face detection options with callback
84
+ * @returns Object with detectFaces function for use in frame processor
85
+ *
86
+ * @example
87
+ * ```tsx
88
+ * import { useFaceDetectorWithCallback } from '@arfuhad/react-native-smart-camera';
89
+ *
90
+ * function FaceDetectionCamera() {
91
+ * const [faces, setFaces] = useState<Face[]>([]);
92
+ *
93
+ * const { detectFaces } = useFaceDetectorWithCallback({
94
+ * classificationMode: 'all',
95
+ * onFacesDetected: (detectedFaces) => {
96
+ * setFaces(detectedFaces);
97
+ * },
98
+ * });
99
+ *
100
+ * const frameProcessor = useFrameProcessor((frame) => {
101
+ * 'worklet';
102
+ * detectFaces(frame); // Automatically calls onFacesDetected
103
+ * }, [detectFaces]);
104
+ *
105
+ * return <Camera frameProcessor={frameProcessor} />;
106
+ * }
107
+ * ```
108
+ */
109
+ export function useFaceDetectorWithCallback(options = {}) {
110
+ const { onFacesDetected } = options, detectorOptions = __rest(options, ["onFacesDetected"]);
111
+ const { detectFaces: baseDet } = useFaceDetector(detectorOptions);
112
+ const callbackRef = useRef(onFacesDetected);
113
+ useEffect(() => {
114
+ callbackRef.current = onFacesDetected;
115
+ }, [onFacesDetected]);
116
+ // Create runOnJS callback
117
+ const handleFacesDetected = useRunOnJS((faces) => {
118
+ var _a;
119
+ (_a = callbackRef.current) === null || _a === void 0 ? void 0 : _a.call(callbackRef, faces);
120
+ }, []);
121
+ const detectWithCallback = useCallback((frame) => {
122
+ 'worklet';
123
+ const faces = baseDet(frame);
124
+ if (faces.length > 0 || callbackRef.current) {
125
+ handleFacesDetected(faces);
126
+ }
127
+ return faces;
128
+ }, [baseDet, handleFacesDetected]);
129
+ return {
130
+ detectFaces: detectWithCallback,
131
+ };
132
+ }
133
+ //# sourceMappingURL=useFaceDetector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFaceDetector.js","sourceRoot":"","sources":["../../src/hooks/useFaceDetector.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AA6CxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkC,EAAE;IAClE,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnC,2BAA2B;IAC3B,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAC/B,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,mDAAmD;IACnD,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,KAAY,EAAU,EAAE;QAClD,SAAS,CAAC;QACV,OAAO,WAAW,CAAC,KAAK,EAAE;YACxB,eAAe,EAAE,UAAU,CAAC,OAAO,CAAC,eAAe;YACnD,YAAY,EAAE,UAAU,CAAC,OAAO,CAA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