extractFace method
- DocumentImage image,
- String? documentName
Extracts a crop of the face in a document.
param image The image that contains the document. Must be a realigned BGR image of the document. param documentName The name of the document to be searched. Must be a key loaded in DocumentLibrary. return The cropped image of the face. throws DocumentException An error has occurred during Document Library execution.
Implementation
DocumentImage extractFace(DocumentImage image, String? documentName) {
Pointer<Char>? pDocumentName = documentName?.toNativeUtf8().cast<Char>();
DocumentImage croppedFace = DocumentImage();
try {
var err = documentSDK.id3DocumentReader_ExtractFace(_pHandle.value, image.handle, pDocumentName ?? nullptr, croppedFace.handle);
if (err != DocumentError.success.value) {
croppedFace.dispose();
throw DocumentException(err);
}
return croppedFace;
} finally {
if (pDocumentName != null) {
calloc.free(pDocumentName);
}
}
}