帧处理器抛出错误:找不到变量:__scanFaces // vision-camera-face-detector

问题描述 投票:0回答:0

我正在构建一个 React Native 应用程序,它使用 react-native-vision-camera 包进行人脸检测。我还安装了 vision-camera-face-detector 包来启用人脸检测。但是,当我尝试运行该应用程序并使用 vision-camera-face-detector 中的 scanFaces 函数时,我在我的帧处理器中收到错误消息“找不到变量:__scanFaces”

import { scanFaces } from "vision-camera-face-detector";

const frameProcessor = useFrameProcessor((frame) => {
  const scannedFaces = scanFaces(frame);
  if (scannedFaces.length) {
    runOnJS(setFaces)(scannedFaces);
  }
}, []);

我的 babel.config 文件如下所示:

module.exports = {
  presets: ["module:metro-react-native-babel-preset", "module:react-native-dotenv"],
  env: {
    production: {},
  },
  plugins: [
    [
      "@babel/plugin-proposal-decorators",
      {
        legacy: true,
      },
    ],
    ["@babel/plugin-proposal-optional-catch-binding"],
    [
      'react-native-reanimated/plugin',
      {
        globals: ['__scanFaces'],
      },
    ], // NOTE: this must be last in the plugins
  ],
}

我目前正在使用这些版本:

`"react": "17.0.2",
 "react-native": "^0.64.2", // migrated from 0.63.3 to 0.64.2 to install vision camera
 "react-native-reanimated": "2.3.0-beta.2", 
 "react-native-vision-camera": "2.13.0", 
 "vision-camera-face-detector": "^0.1.7", //  Tried  "0.1.8" and "0.1.7" `
react-native face-detection react-native-reanimated react-native-vision-camera
© www.soinside.com 2019 - 2024. All rights reserved.