Mobile FCM

AI Tools

Mobile Face Capture Module (FCM) uses native APIs for face detection and image processing, which keeps our library small in size. This module leverages Google ML Kit for Android and Apple's Vision Library for iOS. Facial images are captured with the front-facing camera. The captured frames are analysed by the module and are cropped automatically, which can then be sent to the Yoti backend API for the age estimation & liveness check.

Secure Image Capture (SICAP)

SICAP is currently only supported in Web FCM. If you prefer to use mobile-native FCM, you should implement code obfuscation, signature verification and encryption within your own application to block injection attacks.

There are two steps to integrate the Mobile FCM:

  1. Install the dependency

  2. Integrate the module into your application


Install the dependency

Yoti currently supports:

  • Android

  • iOS

  • React Native

Prerequisite

System requirements

Minimum supported version

Android SDK/API Level

21

Camera permission is required to allow capturing the facial image.

<uses-feature android:name="android.hardware.camera.any" /> <uses-permission android:name="android.permission.CAMERA" />

System requirements

Minimum supported version

iOS

13

Swift

5.5

Camera permission is required to allow capturing the facial image.

<key>NSCameraUsageDescription</key> <string>We need access to your camera to let you take photos and record video.</string>

System requirements

Minimum supported version

Android SDK/API Level

21

iOS

12

Swift

5.3

React Native

0.59

Camera permission is required to allow capturing the facial image. If your application does not request camera access from the user already, you may consider an in-built approach such as PermissionsAndroid. Alternatively, you may use community libraries like React Native Permissions.

Installation

We offer two options, bundled and unbundled, to add this module to your app.

Version

Size (armeabi-v7a)

Size (arm64-v8a)

Description

Bundled

11.6 MB

15.2 MB

This includes an embedded model for face detection.

Unbundled

2.3 MB

2.7 MB

Face detection model will be installed via Google Play Services at the first application launch.

(1) Bundled version

To integrate the bundled version, simply add the line below to the gradle.properties file.

implementation 'com.yoti.mobile.android:face-capture-bundled:4.8.1'

(2) Unbundled version

To integrate the unbundled version, add the following line to the gradle.properties file.

implementation 'com.yoti.mobile.android:face-capture-unbundled:4.8.1'

It is recommended to add the following metadata to your manifest.xml to get the model downloaded as soon as the app is installed.

<application ...> ... <meta-data android:name="com.google.firebase.ml.vision.DEPENDENCIES" android:value="face" /> </application>

There are three installation options. You can install the package through:

(1) Swift Package Manager

Add the following line to your Package.swift file:1

.package(url: "https://github.com/getyoti/yoti-face-capture-ios.git", from: "9.0.1")

(2) Xcode Package Dependency

