toBit method

Uint8List toBit(
  1. int threshold,
  2. int referenceDataQualifier
)

Exports the face template as a Biometric Information Template (BIT) for enrolment on a smart card equipped with id3 Match-on-Card technology. Note: The threshold value is required and should be set according to the used Face Encoder and desired security level. Important: The reference data qualifier (RDQ) should be defined in accordance with the smart card application specifications.

param threshold The decision threshold, from 0 to 653535, to be applied during the face comparison on the smart card. See FaceMatcherThreshold for a list of typical values. param referenceDataQualifier Reference data qualifier. return A buffer that receives the biometric information template. throws FaceException An error has occurred during Face Library execution.

Implementation

Uint8List toBit(int threshold, int referenceDataQualifier) {
  Pointer<UnsignedChar> pData = nullptr;
  Pointer<Int> pDataSize = calloc();
  pDataSize[0] = -1;
  try {
    var err = faceSDK.id3FaceTemplate_ToBit(_pHandle.value, threshold, referenceDataQualifier, pData, pDataSize);
    if (err == FaceError.insufficientBuffer.value) {
      pData = calloc.allocate(pDataSize.value);
      err = faceSDK.id3FaceTemplate_ToBit(_pHandle.value, threshold, referenceDataQualifier, 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);
  }
}