computeEyeOpenness method
- Image image,
- DetectedFace detectedFace,
- PointList landmarks
Computes the eye openness of a detected face.
The minimum recommanded value for is 90.
Important: Loading the EyeOpennessDetector model is required to use this function.
param image Source image to process. param detectedFace Detected face to process. param landmarks Estimated landmarks of the detected face. Must be computed with the face analyser. return The estimated openness scores of left and right eyes of the detected face in this order. throws FaceException An error has occurred during Face Library execution.
Implementation
List<int> computeEyeOpenness(Image image, DetectedFace detectedFace, PointList landmarks) {
Pointer<Int> pEyeOpennessScores = calloc.allocate(2);
Pointer<Int> pEyeOpennessScoresSize = calloc.allocate(1);
pEyeOpennessScoresSize[0] = 2;
try {
var err = faceSDK.id3FaceAnalyser_ComputeEyeOpenness(_pHandle.value, image.handle, detectedFace.handle, landmarks.handle, pEyeOpennessScores, pEyeOpennessScoresSize);
if (err == FaceError.insufficientBuffer.value) {
calloc.free(pEyeOpennessScores);
pEyeOpennessScores = calloc.allocate(pEyeOpennessScoresSize.value);
err = faceSDK.id3FaceAnalyser_ComputeEyeOpenness(_pHandle.value, image.handle, detectedFace.handle, landmarks.handle, pEyeOpennessScores, pEyeOpennessScoresSize);
}
if (err != FaceError.success.value) {
throw FaceException(err);
}
final vEyeOpennessScores = Int32List.fromList(pEyeOpennessScores.cast<Int32>().asTypedList(pEyeOpennessScoresSize.value));
return vEyeOpennessScores;
} finally {
calloc.free(pEyeOpennessScores);
calloc.free(pEyeOpennessScoresSize);
}
}