Add the package in Xcode via File -> Swift Packages -> Add Package Dependency using the URL of the iOS SDK repository (https://github.com/getyoti/yoti-face-capture-ios)

(3) Podfile

Add the following code to your Podfile and run pod install from its directory:

platform :ios, '13.0' target 'TargetName' do use_frameworks! pod 'YotiFaceCapture' end

Install the module with Yarn or npm.

npm install @getyoti/react-native-yoti-face-capture
yarn add @getyoti/react-native-yoti-face-capture

Then, navigate to your iOS folder and install pods with the pod install command. React Native's autolinking will handle the rest of the native configuration. Should autolinking fail, consult the troubleshooting instructions.

For React Native 0.59.x installation

Manually link the module with the following command.

react-native link @getyoti/react-native-yoti-face-capture

If you're using CocoaPods, update your Podfile with the following lines and run pod install :

pod 'Folly', :podspec => '../nodemodules/react-native/third-party-podspecs/Folly.podspec'

pod 'react-native-yoti-face-capture', :path => '../node modules/react-native-yoti-face-capture/react-native-yoti-face-capture.podspec'


Example integration

Below is the example code for FCM integration.

import com.yoti.mobile.android.capture.face.demo.R import com.yoti.mobile.android.capture.face.ui.models.camera.CameraConfiguration import com.yoti.mobile.android.capture.face.ui.models.face.FaceCaptureConfiguration import com.yoti.mobile.android.capture.face.ui.models.face.ImageQuality // Configure the camera val cameraConfiguration = CameraConfiguration() // Configure your module val configuration = FaceCaptureConfiguration( FaceCaptureConfiguration.FACE_CENTER, ImageQuality.MEDIUM, requireValidAngle = true, requireEyesOpen = true, requireBrightEnvironment = true, requiredStableFrames = 3, provideLandmarks = true, provideSmileScore = true, isSelfCheckOutMode = false ) // Retrieve your view val faceCapture = findViewById < FaceCapture > (R.id.faceCapture) // Start the camera faceCapture.startCamera(this, :: onCameraState, cameraConfiguration) // Start the analysis faceCapture.startAnalysing(configuration, :: onFaceCaptureResult)

More details can be found in our GitHub repository. A sample app is available here for reference.

import YotiFaceCapture // Fetch FaceCaptureViewController from framework and set delegate let faceCaptureViewController = FaceCapture.faceCaptureViewController() faceCaptureViewController.delegate = self // Configure the capture let faceCaptureConfiguration = Configuration( faceCenter: CGPoint(x: 0.5, y: 0.5), imageQuality: .medium, validationOptions: [.faceNotStraight], discardsLateAnalysisResults: true ) // Start the camera feed faceCaptureViewController.startCamera() // Start the analysis faceCaptureViewController.startAnalyzing(withConfiguration: faceCaptureConfiguration)

More details can be found in our GitHub repository. A sample app is available here for reference.

import React, { PixelRatio, useRef, useWindowDimensions } from 'react'; // Image quality options import YotiFaceCapture, { IMAGE_QUALITY_MEDIUM } from "react-native-yoti-face-capture"; function App() { const yotiFaceCaptureRef = useRef(null); const windowHeight = useWindowDimensions().height; const windowWidth = useWindowDimensions().width; return ( <YotiFaceCapture imageQuality={IMAGE_QUALITY_MEDIUM} ref={YotiFaceCaptureRef} requireEyesOpen={false} requiredStableFrames={3} requireValidAngle requireBrightEnvironment faceCenter={[0.5, 0.5]} onFaceCaptureAnalyzedImage={({ nativeEvent: analysis }) => { // analysis.croppedImage // analysis.croppedFaceBoundingBox // analysis.faceBoundingBox // analysis.originalImage }} onFaceCaptureImageAnalysisFailed={({ nativeEvent: failure }) => { // failure.cause // failure.originalImage }} onFaceCaptureStateChanged={({ nativeEvent: state }) => { // state may either be 'Analyzing', 'CameraReady' or 'CameraStopped' }} onFaceCaptureStateFailed={({ nativeEvent: failure }) => { // failure may either be 'CameraInitializationError' or 'MissingPermissions' }} /> ) }

More details can be found in our GitHub repository. A sample app is available here for reference.


Error codes

Error code

Description

FaceNotStraight

The picture must be taken with a tilt angle no bigger than 30 degrees.

EyesClosed

Eyes must be open when taking the photos.

EnvironmentTooDark

The environment luminosity is below a pre-determined threshold. Try again with a brighter environment.

FaceNotStable

Blurry images are being captured. A number of frames are taken as similar as possible in terms of width/height and x/y position.

AnalysisError

The device is not compatible with the SDK, and the capture analysis cannot be performed. We recommend that you fall back to manual capture mode (for details, please check the sample app) if this error happens, so that the user can perform a manual capture.

NoFaceDetected

Face is not detected in the capture area.

MultipleFacesDetected

Multiple faces are detected in the view. Only one face is allowed.

FaceTooSmall

The face is too small. Move closer to the camera.

FaceTooBig

The face is too big. Move away from the camera.

FaceNotCentered

The face is not positioned at the center of the camera.

Error code

Description

cameraNotAccessible

Camera permissions not authorized

cameraInitializingError

Camera initialization failed

faceAnalysisFailed

The device is not compatible with the SDK, and the capture analysis cannot be performed.

noFaceDetected

Face is not detected in the capture area.

multipleFaces

Multiple faces are detected in the view. Only one face is allowed.

eyesNotOpen

Eyes must be open when taking the photos.

faceTooSmall

The face is too small. Move closer to the camera.

faceTooBig

The face is too big. Move away from the camera.

faceNotCentered

The face is not positioned at the center of the camera.

faceNotStable

Blurry images are being captured. A number of frames are taken as similar as possible in terms of width/height and x/y position.

faceNotStraight

The picture must be taken with a tilt angle no bigger than 30 degrees.

environmentTooDark

The environment luminosity is below a pre-determined threshold. Try again with a brighter environment.

Error code

Description

FaceCaptureAnalysisErrorEyesNotOpen

Eyes must be open when taking the photos.

FaceCaptureAnalysisErrorFaceNotStable

Blurry images are being captured. A number of frames are taken as similar as possible in terms of width/height and x/y position.

FaceCaptureAnalysisErrorFaceNotStraight

The picture has to be taken with a tilt angle no bigger than 30 degrees.

FaceCaptureAnalysisErrorEnvironmentTooDark

The picture has to be taken in a bright environment.

FaceCaptureStateErrorCameraInitializingError

There was an error initialising the camera.

FaceCaptureStateErrorCameraNotAccessible

The Face Capture does not have sufficient permissions to access the camera.

FaceCaptureStateErrorInvalidState

The Face Capture is in an invalid state.

FaceCaptureAnalysisErrorFaceTooBig

The face is too big. Move away from the camera.

FaceCaptureAnalysisErrorFaceTooSmall

The face is too small. Move closer to the camera.

FaceCaptureAnalysisErrorNoFaceDetected

Face is not detected in the capture area.

FaceCaptureAnalysisErrorFaceNotCentered

The face is not positioned at the center of the camera.

FaceCaptureAnalysisErrorFaceAnalysisFailed

The device is not compatible with the SDK, and the capture analysis cannot be performed.

FaceCaptureAnalysisErrorMultipleFaces

Multiple faces are detected in the view. Only one face is allowed.