This library provide google ml-kit abilities from react-native.
It's build with usage of react-native-vision-camera.
npm install vision-camera-rn-face-detector
Add to AndroidManifest
<uses-permission android:name="android.permission.CAMERA" />
Follow these intructions to make work reanimated correctly
Add this to babel.config.js in root of project
module.exports = {
...
plugins: [
...
[
'react-native-reanimated/plugin',
{
globals: ['__vision_camera_plugin'],
},
],
],
};
import {...} from 'vision-camera-rn-face-detector';
const frameProcessor = useFrameProcessor((frame) => {
'worklet';
const faces = scanFacesFromCamera(frame);
console.log(faces);
frame.close();
}, []);
const CameraView = () => {
const devices = useCameraDevices();
const device = devices.front;
return (
<Camera
style={StyleSheet.absoluteFill}
device={device}
frameProcessor={frameProcessor}
frameProcessorFps={3}
fps={25}
isActive={true}
/>
);
}
To define single face landmarks you can use
getLandMarkFromFace(face, FaceField.SMILE_PROBABILITY)
Try to open cmake at node_modules/react-native-vision-camera/andoid/CmakeList.txt, then find these lines in the end of file and remove
find_library(
JSI_LIB
jsi
PATHS ${LIBRN_DIR}
NO_ CMAKE_FIND_ROOT_PATH
) <- all these line
target_link_libraries(
...
${JSI_LIB} <- this line
...
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT