VerIDFaceDetectionService

Default implementation of IFaceDetectionService. Suitable for handheld devices.

Package com.appliedrec.ver_id.services

public class VerIDFaceDetectionService

Implements

Constructors

VerIDFaceDetectionService

Introduced in version 4.7.0

public VerIDFaceDetectionService(VerIDSessionSettings)

Class constructor

Parameters

settings com.appliedrec.ver_id.session.VerIDSessionSettings
Session settings

VerIDFaceDetectionService

Introduced in version 4.7.0

public VerIDFaceDetectionService(VerIDSessionSettings, long, int, float, float, float, float)

Class constructor

Parameters

settings com.appliedrec.ver_id.session.VerIDSessionSettings
Session settings
pauseTime long
Pause time in milliseconds
faceBufferSize int
Size of the face buffer
yawThreshold float
Threshold angle for the yaw axis
pitchThreshold float
Threshold angle for the pitch axis
yawThresholdTolerance float
Threshold tolerance angle for the yaw axis
pitchThresholdTolerance float
Threshold tolerance angle for the pitch axis

See also

Methods

detectFaceInVerIDImage

Introduced in version 4.7.0

public final synchronized detectFaceInVerIDImage(VerIDImage)

Detect face in image

Parameters

image com.appliedrec.ver_id.VerIDImage
Image in which to detect the face

Returns

com.appliedrec.ver_id.model.FaceDetectionResult
Face detection result

getSmoothingBufferSize

Introduced in version 4.7.0

public getSmoothingBufferSize()

To reduce noise in face detection the face angle and bounds are kept in a buffer and a smoothed value is used for calculations and display. Override this method if you need to increase or decrease the size of the buffers. Default value is 3. Larger buffer size will yield smoother results but the display may appear lagging behind. Smaller size will produce more responsive but potentially stuttering and error-prone user experience.

Returns

int
Buffer size

getPauseTime

Introduced in version 4.7.0

public getPauseTime()

When the face is fixed the face detection will pause to allow enough time for the user to read the on-screen instructions. The default pause is 2000 (2 seconds). 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.

Returns

long
Pause time in milliseconds

getFaceBufferSize

Introduced in version 4.7.0

public getFaceBufferSize()

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. Default value is 4.

Returns

int
Size of the face buffer

isFaceWithBoundsFixedInImageSize

Introduced in version 4.7.0

public isFaceWithBoundsFixedInImageSize(RectF, Size)

When the service first detects a face it checks the result of this method to see if it can consider the face "fixed" and ready to ask the user to align with a bearing.

Parameters

faceBounds android.graphics.RectF
Bounds of the detected face
size com.appliedrec.shared.Size
Pixel size of the image in which the face was detected

Returns

boolean
true if the face is "fixed"

angleMatchesBearing

Introduced in version 4.7.0

public final angleMatchesBearing(VerID.EulerAngleF, VerID.Bearing)

Helper method to check whether an angle matches a bearing

Parameters

angle com.appliedrec.ver_id.VerID.EulerAngleF
Face angle
bearing com.appliedrec.ver_id.VerID.Bearing
Bearing

Returns

boolean
true if the angle matches the bearing

getAngleForBearing

Introduced in version 4.7.0

public final getAngleForBearing(VerID.Bearing)

Helper method to get an angle representing the given bearing.

Parameters

bearing com.appliedrec.ver_id.VerID.Bearing
Bearing

Returns

com.appliedrec.ver_id.VerID.EulerAngleF
Bearing angle

getMinAngleForBearing

Introduced in version 4.7.0

public final getMinAngleForBearing(VerID.Bearing)

Helper method to get a minimum angle for the given bearing. For a face to be considered matching a bearing, its angle must lie between minimum and maximum angles for the bearing.

Parameters

bearing com.appliedrec.ver_id.VerID.Bearing
Bearing

Returns

com.appliedrec.ver_id.VerID.EulerAngleF
Minimum angle

getMaxAngleForBearing

Introduced in version 4.7.0

public final getMaxAngleForBearing(VerID.Bearing)

