getModelFileName static method

String getModelFileName(
  1. FaceModel model
)

Retrieves the model file name which is needed in the LoadModel function.

param model The Face Model to look for. return The expected file name throws FaceException An error has occurred during Face Library execution.

Implementation

static String getModelFileName(FaceModel model) {
  Pointer<Char> pFileName = nullptr;
  Pointer<Int> pFileNameSize = calloc.allocate(1);
  pFileNameSize[0] = -1;
  try {
    var err = faceSDK.id3FaceLibrary_GetModelFileName(model.value, pFileName, pFileNameSize);
    if (err == FaceError.insufficientBuffer.value) {
      pFileName = calloc.allocate(pFileNameSize.value);
      err = faceSDK.id3FaceLibrary_GetModelFileName(model.value, pFileName, pFileNameSize);
      if (err != FaceError.success.value) {
        throw FaceException(err);
      }
    }
    final vFileName = utf8.decode(Uint8List.fromList(pFileName.cast<Uint8>().asTypedList(pFileNameSize.value)));
    return vFileName;
  } finally {
    calloc.free(pFileName);
    calloc.free(pFileNameSize);
  }
}