I use React-native-camera library for face detection and bounding box on faces. After I want crop only faces from image. For that I used ImageEditor Library for crop image from bounding box. But not getting accurate results.
const cropData = {
offset: { x: faces[0]["bounds"]['origin']["x"], y: faces[0]["bounds"]['origin']["y"] },
size: { width: faces[0]["bounds"]['size']["width"], height: faces[0]["bounds"]['size']["height"] },
displaySize: { width: faces[0]["bounds"]['size']["width"], height: faces[0]["bounds"]['size']["height"] },
resizeMode: 'contain',
};
ImageEditor.cropImage(url, cropData).then(url => {
console.log("Cropped image url",url);
}
Where faces are generated from React-native-camera library. faces = [{"bottomMouthPosition": {"x": 273.6521504720052, "y": 504.9319492340088}, "bounds": {"origin": [Object], "size": [Object]}, "faceID": 0, "leftCheekPosition": {"x": 309.4739685058594, "y": 433.28645477294924}, "leftEarPosition": {"x": 314.48342386881507, "y": 387.3479737599691}, "leftEyeOpenProbability": 0.9537659883499146, "leftEyePosition": {"x": 272.45707194010413, "y": 378.8229661305745}, "leftMouthPosition": {"x": 298.3786315917969, "y": 477.2733610788981}, "noseBasePosition": {"x": 252.38332112630206, "y": 442.4113123575846}, "rightCheekPosition": {"x": 190.822509765625, "y": 479.6853875478109}, "rightEarPosition": {"x": 144.62736002604166, "y": 464.80665067036944}, "rightEyeOpenProbability": 0.9021314382553101, "rightEyePosition": {"x": 184.92427571614581, "y": 413.32094650268556}, "rightMouthPosition": {"x": 228.29396565755206, "y": 503.3075309753418}, "rollAngle": -20.892227172851562, "smilingProbability": 0.00994393602013588, "yawAngle": -7.05137825012207}]