Helper method to get a maximum angle for the given bearing. For a face to be considered matching a bearing, its angle must lie between minimum and maximum angles for the bearing.

Parameters

bearing com.appliedrec.ver_id.VerID.Bearing
Bearing

Returns

com.appliedrec.ver_id.VerID.EulerAngleF
Maximum angle

getStatus

Introduced in version 4.7.0

public final getStatus()

Returns the current status of face detection. The status of a typical liveness detection session will change from started to face found to face fixed to face aligned to face misaligned and again face aligned.

Returns

com.appliedrec.ver_id.session.FaceDetectionStatus
Face detection status

getFaceBuffer

Introduced in version 4.7.0

public final getFaceBuffer()

Buffer of detected face bounds. Used when evaluating whether a face is aligned. The maximum size of the buffer is dictated by getFaceBufferSize().

Returns

java.util.ArrayList<RectF>
List of detected face bounds

getAngleFromAngleToBearing

Introduced in version 4.7.0

public final getAngleFromAngleToBearing(VerID.EulerAngleF, VerID.Bearing)

Angle from a given angle to a bearing

Parameters

angle com.appliedrec.ver_id.VerID.EulerAngleF
From angle
bearing com.appliedrec.ver_id.VerID.Bearing
To bearing

Returns

double
Angle in radians

getDistanceFromAngleToBearing

Introduced in version 4.7.0

public final getDistanceFromAngleToBearing(VerID.EulerAngleF, VerID.Bearing)

Distance from a given angle to a bearing

Parameters

angle com.appliedrec.ver_id.VerID.EulerAngleF
From angle
bearing com.appliedrec.ver_id.VerID.Bearing
To bearing

Returns

double
Distance normalized to values between 0.0 and 1.0

getThresholdAngleForAxis

Introduced in version 4.7.0

public getThresholdAngleForAxis(VerIDFaceDetectionService.Axis)

Threshold angle that represents a bearing. For example returning 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. Default value is 12 for both yaw and pitch.

Parameters

axis com.appliedrec.ver_id.services.VerIDFaceDetectionService.Axis

Returns

float
Threshold angle for the given axis

See also

getThresholdAngleToleranceForAxis

Introduced in version 4.7.0

public getThresholdAngleToleranceForAxis(VerIDFaceDetectionService.Axis)

Value added or subtracted from the threshold when evaluating whether an angle matches a bearing. For example, given pitch threshold of 12 and a tolerance returned by this method of 5, an angle will match one of the up bearings if its pitch is below -7 (0 - 12 + 5).

Example

Note: The example illustrates the calculation done by the service. The method angleMatchesBearing will achieve the same result with less boilerplate code.

EulerAngleF faceAngle; // Angle of the datected face float yawThreshold = getThresholdAngleForAxis(Axis.YAW); float yawTolerance = getThresholdAngleToleranceForAxis(Axis.YAW); EulerAngleF straightBearingAngle = getAngleForBearing(VerID.Bearing.STRAIGHT); boolean isYawCentred = faceAngle.yaw > straightBearingAngle.yaw - yawThreshold - yawTolerance && faceAngle.yaw < straightBearingAngle.yaw + yawThreshold + yawTolerance;

Parameters

axis com.appliedrec.ver_id.services.VerIDFaceDetectionService.Axis

Returns

float
Threshold tolerance angle for the given axis

getRequestedBearing

Introduced in version 4.7.0

public synchronized getRequestedBearing()

Returns

com.appliedrec.ver_id.VerID.Bearing

setRequestedBearing

Introduced in version 4.7.0

public synchronized setRequestedBearing(VerID.Bearing)

Parameters

bearing com.appliedrec.ver_id.VerID.Bearing

getDefaultFaceBoundsInImageSize

Introduced in version 4.7.0

public getDefaultFaceBoundsInImageSize(Size)

Parameters

imageSize com.appliedrec.shared.Size

Returns

android.graphics.RectF

Properties

settings

Introduced in version 4.7.0

public final VerIDSessionSettings settings

Session settings