英文:
How to use react-native-vision-camera Frame Processor to detect human face?
问题
Here is the translated code portion:
如何使用react-native-vision-camera的Frame Processor来检测人脸?我尝试使用一个名为vision-camera-face-detector的包,但在尝试创建我的React Native CLI应用APK时失败了,是否有其他方法可以使用react-native-vision-camera的Frame Processor来检测人脸?
export default function App() {
const [cameraPermission, setCameraPermission] = useState();
useEffect(() => {
(async () => {
const cameraPermissionStatus = await Camera.requestCameraPermission();
setCameraPermission(cameraPermissionStatus);
})();
}, []);
console.log(`摄像头权限状态:${cameraPermission}`);
const devices = useCameraDevices();
const cameraDevice = devices.back;
const renderDetectorContent = () => {
if (cameraDevice && cameraPermission === 'authorized') {
return (
<Camera
style={styles.camera}
device={cameraDevice}
isActive={true}
/>
);
}
return <ActivityIndicator size="large" color="#1C6758" />;
};
return (
<View style={styles.screen}>
<SafeAreaView style={styles.saveArea}>
<View style={styles.header}>
<Text style={styles.headerText}>React Native 人脸检测器</Text>
</View>
</SafeAreaView>
{renderDetectorContent()}
</View>
);
}
I've provided the translated code portion as requested. If you have any more translation needs or questions, feel free to ask.
英文:
How to use react-native-vision-camera Frame Processor to detect human faces? I tried using a package called vision-camera-face-detector but it fails my built when I am trying to create my react native cli app apk is there any other solution to detect human faces using react-native-vision-camera Frame Processor?
export default function App() {
const [cameraPermission, setCameraPermission] = useState();
useEffect(() => {
(async () => {
const cameraPermissionStatus = await Camera.requestCameraPermission();
setCameraPermission(cameraPermissionStatus);
})();
}, []);
console.log(`Camera permission status: ${cameraPermission}`);
const devices = useCameraDevices();
const cameraDevice = devices.back;
const renderDetectorContent = () => {
if (cameraDevice && cameraPermission === 'authorized') {
return (
<Camera
style={styles.camera}
device={cameraDevice}
isActive={true}
/>
);
}
return <ActivityIndicator size="large" color="#1C6758" />;
};
return (
<View style={styles.screen}>
<SafeAreaView style={styles.saveArea}>
<View style={styles.header}>
<Text style={styles.headerText}>React Native Face Detector</Text>
</View>
</SafeAreaView>
{renderDetectorContent()}
</View>
);
}
答案1
得分: 3
我可以使用 vision-camera-face-detector 插件来检测人脸。
查看文档 https://github.com/rodgomesc/vision-camera-face-detector
以下是示例的帧处理器:
const frameProcessor = useFrameProcessor((frame) => {
'worklet';
const scannedFaces = scanFaces(frame);
runOnJS(setFaces)(scannedFaces);
}, []);
英文:
I can use the vision-camera-face-detector plugin to detect face.
See the docs https://github.com/rodgomesc/vision-camera-face-detector
Here's example the frame processor:
const frameProcessor = useFrameProcessor((frame) => {
'worklet';
const scannedFaces = scanFaces(frame);
runOnJS(setFaces)(scannedFaces);
}, []);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论