Expo FaceDetector
A library that uses Google Mobile Vision to detect faces on images.
Deprecated: This library will no longer be available from SDK 51. We recommendreact-native-vision-camera
if you require this functionality.
expo-face-detector
lets you use the power of the Google's ML Kit framework to detect faces on images.
Known issues Android
Face detector does not recognize faces that aren't aligned with the interface (top of the interface matches top of the head).
Installation
This module is not available in the Expo Go app because it has dependencies that break builds for iOS Simulators.
You can create a development build to work with this package.
-
npx expo install expo-face-detector
If you are installing this in an existing React Native app, make sure to install expo
in your project.
Usage
Settings
To configure detector's behavior modules pass a DetectionOptions
object which is then interpreted by this module.
Example
You can use the following snippet to detect faces in a fast mode without detecting landmarks or whether a face is smiling.
import { Camera } from 'expo-camera';
import * as FaceDetector from 'expo-face-detector';
const App = () => (
<Camera
// other props
onFacesDetected={handleFacesDetected}
faceDetectorSettings={{
mode: FaceDetector.FaceDetectorMode.fast,
detectLandmarks: FaceDetector.FaceDetectorLandmarks.none,
runClassifications: FaceDetector.FaceDetectorClassifications.none,
minDetectionInterval: 100,
tracking: true,
}}
/>
);
const handleFacesDetected = ({ faces }) => {
console.log(faces);
};
export default App;
API
import * as FaceDetector from 'expo-face-detector';
No API data file found, sorry!