API Reference
Last updated
'check_liveness_level'
0: liveness v1 -> more accurate model
1: liveness v2-fast -> lighter modelFuture<dynamic> extractFaces(String imagePath){
"x1": face.x1,
"y1": face.y1,
"x2": face.x2,
"y2": face.y2,
"liveness": face.liveness,
"yaw": face.yaw,
"roll": face.roll,
"pitch": face.pitch,
"templates": templates,
"faceJpg": faceJpg,
"frameWidth": bitmap!!.width,
"frameHeight": bitmap!!.height
}Future<double?> similarityCalculation(
Uint8List templates1, Uint8List templates2)void onFaceDetected(faces)@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);
}