0.1.3 • Published 2 years ago

vision-camera-rn-face-detector v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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 {scanFacesFromCamera} 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
    ...

2. Gradle doesn't see dependencies

Try to install react-native-reanimated and react-native-vision-camera manually

yarn add react-native-reanimated react-native-vision-camera

3. Build error

Try to set compileSdkVersion 31 at least

Contributing

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

License

MIT

0.1.2

2 years ago

0.1.3

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago