'Expo: How to save and compare faces?
I have an expo-camera app:
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native';
import { useState, useEffect } from 'react';
import { Camera } from 'expo-camera';
export default function App() {
const [cameraPerm, setCameraPerm] = useState(null);
const [type, setType] = useState(Camera.Constants.Type.back);
const permFunction = async () => {
const cameraPermission = await Camera.requestCameraPermissionsAsync();
setCameraPerm(cameraPermission.granted);
};
useEffect(() => {
permFunction();
}, []);
if (!cameraPerm) {
return (
<View style={styles.container}>
<Text>onay yok</Text>
</View>
)
}
return (
<View style={styles.container}>
<Camera style={styles.camera} type={type}
onFacesDetected={(faces) => console.log(faces)}>
<View style={styles.buttonContainer}>
<TouchableOpacity
style={styles.button}
onPress={() => {
setType(
type === Camera.Constants.Type.back
? Camera.Constants.Type.front
: Camera.Constants.Type.back
);
}}>
<Text style={styles.text}> Flip </Text>
</TouchableOpacity>
</View>
</Camera>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
camera: {
width: '100%',
height: '70%',
},
button: {
alignItems: 'center',
},
text: {
fontSize: 100,
color: '#fff',
}
});
At onFacesDetected={} I console.log the faces.
That's an example what I got as logged:
Object {
"faces": Array [
Object {
"bounds": Object {
"origin": Object {
"x": 113.06666666666668,
"y": 54.79012345679012,
},
"size": Object {
"height": 185.89506172839504,
"width": 168.88888888888889,
},
},
"faceID": -1,
"rollAngle": 12.109676361083984,
"yawAngle": 35.44415283203125,
},
],
"target": 65,
"type": "face",
}
I have an API. User will scan his face when he/she is registered and scan details will be posted to API. When user will try to login, I'll get the user's face details and compare with the one user currently scanning. How can I save face detail and compare that two faces with each other?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
