Android

BCC Face is an Android library meant to be integrated into an Android application.

It uses the device’s camera to take a picture of a face for biometric purposes. It provides a simple active liveness test, requiring the person to smile for about a second and/or look to the right or left. The liveness test includes an option to speak the instructions, facilitating the workflow for users. Additionally, it provides a passive liveness test that can be used to check if the photo was taken from a real person without requiring user interaction.

This manual is updated to BCC Face Mobile Android version 4.8.0.

Requirements

BCC Face is an Android library, and must be imported into the target project.

  • Minimum Android Version: Android 6.0 (SDK 23), "Marshmallow".

  • The mobile device must have a camera.

  • The native app must be built with Android technology.

  • Development environment: an Android IDE is required, such as Android Studio (recommended).

  • Additional external dependencies:

  • External services:

    • Firebase, by Google. An account is required, but no charges will be applied since the library uses only on-device APIs.

Installation

Adding the Library in the App Project

BCC Face is provided by Griaule as a .aar file.

To add the libraries, go to your project directory, open the app folder and create the directories: libs/bccface. Then, add the bccfacelib-release.aar dependency. The folder structure must similar to this:

The next step is to make these files visible to the gradle dependencies. To do this, add the following line in the file build.gradle (:app), in the dependencies object:

Inside the build.gradle (:app) file, also add the compile options and set Source Compatibility and Target Compatibility to use 1.8 (Java 8):

Setting up Google ML Kit

It is recommended to follow the instructions provided in "Option 1: Use the Firebase console setup workflow" of the Firebase for Android documentation: Add Firebase to your Android project.

An account is required, but no charges will be applied since the library uses only on-device APIs: See Firebase pricing details.

If Option 1 was chosen, make sure to generate the google-services.json file and to place it in android/app/ directory.

Make changes to the following files:

  • android/build.gradle

  • android/app/build.gradle, add to the bottom of the file:

Setting up all dependencies

Make changes to the following files:

  • android/build.gradle

  • android/app/build.gradle

Usage

Parameters and Constructor

To properly use the BCC Face library, there are some required parameters.

A simple library usage example is shown below:


The BCCFaceBuilder class constructor receives the following parameters:

  • context: Context - The application context.

  • delegate: BCCFaceDelegate - Interface responsible for notifying capture events (e.g. failure or success).


The BCCFaceBuilder class is responsible for handling the usage configuration for BCCFace. The following parameters are accepted for configuring biometric capture and software behavior:

  • buildSmileCheck(smileProbability: Float = 0.8f) - Adds smile for liveness test and defines the acceptance threshold. This feature is enabled by default.

  • removeSmileCheck() - Removes smile for liveness check.

  • buildRotationCheck(livenessConfigList: List<HeadRotationCheck>, headRotationAngle: Float = 20f) - Defines a list of liveness tests for head rotation and max rotation angle. This feature is enabled by default. The head rotation options are:

  • removeHeadRotation() - Removes head rotation for liveness check.

  • addPassiveLiveness() - Adds the passive liveness test. This feature is used to check if the captured photo is from a real person without requiring any user interaction. To use this feature, you MUST disable the active liveness checks (removeSmileCheck() and removeHeadRotation()) that are added by default.

  • buildSpeechSettings(speechSettings: SpeechSettings?) - Defines the criteria for accessibility speech, using the following parameters:

    • volume - The audio volume between 0.0 and 1.0.

    • startsMuted - Defines whether the instructions start muted or not (true for muted).

    • pitch - Defines the voice pitch for the instructions between 0.5 (low) and 2.0 (high).

    • speed - Defines the voice speed for the instructions. This value must be positive.

    The pre-defined values can be accessed through the static variable:

  • removeSpeech() - Removes accessibility speech.

  • setReviewEnable(enable: Boolean) - Defines whether the biometric capture review screen is enabled or disabled.

  • setInstructionEnable(enable: Boolean) - Defines whether the instruction screen is enabled or disabled.

  • forceLanguage(language: BCCFaceAPI.BCCLanguages?) - Forces the instructions to be shown in a single language. If the device language is not supported, English will be used. The supported languages are:

  • removeLanguage() - Removes the forced language.

  • enableFlipCameraButton(enable: Boolean) - Activates (true) or deactivates (false) the camera flip button (front or back camera). Default: enabled (true).

  • setCameraInitialDirection(CameraFacingDirection.<FRONT or BACK>) - Defines the initial camera direction, choose between:

    • CameraFacingDirection.FRONT - Front camera (default setting).

    • CameraFacingDirection.BACK - Back camera.


All camera direction settings are obtained through the combination of the enableFlipCameraButton and setCameraInitialDirection methods. For example:

  • Start with the front camera and enable the camera flip button:

  • Start with the back camera and disable the camera flip button:


For reference, here is a full list of parameters and default values:

Here is a code snipped to initialize a capture using only the passive liveness test:

Return Values

The results from the last facial capture can be retrieved using the faceCaptureDidFinish method from the BCCFaceDelegate interface:

The data object contains both images captured during the process:

The returned properties are:

  • originalPhoto (image) - The original photo taken by the camera.

  • croppedPhoto (image) - The cropped photo, which is the face image cropped from the original photo.

  • passiveResult (ByteArray) - File content of the collection for passive liveness. It is present only if successfully captured. It is the return of the collection for passive liveness as JPEG ByteArray. This data can be saved/exported directly to a file or sent to the network (for networking: system encoding can be easily done, e.g. Base64 string).

The originalPhoto and croppedPhoto properties return null when the capture is performed only for passive tests (i.e., without including an active test).

If the user aborts the capture, closing before capturing the biometrics, the method faceCaptureDidAbort will be called. You can implement this method to treat this scenario.

Sample Project

This is a functional sample project for a face capture using BCC Mobile Face Android:

Last updated

Was this helpful?