Below code, i am using for detecting face and eye in flutter, i am detecting face successfully using firebase google ml kit but problem is that while detecting eyes (leftEyeOpenProbability and rightEyeOpenProbability) always getting null.
Below is my code:
`Future<void> detectFacesInImage(String imagePath) async
{
final File imageFile = File(imagePath);
final InputImage inputImage = InputImage.fromFile(imageFile);
final FaceDetector faceDetector = GoogleMlKit.vision.faceDetector();
var landmarkMode = faceDetector.;
try {
final List<Face> faces = await faceDetector.processImage(inputImage);
if (faces.isEmpty)
{
/// No faces detected in the image
print('No faces detected in the image');
showCustomSnackbar(title: 'error', message: 'No faces detected in the image', backgroundColor: Colors.red);
return;
}
for (Face face in faces)
{
print('enter in face');
/// Access the right eye open probability
final double? leftEyeOpenProbability = face.leftEyeOpenProbability;
if (leftEyeOpenProbability != null) {
print('Left eye open probability: $leftEyeOpenProbability');
} else {
print('Left eye open probability: $leftEyeOpenProbability');
showCustomSnackbar(title: 'error', message: 'Left eye open probability not available', backgroundColor: Colors.red);
return;
}
/// Access the right eye open probability
final double? rightEyeOpenProbability = face.rightEyeOpenProbability;
if (rightEyeOpenProbability != null) {
print('Right eye open probability: $rightEyeOpenProbability');
} else {
print('Right eye open probability: $rightEyeOpenProbability');
showCustomSnackbar(title: 'error', message: 'Right eye open probability not available', backgroundColor: Colors.red);
return;
}
}
} catch (e) {
showCustomSnackbar(title: 'error', message: 'Error detecting faces', backgroundColor: Colors.red);
print('Error detecting faces: $e');
} finally {
/// showCustomSnackbar(title: 'error', message: 'succes', backgroundColor: Colors.red);
faceDetector.close();
}
}`
I am expecting when eyes open, it should return some probability value of left and right open.