@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.
- package/CHANGELOG.md +75 -3
- package/README.md +259 -206
- package/android/build.gradle +14 -39
- package/android/src/main/java/com/smartcamera/FaceDetectorFrameProcessorPlugin.kt +324 -0
- package/android/src/main/java/com/smartcamera/SmartCameraPackage.kt +28 -0
- package/build/detection/blinkProcessor.js +2 -1
- package/build/detection/blinkProcessor.js.map +1 -1
- package/build/detection/faceDetector.d.ts +4 -4
- package/build/detection/faceDetector.d.ts.map +1 -1
- package/build/detection/faceDetector.js +31 -11
- package/build/detection/faceDetector.js.map +1 -1
- package/build/detection/index.d.ts +1 -1
- package/build/detection/index.d.ts.map +1 -1
- package/build/detection/index.js +1 -1
- package/build/detection/index.js.map +1 -1
- package/build/detection/staticImageDetector.d.ts +11 -11
- package/build/detection/staticImageDetector.d.ts.map +1 -1
- package/build/detection/staticImageDetector.js +19 -23
- package/build/detection/staticImageDetector.js.map +1 -1
- package/build/hooks/index.d.ts +6 -0
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +8 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/useBlinkDetection.d.ts +27 -16
- package/build/hooks/useBlinkDetection.d.ts.map +1 -1
- package/build/hooks/useBlinkDetection.js +63 -37
- package/build/hooks/useBlinkDetection.js.map +1 -1
- package/build/hooks/useFaceDetection.js +3 -2
- package/build/hooks/useFaceDetection.js.map +1 -1
- package/build/hooks/useFaceDetector.d.ts +123 -0
- package/build/hooks/useFaceDetector.d.ts.map +1 -0
- package/build/hooks/useFaceDetector.js +133 -0
- package/build/hooks/useFaceDetector.js.map +1 -0
- package/build/hooks/useSmartCamera.js.map +1 -1
- package/build/hooks/useSmartCameraWebRTC.d.ts +3 -5
- package/build/hooks/useSmartCameraWebRTC.d.ts.map +1 -1
- package/build/hooks/useSmartCameraWebRTC.js +19 -87
- package/build/hooks/useSmartCameraWebRTC.js.map +1 -1
- package/build/hooks/useWebRTC.d.ts +88 -0
- package/build/hooks/useWebRTC.d.ts.map +1 -0
- package/build/hooks/useWebRTC.js +394 -0
- package/build/hooks/useWebRTC.js.map +1 -0
- package/build/hooks/useWebRTCWithDetection.d.ts +89 -0
- package/build/hooks/useWebRTCWithDetection.d.ts.map +1 -0
- package/build/hooks/useWebRTCWithDetection.js +131 -0
- package/build/hooks/useWebRTCWithDetection.js.map +1 -0
- package/build/index.d.ts +24 -10
- package/build/index.d.ts.map +1 -1
- package/build/index.js +38 -13
- package/build/index.js.map +1 -1
- package/build/types.d.ts +28 -12
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils/index.js.map +1 -1
- package/build/webrtc/WebRTCBridge.d.ts +3 -0
- package/build/webrtc/WebRTCBridge.d.ts.map +1 -1
- package/build/webrtc/WebRTCBridge.js +12 -15
- package/build/webrtc/WebRTCBridge.js.map +1 -1
- package/build/webrtc/WebRTCManager.d.ts +148 -0
- package/build/webrtc/WebRTCManager.d.ts.map +1 -0
- package/build/webrtc/WebRTCManager.js +383 -0
- package/build/webrtc/WebRTCManager.js.map +1 -0
- package/build/webrtc/index.d.ts +3 -1
- package/build/webrtc/index.d.ts.map +1 -1
- package/build/webrtc/index.js +5 -0
- package/build/webrtc/index.js.map +1 -1
- package/build/webrtc/types.d.ts +212 -4
- package/build/webrtc/types.d.ts.map +1 -1
- package/build/webrtc/types.js +34 -1
- package/build/webrtc/types.js.map +1 -1
- package/ios/FaceDetectorFrameProcessorPlugin.m +11 -0
- package/ios/FaceDetectorFrameProcessorPlugin.swift +304 -0
- package/package.json +11 -11
- package/react-native-smart-camera.podspec +32 -0
- package/src/detection/blinkProcessor.ts +127 -0
- package/src/detection/faceDetector.ts +78 -0
- package/src/detection/index.ts +3 -0
- package/src/detection/staticImageDetector.ts +53 -0
- package/src/hooks/index.ts +26 -0
- package/src/hooks/useBlinkDetection.ts +127 -0
- package/src/hooks/useFaceDetection.ts +105 -0
- package/src/hooks/useFaceDetector.ts +191 -0
- package/src/hooks/useSmartCamera.ts +83 -0
- package/src/hooks/useSmartCameraWebRTC.ts +120 -0
- package/src/hooks/useWebRTC.ts +453 -0
- package/src/hooks/useWebRTCWithDetection.ts +181 -0
- package/src/index.ts +170 -0
- package/src/types.ts +636 -0
- package/src/utils/index.ts +355 -0
- package/src/webrtc/WebRTCBridge.ts +127 -0
- package/src/webrtc/WebRTCManager.ts +453 -0
- package/src/webrtc/index.ts +50 -0
- package/src/webrtc/types.ts +361 -0
- package/android/build/.transforms/e0a0b120a9ccc3a8de4f5784bc36b161/results.bin +0 -1
- package/android/build/.transforms/e0a0b120a9ccc3a8de4f5784bc36b161/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/generated/source/buildConfig/debug/expo/modules/smartcamera/BuildConfig.java +0 -10
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -7
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -6
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/java_res/debug/out/META-INF/arfuhad-react-native-smart-camera_debug.kotlin_module +0 -0
- package/android/build/intermediates/javac/debug/classes/expo/modules/smartcamera/BuildConfig.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -7
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -7
- package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -16
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/META-INF/arfuhad-react-native-smart-camera_debug.kotlin_module +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/DetectedFace.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceBounds.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceContoursData.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceDetectionOptions.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceLandmarksData.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader$loadImage$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector$detectFaces$2$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector$detectFaces$2$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetectorKt$sam$com_google_android_gms_tasks_OnSuccessListener$0.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetectorKt.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/PointData.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$1$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$3$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$4$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$3.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$3.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$4.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$3.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$4.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$FunctionWithoutArgs$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$FunctionWithoutArgs$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnActivityEntersBackground$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnActivityEntersForeground$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnDestroy$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraView.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/WebRTCFrameBridge$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/WebRTCFrameBridge.class +0 -0
- package/android/src/main/java/expo/modules/smartcamera/ImageLoader.kt +0 -106
- package/android/src/main/java/expo/modules/smartcamera/MLKitFaceDetector.kt +0 -273
- package/android/src/main/java/expo/modules/smartcamera/SmartCameraModule.kt +0 -205
- package/android/src/main/java/expo/modules/smartcamera/SmartCameraView.kt +0 -153
- package/android/src/main/java/expo/modules/smartcamera/WebRTCFrameBridge.kt +0 -184
- package/build/SmartCamera.d.ts +0 -17
- package/build/SmartCamera.d.ts.map +0 -1
- package/build/SmartCamera.js +0 -270
- package/build/SmartCamera.js.map +0 -1
- package/build/SmartCameraModule.d.ts +0 -112
- package/build/SmartCameraModule.d.ts.map +0 -1
- package/build/SmartCameraModule.js +0 -121
- package/build/SmartCameraModule.js.map +0 -1
- package/build/SmartCameraView.d.ts +0 -8
- package/build/SmartCameraView.d.ts.map +0 -1
- package/build/SmartCameraView.js +0 -7
- package/build/SmartCameraView.js.map +0 -1
- package/expo-module.config.json +0 -9
- package/ios/MLKitFaceDetector.swift +0 -310
- package/ios/SmartCamera.podspec +0 -33
- package/ios/SmartCameraModule.swift +0 -225
- package/ios/SmartCameraView.swift +0 -146
- 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
|
-
* //
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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":"
|
|
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"}
|
package/build/hooks/index.d.ts
CHANGED
|
@@ -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":"
|
|
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"}
|
package/build/hooks/index.js
CHANGED
|
@@ -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
|
package/build/hooks/index.js.map
CHANGED
|
@@ -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;
|
|
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 {
|
|
1
|
+
import type { EyeStatusResult, UseBlinkDetectionResult } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Options for useBlinkDetection hook
|
|
4
4
|
*/
|
|
5
5
|
export interface UseBlinkDetectionOptions {
|
|
6
|
-
/** Whether
|
|
6
|
+
/** Whether eye tracking is enabled. Default: true */
|
|
7
7
|
enabled?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/** Callback when
|
|
11
|
-
|
|
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
|
|
14
|
+
* Hook for tracking eye status from detected faces
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
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
|
|
22
|
-
* const {
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
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>
|
|
32
|
-
* <
|
|
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,
|
|
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
|
|
3
|
+
* Hook for tracking eye status from detected faces
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
|
11
|
-
* const {
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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>
|
|
21
|
-
* <
|
|
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,
|
|
29
|
-
const [
|
|
30
|
-
const
|
|
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 =
|
|
36
|
-
}, [
|
|
37
|
-
//
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
84
|
+
reset();
|
|
59
85
|
}
|
|
60
|
-
}, [enabled,
|
|
86
|
+
}, [enabled, reset]);
|
|
61
87
|
return {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
|
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,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,iFAAiF;IACjF,MAAM,gBAAgB,GAAG,WAAW,CAAC,CAAC,KAAa,EAAE,EAAE;;QACrD,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QAED,sCAAsC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAEtB,yCAAyC;QACzC,IACE,IAAI,CAAC,sBAAsB,KAAK,SAAS;YACzC,IAAI,CAAC,uBAAuB,KAAK,SAAS,EAC1C,CAAC;YACD,OAAO;QACT,CAAC;QAED,MAAM,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,CAAC;QACxD,MAAM,oBAAoB,GAAG,IAAI,CAAC,uBAAuB,CAAC;QAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,MAAM,MAAM,GAAoB;YAC9B,OAAO,EAAE;gBACP,eAAe,EAAE,mBAAmB;gBACpC,QAAQ,EAAE,mBAAmB,GAAG,kBAAkB;aACnD;YACD,QAAQ,EAAE;gBACR,eAAe,EAAE,oBAAoB;gBACrC,QAAQ,EAAE,oBAAoB,GAAG,kBAAkB;aACpD;YACD,MAAM,EAAE,IAAI,CAAC,UAAU;YACvB,SAAS,EAAE,GAAG;SACf,CAAC;QAEF,YAAY,CAAC,MAAM,CAAC,CAAC;QACrB,MAAA,WAAW,CAAC,OAAO,4DAAG,MAAM,CAAC,CAAC;IAChC,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAElC,mBAAmB;IACnB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,YAAY,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,mBAAmB;IACnB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,KAAK,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]
|
|
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
|
|
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,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;IAC5B,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,OAAO,GAAG,cAAc,CAAC;IACvC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,+DAA+D;IAC/D,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,QAAgB,EAAE,EAAE
|
|
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;IAC5B,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,OAAO,GAAG,cAAc,CAAC;IACvC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,+DAA+D;IAC/D,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,QAAgB,EAAE,EAAE;;QACnD,wBAAwB;QACxB,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAEjD,+BAA+B;QAC/B,MAAM,YAAY,GAChB,YAAY,CAAC,MAAM,KAAK,QAAQ,CAAC,OAAO,CAAC,MAAM;YAC/C,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,WAAC,OAAA,IAAI,CAAC,UAAU,MAAK,MAAA,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,0CAAE,UAAU,CAAA,CAAA,EAAA,CAAC,CAAC;QAEtF,IAAI,YAAY,EAAE,CAAC;YACjB,QAAQ,CAAC,OAAO,GAAG,YAAY,CAAC;YAChC,QAAQ,CAAC,YAAY,CAAC,CAAC;YACvB,MAAA,WAAW,CAAC,OAAO,4DAAG,YAAY,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,6BAA6B;IAC7B,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE;QACtC,cAAc,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE;QACrC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtB,QAAQ,CAAC,EAAE,CAAC,CAAC;QACb,QAAQ,CAAC,OAAO,GAAG,EAAE,CAAC;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"}
|
|
@@ -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,CAAC,YAAY;YAC7C,WAAW,EAAE,UAAU,CAAC,OAAO,CAAC,WAAW;YAC3C,kBAAkB,EAAE,UAAU,CAAC,OAAO,CAAC,kBAAkB;YACzD,WAAW,EAAE,UAAU,CAAC,OAAO,CAAC,WAAW;YAC3C,eAAe,EAAE,UAAU,CAAC,OAAO,CAAC,eAAe;YACnD,YAAY,EAAE,UAAU,CAAC,OAAO,CAAC,YAAY;YAC7C,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ;YACrC,WAAW,EAAE,UAAU,CAAC,OAAO,CAAC,WAAW;YAC3C,YAAY,EAAE,UAAU,CAAC,OAAO,CAAC,YAAY;SAC9C,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,WAAW,EAAE,MAAM;KACpB,CAAC;AACJ,CAAC;AAiBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,2BAA2B,CACzC,UAA8C,EAAE;IAEhD,MAAM,EAAE,eAAe,KAAyB,OAAO,EAA3B,eAAe,UAAK,OAAO,EAAjD,mBAAuC,CAAU,CAAC;IACxD,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC,eAAe,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;IAE5C,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,OAAO,GAAG,eAAe,CAAC;IACxC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEtB,0BAA0B;IAC1B,MAAM,mBAAmB,GAAG,UAAU,CAAC,CAAC,KAAa,EAAE,EAAE;;QACvD,MAAA,WAAW,CAAC,OAAO,4DAAG,KAAK,CAAC,CAAC;IAC/B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,kBAAkB,GAAG,WAAW,CAAC,CAAC,KAAY,EAAU,EAAE;QAC9D,SAAS,CAAC;QACV,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YAC5C,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAEnC,OAAO;QACL,WAAW,EAAE,kBAAkB;KAChC,CAAC;AACJ,CAAC"}
|