toBdt method

Uint8List toBdt()

Exports the face template object to a Biometric Data Template (BDT) buffer. This buffer can only be used with id3 Face Match on Card specific implementations to verify a face template.

return A buffer that receives the biometric data template. throws FaceException An error has occurred during Face Library execution.

Implementation

Uint8List toBdt() {
  Pointer<UnsignedChar> pData = nullptr;
  Pointer<Int> pDataSize = calloc();
  pDataSize[0] = -1;
  try {
    var err = faceSDK.id3FaceTemplate_ToBdt(_pHandle.value, pData, pDataSize);
    if (err == FaceError.insufficientBuffer.value) {
      pData = calloc.allocate(pDataSize.value);
      err = faceSDK.id3FaceTemplate_ToBdt(_pHandle.value, pData, pDataSize);
    }
    if (err != FaceError.success.value) {
      throw FaceException(err);
    }
    final vData = Uint8List.fromList(pData.cast<Uint8>().asTypedList(pDataSize.value));
    return vData;
  } finally {
    calloc.free(pData);
    calloc.free(pDataSize);
  }
}