andpall / vision-camera-rn-face-detector

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vision-camera-rn-face-detector

This library provide google ml-kit abilities from react-native.
It's build with usage of react-native-vision-camera.

Installation

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'],
      },
    ],
  ],
};

Usage

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)

Troubleshooting

1. Cmake doesn't find variables

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
    ...

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

About

License:MIT License


Languages

Language:Java 65.5%Language:TypeScript 17.5%Language:Objective-C 9.2%Language:JavaScript 4.1%Language:Ruby 2.9%Language:Shell 0.4%Language:C 0.2%Language:Swift 0.2%