startFacialComparisonSDK method
Future<BlusaltLivenessResultResponse?>
startFacialComparisonSDK({
- required String apiKey,
- required String appName,
- required String clientId,
- required bool isDev,
- required Uint8List imageData,
- String? reference,
- String? webhookUrl,
- LivenessFacialComparisonType livenessFacialComparisonType = LivenessFacialComparisonType.motional,
- bool collectDeviceId = false,
- bool collectDeviceLocation = false,
- ThresholdPriority thresholdPriority = ThresholdPriority.localOnly,
- bool? startProcessOnGettingToFirstScreen,
- double? thresholdInPercent,
- bool? showScore,
- bool? showThreshold,
- int? timeoutDurationInSec,
override
imageData is the image your want to compare with.
livenessFacialComparisonType can be LivenessFacialComparisonType.motional or LivenessFacialComparisonType.still
thresholdInPercent ranges between 0-100. The higher the value, the stricter the facial comparison.
When set to null or no value is passed, it will use the default value from SDK which ranges from 90-94.
timeoutDurationInSec this value can be used top override the timeout duration of networks calls in the SDK.
When set to null or no value is passed, it will use the default value from SDK 120s..
Implementation
@override
Future<BlusaltLivenessResultResponse?> startFacialComparisonSDK(
{required String apiKey,
required String appName,
required String clientId,
required bool isDev,
required Uint8List imageData,
String? reference,
String? webhookUrl,
LivenessFacialComparisonType livenessFacialComparisonType =
LivenessFacialComparisonType.motional,
bool collectDeviceId = false,
bool collectDeviceLocation = false,
ThresholdPriority thresholdPriority = ThresholdPriority.localOnly,
bool? startProcessOnGettingToFirstScreen,
double? thresholdInPercent,
bool? showScore,
bool? showThreshold,
int? timeoutDurationInSec}) async {
try {
if (thresholdPriority != ThresholdPriority.serverOnly &&
thresholdInPercent != null &&
(thresholdInPercent < 0 || thresholdInPercent > 100)) {
return BlusaltLivenessResultResponse(
blusaltLivenessProcess: BlusaltLivenessProcess.notImplemented,
message: "Threshold must be between 0 and 100");
}
final result =
await methodChannel.invokeMethod('startFacialComparisonSDK', {
'apiKey': apiKey,
'appName': appName,
'clientId': clientId,
'isDev': isDev,
'imageData': imageData,
'reference': reference,
'webhookUrl': webhookUrl,
'livenessType': livenessFacialComparisonType.name.toUpperCase(),
'collectDeviceId': collectDeviceId,
'collectDeviceLocation': collectDeviceLocation,
'thresholdPriority': thresholdPriority.name.toUpperCase(),
'startProcessOnGettingToFirstScreen':
startProcessOnGettingToFirstScreen ?? false,
'thresholdInPercent': thresholdInPercent,
'showScore': showScore ?? false,
'showThreshold': showThreshold ?? false,
'timeoutDurationInSec': timeoutDurationInSec,
});
if (result != null) {
var response = json.decode(result);
// Convert string to byte data
var originalImageByteDataInString =
(response['comparisonData']?['originalImage'] ?? '').toString();
// Convert string to byte data
var byteDataInString =
(response['faceDetectionData']?['livenessImage'] ?? '').toString();
return BlusaltLivenessResultResponse(
blusaltLivenessProcess: BlusaltLivenessProcess.completed,
isPassProcedureValidation: response['isProcedureValidationPassed'],
reference: reference,
comparisonData: BlusaltFacialComparisonData(
isPassFaceComparison: response['comparisonData']
['isPassFaceComparison'],
originalImage: originalImageByteDataInString),
faceDetectionData: BlusaltFaceDetectionData(
isPassFaceGenuiness: response['faceDetectionData']
['isPassFaceGenuineness'],
imageByte: byteDataInString),
deviceMetaData: DeviceMetaData(
deviceId: response['deviceMetaData']?['deviceId'],
deviceLocation: DeviceLocation(
address: response['deviceMetaData']?['deviceLocation']
?['address'] ??
'',
locality: response['deviceMetaData']?['deviceLocation']
?['locality'] ??
'',
longitude: response['deviceMetaData']?['deviceLocation']
?['longitude'] ??
'',
latitude: response['deviceMetaData']?['deviceLocation']
?['latitude'] ??
'',
)));
} else {
return BlusaltLivenessResultResponse(
blusaltLivenessProcess: BlusaltLivenessProcess.notImplemented,
message: "Something went wrong");
}
} on PlatformException catch (exception) {
return BlusaltLivenessResultResponse(
blusaltLivenessProcess: BlusaltLivenessProcess.notImplemented,
exception: exception,
message: exception.message,
code: exception.code);
} catch (e) {
return BlusaltLivenessResultResponse(
blusaltLivenessProcess: BlusaltLivenessProcess.notImplemented,
message: e.toString());
}
}