computeEyeRedness method

List<int> computeEyeRedness(
  1. Image image,
  2. DetectedFace detectedFace,
  3. PointList landmarks
)

Computes the eye redness of a detected face. The maximum recommanded value for an ICAO-compliant portrait is 10. Important: Loading the EyeRednessDetector 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 redness 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> computeEyeRedness(Image image, DetectedFace detectedFace, PointList landmarks) {
  Pointer<Int> pEyeRednessScores = calloc.allocate(2);
  Pointer<Int> pEyeRednessScoresSize = calloc.allocate(1);
  pEyeRednessScoresSize[0] = 2;
  try {
    var err = faceSDK.id3FaceAnalyser_ComputeEyeRedness(_pHandle.value, image.handle, detectedFace.handle, landmarks.handle, pEyeRednessScores, pEyeRednessScoresSize);
    if (err == FaceError.insufficientBuffer.value) {
      calloc.free(pEyeRednessScores);
      pEyeRednessScores = calloc.allocate(pEyeRednessScoresSize.value);
      err = faceSDK.id3FaceAnalyser_ComputeEyeRedness(_pHandle.value, image.handle, detectedFace.handle, landmarks.handle, pEyeRednessScores, pEyeRednessScoresSize);
    }
    if (err != FaceError.success.value) {
      throw FaceException(err);
    }
    final vEyeRednessScores = Int32List.fromList(pEyeRednessScores.cast<Int32>().asTypedList(pEyeRednessScoresSize.value));
    return vEyeRednessScores;
  } finally {
    calloc.free(pEyeRednessScores);
    calloc.free(pEyeRednessScoresSize);
  }
}