React Native Vision Camera Face Detector
References
- •
./references/quickstart.md-- install, setup, usage templates, options, and troubleshooting
Core Constraints
- •Requires
react-native-vision-camera. - •Add
react-native-worklets-core/plugintobabel.config.jsfor frame-processor flows. - •Face detection is CPU heavy; run asynchronous frame detection with
runAsyncwhen using frame processors. - •If using
useFaceDetector, callstopListeners()on cleanup/unmount. - •Minimum OS guidance from package docs:
- •Android SDK 26+
- •iOS 15.5+
Setup Workflow
- •Install package:
bash
yarn add react-native-vision-camera-face-detector
- •
Ensure Babel plugin exists:
- •
react-native-worklets-core/plugininbabel.config.js - •Keep it compatible with existing worklets/reanimated plugin ordering in project.
- •
- •
Rebuild native artifacts after install/plugin changes:
- •Expo managed with native code:
npx expo prebuildthen iOS/Android build. - •Bare app: reinstall pods/gradle as needed.
- •Expo managed with native code:
- •
Request camera permission before camera render.
- •
Pick one integration path:
- •Recommended callback API (
Camerafrom this package withfaceDetectionCallback). - •Frame processor API (
useFaceDetector+ Vision Camera frame processor).
- •Recommended callback API (
- •
For gallery/file images, use static
detectFaces.
API Selection Rules
- •Use recommended callback API when you only need face results, not custom frame-processor chains.
- •Use frame processor API when you need to combine multiple processors or custom worklet pipelines.
- •Use static image API for face detection in picked images or previously captured photos.
Performance Rules
- •Prefer
performanceMode: 'fast'unless product requirements need higher precision. - •Do not combine contour mode and tracking unless necessary (usually only one prominent face with contours).
- •Avoid synchronous heavy work on the JS thread for per-frame face results.
- •Keep detection options stable (
useRef) to avoid frequent detector reconfiguration.
Verification Checklist
- •Camera permission flow works for denied/authorized states.
- •Real-time detection callback receives faces on expected camera (
front/back). - •If using frame processors, no "Regular javascript function cannot be shared" worklet errors.
- •
stopListeners()is called on unmount (frame-processor path). - •Static-image
detectFacesworks forrequire,file://,content://, and object{ uri }sources. - •App remains responsive while detecting faces continuously.