Skip to content

Liveness

In the liveness step the user records a short video with the front camera. Prove ID checks the video for liveness and compares the face with the document photo.

The gestureType returned when the transaction started decides which gesture the user is asked for.

LivenessBaseFragment.setLayerShape(LivenessFragment.Shape.OVAL);
LivenessBaseFragment.setControlFaceCapture(true);
LivenessBaseFragment.GESTURE_TYPE = GestureType.EYE; // EYE, MOUTH, HEAD_VERTICAL, HEAD_HORIZONTAL
LivenessBaseFragment.VIDEO_PREPARATION_TIME_IN_MS = 3000;
LivenessBaseFragment.VIDEO_RECORD_TIME_IN_MS = 5000;
LivenessBaseFragment livenessFragment = LivenessBaseFragment.create(this);
livenessFragment.setFragmentListener(new FragmentListener() {
@Override
public void onVideoCaptured(String videoPath) {
// Send the video (below), then delete the file
}
@Override public void onVideoStarting() { }
@Override public void onVideoStarted() { }
@Override public void onVideoCanceled() { }
@Override public void onVideoProcessing() { }
@Override public void onFaceDetectionFailure(boolean isAway) { /* bring the face into the frame */ }
@Override public void onFaceDetectionSuccess() { }
@Override public void onFaceDetectionIdle() { }
@Override public void onMultiFaceDetected() { /* only one person in the frame */ }
});

gestureType values and their GestureType counterparts:

gestureType GestureType
EYE GestureType.EYE
MOUTH GestureType.MOUTH
HEAD-VERTICAL GestureType.HEAD_VERTICAL
HEAD-HORIZONTAL GestureType.HEAD_HORIZONTAL

For head gestures (HEAD_VERTICAL, HEAD_HORIZONTAL) set LivenessBaseFragment.IS_GESTURE_CONTROL_ENABLED = true.

String base64Video = Base64.encodeToString(videoBytes, Base64.NO_WRAP);
ServerCall.checkLiveness(new FaceVerificationModel(base64Video, transactionId, livenessFragment.rotate),
new TechsignServiceListener<VerifyFaceReturnModel>() {
@Override
public void onSuccess(VerifyFaceReturnModel result) {
ControlEntryModel[] controls = result.getControlResults();
}
@Override
public void onFailure(Exception e) { }
});
new File(videoPath).delete(); // don't leave the video on the device

Works without a gesture, with a short recording:

LivenessBaseFragment.VIDEO_PREPARATION_TIME_IN_MS = 1000;
LivenessBaseFragment.VIDEO_RECORD_TIME_IN_MS = 2000;

With a single photo instead of a video:

LivenessBaseFragment.LIVENESS_FROM_IMAGE_ENABLED = true;
livenessFragment.setPhotoListener(new LivenessBaseFragment.LivenessPhotoListener() {
@Override
public void photoCaptured(Bitmap photo) {
ServerCall.verifyFaceWithImage(
new FaceVerificationWithImageInputModel(transactionId, toBase64(photo)),
listener);
}
@Override
public void eligiblePositionForCapture(PreparationPositionModel model) { }
});