Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Background camera app

This app demonstrates how to attach an instance of VerIDFragment to an activity, start a liveness detection session and await the session result.

Creating Ver-ID Fragment

Liveness detection and authentication

If you create the fragment with an instance of VerIDLivenessDetectionSessionSettings the session will detect a live face.

VerIDLivenessDetectionSessionSettings settings = new VerIDLivenessDetectionSessionSettings();
Fragment fragment = VerIDFragment.newInstance(settings);

VerIDFragment will evaluate the face detection result differently for different session settings. If you create the fragment with an instance of VerIDAuthenticationSessionSettings the session will authenticate the user.

VerIDAuthenticationSessionSettings settings = new VerIDAuthenticationSessionSettings("myUserId");
Fragment fragment = VerIDFragment.newInstance(settings);


As expected, creating VerIDFragment with an instance of VerIDRegistrationSessionSettings will register the user.

However, for an enhanced registration experience create an instance of VerIDRegistrationFragment instead of VerIDFragment.

VerIDRegistrationSessionSettings settings = new VerIDRegistrationSessionSettings("myUserId");
Fragment fragment = VerIDRegistrationFragment.newInstance(settings);

Optimising Session Settings

The default Ver-ID sessions are set up for hand-held devices. Running Ver-ID on devices mounted at a fixed location may require relaxing some of the liveness detection requirements to optimise the user experience.

Changing the session behaviour

Implement IFaceDetectionServiceFactory in the activity that attaches the VerIDFragment.

public class MyActivity extends AppCompatActivity implements IFaceDetectionServiceFactory {
	// ...

Override the makeFaceDetectionService method and supply an instance of VerIDTAFaceDetectionService. This service relaxes the requirement to align the user's face with an on-screen template.

You can further customise the service by passing different settings into its constructor. See the VerIDFaceDetectionService.

public IFaceDetectionService makeFaceDetectionService(VerIDSessionSettings verIDSessionSettings) {
	// When the face is fixed the face detection will pause 
	// to allow enough time for the user to read the on-screen instructions.
	// Decreasing the pause time will shorten the session but may lead 
	// to a frustrating user experience if the user isn't allowed enough 
	// time to read the prompts.
	long pauseTime = 1500;
	// To reduce the possibility of an unwanted face accidentally being 
	// considered in the session the service buffers a number of faces and 
	// checks that their bounds are within a given range of each other.
	// Decresing the value will speed up the session but introduce the 
	// possibility of a passing face being detected and considered for recognition.
	int faceBufferSize = 2;
	// Threshold angle that represents a bearing.
	// For example a value of 12 for the yaw axis will make bearings 
	// with yaw -12 represent left and bearings with yaw 12 represent right.
	// Values over 18 are too extreme and values below 10 are not pronounced enough.
	float yawThreshold = 12;
	float pitchThreshold = 12;
	// Value added or subtracted from the threshold angle (see above) when
	// evaluating whether an angle matches a bearing.
	// For example, given pitch threshold of 12 and a tolerance of 5, 
	// an angle will match one of the UP bearing if its pitch is below -7 (0 - 12 + 5).
	float yawThresholdTolerance = 5;
	float pitchThresholdTolerance = 5;
	// Construct the face detection service
	return new VerIDTAFaceDetectionService(verIDSessionSettings, pauseTime, faceBufferSize, yawThreshold, pitchThresholw, yawThresholdTolerance, pitchThresholdTolerance);
You can’t perform that action at this time.