API Reference
setActivation
Future<int?> setActivation(String license)
Name
setActivation
Description
Activate SDK
Input
license: The license string
Output
The SDK activation status code.
0: Success
Non-zero: Activation failed
init
Future<int?> init()
Name
init
Description
Initiate SDK
Input
None
Output
The SDK initialization status code.
0: Success
-1: License Key Error
-2: License AppID Error
-3: License Expired
-4: Activate Error
-5: Initialize SDK Error
setParam
Future<void> setParam(Meap<String, Object> params)
Name
setParam
Description
Set Face Detection parameters
Input
params face detection parameters
Output
None
extractFaces
Future<dynamic> extractFaces(String imagePath)
Name
extractFaces
Description
Detect and extract face templates from image file
Input
imagePath : Image file path
Output
Face detection result
similarityCalculation
Future<double?> similarityCalculation(
Uint8List templates1, Uint8List templates2)
Name
similarityCalculation
Description
Calculate similarity between two face features
Input
templates1: The first face template
templates2: The second face template
Output
A float value representing the similarity score between the two face templates The score ranges from 0.0 to 1.0 Default Threshold is 0.8
onFaceDetected
void onFaceDetected(faces)
Name
onFaceDetected
Description
callback function for face detection on camera stream
Input
None
Output
Face detection result in camera frame
callback function definition
@Override
public void onFrame(Bitmap bitmap) {
ArrayList<HashMap<String, Object>> faceBoxesMap = new ArrayList<HashMap<String, Object>>();
FaceDetectionParam param = new FaceDetectionParam();
param.check_liveness = true;
param.check_liveness_level = FaceDetectionFlutterView.livenessDetectionLevel;
List<FaceBox> faceBoxes = FaceSDK.faceDetection(bitmap, param);
for(int i = 0; i < faceBoxes.size(); i ++) {
FaceBox faceBox = faceBoxes.get(i);
byte[] templates = FaceSDK.templateExtraction(bitmap, faceBox);
Bitmap faceImage = Utils.cropFace(bitmap, faceBox);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
faceImage.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] faceJpg = byteArrayOutputStream.toByteArray();
HashMap<String, Object> e = new HashMap<String, Object>();
e.put("x1", faceBox.x1);
e.put("y1", faceBox.y1);
e.put("x2", faceBox.x2);
e.put("y2", faceBox.y2);
e.put("liveness", faceBox.liveness);
e.put("yaw", faceBox.yaw);
e.put("roll", faceBox.roll);
e.put("pitch", faceBox.pitch);
e.put("templates", templates);
e.put("faceJpg", faceJpg);
e.put("frameWidth", bitmap.getWidth());
e.put("frameHeight", bitmap.getHeight());
faceBoxesMap.add(e);
}
Message message = new Message();
message.what = 1;
message.obj = faceBoxesMap;
channelHandler.sendMessage(message);
}
Last updated