I am trying to scan the user face to save the user LivenessResponse, but it didn't work here the function is invoke but the it did not scan the face. here is the function
Future<void> startLiveness() async {
try {
// Start the liveness detection
LivenessResponse result = await faceSdk.startLiveness(
config: LivenessConfig(
skipStep: [LivenessSkipStep.ONBOARDING_STEP],
),
notificationCompletion: (notification) {
print(notification.status);
},
);
print('result image $result');
if (result.image != null) {
setState(() {
_livenessResponse = result; // Save the liveness response
_status = "Liveness scan successful!";
});
} else {
setState(() {
_status = "Liveness scan failed: No image captured.";
});
}
} catch (e) {
setState(() {
_status = "Liveness scan failed: ${e.toString()}";
});
}
}
so here what is wrong? because there is not live face is capture so the image is always null.
Try this code. I added enhanced debug output in the notificationCompletion callback to better understand the face detection status during the liveness scan.
Future<void> startLiveness() async {
try {
// Start the liveness detection
LivenessResponse result = await faceSdk.startLiveness(
config: LivenessConfig(
skipStep: [LivenessSkipStep.ONBOARDING_STEP],
),
notificationCompletion: (notification) {
print("Notification status: ${notification.status}");
if (notification.status == "FACE_NOT_DETECTED") {
print("Face not detected, please adjust your position.");
}
},
);
print('Result: $result');
if (result.image != null) {
setState(() {
_livenessResponse = result; // Save the liveness response
_status = "Liveness scan successful!";
});
} else {
setState(() {
_status = "Liveness scan failed: No image captured.";
});
}
} catch (e) {
setState(() {
_status = "Liveness scan failed: ${e.toString()}";
});
print("Error: $e");
}
}