vision-camera-face-detector: Frame Processor threw an error: Can't find variable: __scanFaces

I’m facing an error when I try to run the app on Android

error Frame Processor threw an error: Can't find variable: __scanFaces

My environment:

    "react": "17.0.2",
    "react-native": "0.68.2",
    "react-native-device-info": "^8.0.0",
    "react-native-fs": "^2.20.0",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-reanimated": "2.9.1",
    "react-native-safe-area-context": "^4.3.3",
    "react-native-safe-area-view": "^1.1.1",
    "react-native-screens": "^3.17.0",
    "react-native-svg": "^12.1.0",
    "react-native-vision-camera": "^2.14.1",
    "react-navigation": "^4.4.3",
    "react-navigation-stack": "^2.10.2",
    "react-router-dom": "^6.3.0",
    "vision-camera-face-detector": "^0.1.8"

babel.config.js image

Metro image

I’m using the FrameProcessor

const frameProcessor = useFrameProcessor((frame) => {
    'worklet';
    const scannedFaces = scanFaces(frame);
    if (scannedFaces.length) {
      runOnJS(setFace)(scannedFaces.at(0));
    }
  }, []);

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 2
  • Comments: 23

Most upvoted comments

Instead of “__scanFaces”, you can use “scanFace” from ‘vision-camera-face-detector’. import { scanFaces, Face } from 'vision-camera-face-detector'; After you import “scanFaces” and Face from the above package in Typescript, you can use the bellow code to get the detected face.

const face = scanFaces(frame)[0] as Face

Also, you can use the bellow repository for more detail and example.

https://github.com/rodgomesc/vision-camera-face-detector

I fixed my issue after upgrading react-native-vision-camera to ^2.15.4

have you imported …'import ‘react-native-reanimated’;…on top of your index file??

Can you clear the cache and try again. It worked for me.

npx react-native start --reset-cache
or
yarn start --reset-cache
or
npm start --reset-cache