Skip to main content
Version: 3.23.1

Flutter isolate sample

The sample demonstrates the use of the Face SDK plugin for Flutter and includes the following features:

  • Face detection on images captured from the front or rear camera of the device.
  • Face detection on video streams from the front camera, Liveness check, image quality assessment.

Requirements

  • Flutter from 3.3.0 to 3.16.3
  • Dart from 2.17.0 to 3.2.3
  • Latest models installed
  • Android or iOS device

Run the sample

  1. Install the "flutter" component using the Face SDK installer or the maintenancetool utility:

    • If Face SDK is not installed, follow the installation instructions in the Getting Started section. Select the "flutter" component in the "Component selection" section.

    • If Face SDK is installed without the "flutter" component (the flutter directory is absent in the Face SDK root directory), use the maintenancetool to install the "flutter" component by selecting it in the "Component Selection" section.

  2. Connect your Android or iOS device to the computer.

  3. Run the script examples/flutter/scripts/isolates_demo.sh or examples/flutter/scripts/isolates_demo.bat and pass the path to FaceSDK.

  4. Copy the lib folder from the flutter directory to examples/flutter/isolates_demo/assets.

  5. Build and run the sample using the console or through Android Studio (see below).

Run from the console

To run the sample from the console, navigate to the directory examples/flutter/isolates_demo and execute the following commands:

flutter pub get
flutter pub upgrade
flutter run --release
Debugging
  • Use Flutter stable version 3.3.0 or higher. You can select and download the Flutter distribution for your operating system from the link provided.

  • Add the path to the bin directory of the Flutter distribution to the PATH environment variable. Instructions for adding environment variables are available here for Linux and MacOS, and here for Windows.

Run the sample through Android Studio

To run the sample through Android Studio:

  • Open the folder examples/flutter/isolates_demo in Android Studio.
  • In Android Studio,
    • Open the file isolates_demo/pubspec.yaml and click on the "Pub get" button.
    • Click on the "Run" button.
Debugging
  • Use Flutter stable version 3.3.0 or higher. You can select and download the Flutter distribution for your operating system from the link provided.

  • Specify the path to the Flutter distribution in the Android Studio settings: "File" > "Settings" > "Languages & Frameworks" > "Flutter".

  • Install the Flutter and Dart plugins in Android Studio. The list of installed plugins and the Marketplace for their installation are available in the Android Studio settings: "File" > "Settings" > "Plugins".

Functionality description

After launching the sample, the device screen displays a start screen with a "Start" button. Press the "Start" button to enter the "Detecting faces on photo" mode.

Detecting faces on photo

In the "Detecting Faces On Photo" mode, the device screen displays a preview from the device camera. At the top of the screen, there is an instruction "Take a photo of the document". At the bottom of the screen, there are buttons "Take a photo" (bottom left) and "Change Camera" (bottom right).

To continue, you need to photograph a document with a face image. Press the "Take a photo" button (bottom left) to take a picture; image quality is also checked. After that, the device screen will display the photo "Detected faces", with the detected face highlighted by a bounding box.

After detecting the face and successfully checking the photo quality, the "Next" button (bottom right) will appear on the screen to proceed to the Liveness check mode.

Liveness check

For the Liveness check to pass correctly, there should be only one face in the camera frame. The Liveness check starts automatically upon face detection.

During the Liveness check, a bounding box is displayed, along with the current Liveness check state and image quality beneath the box.

Upon passing the Liveness check, the current Liveness state will change to "Real" or "Fake", and the "Next" button (bottom right) will appear to proceed to face assessment results.

After pressing the "Next" button, the following results will be displayed on the device screen:

  • Match score: The assessment of the match between the face in the photo and the face that passed the Liveness check. A maximum value of 1 indicates that the faces belong to the same person.
  • Is same person: Verdict on whether the face belongs to the same person, with values "true" or "false".
  • Liveness passed: Verdict on the Liveness check passing, with values "true" or "false".

Below the results, there will be a "Next" button. Pressing it will return you to the start screen.