import { FaceFeature, Point } from 'expo-face-detector';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
const landmarkSize = 2;
export const scaledFace =
(scale: number) =>
({ faceID, bounds, rollAngle, yawAngle }: FaceFeature) => (
ID: {faceID}
rollAngle: {rollAngle!.toFixed(0)}
yawAngle: {yawAngle!.toFixed(0)}
);
export const scaledLandmarks = (scale: number) => (face: FaceFeature) => {
const renderLandmark = (position?: Point) =>
position && (
);
console.log('landmark', face);
return (
{renderLandmark(face.leftEyePosition)}
{renderLandmark(face.rightEyePosition)}
{renderLandmark(face.leftEarPosition)}
{renderLandmark(face.rightEarPosition)}
{renderLandmark(face.leftCheekPosition)}
{renderLandmark(face.rightCheekPosition)}
{renderLandmark(face.leftMouthPosition)}
{renderLandmark(face.mouthPosition)}
{renderLandmark(face.rightMouthPosition)}
{renderLandmark(face.noseBasePosition)}
{renderLandmark(face.bottomMouthPosition)}
);
};
export const face = scaledFace(1);
export const landmarks = scaledLandmarks(1);
const styles = StyleSheet.create({
face: {
padding: 10,
borderWidth: 2,
borderRadius: 2,
position: 'absolute',
borderColor: '#FFD700',
justifyContent: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
},
landmark: {
width: landmarkSize,
height: landmarkSize,
position: 'absolute',
backgroundColor: 'red',
},
faceText: {
color: '#FFD700',
fontWeight: 'bold',
textAlign: 'center',
margin: 10,
backgroundColor: 'transparent',
},
});