# FaceRecognition - Flutter

## Overview

The demo project demonstrates both Face Liveness Detection and Face Recognition Technology.

It stands for face recognition Flutter, facial recognition Flutter, face liveness check Flutter, spoofing prevention Flutter, face matching Flutter, face comparison Flutter, face search engine Flutter, face identification Flutter.

## Github

{% embed url="<https://github.com/kby-ai/FaceRecognition-Flutter>" %}

## Google Play

{% embed url="<https://play.google.com/store/apps/details?id=com.kbyai.facerecognition>" %}

## App Store

{% embed url="<https://apps.apple.com/us/app/kby-ai-face-recognition/id6448648922>" %}

## YouTube

{% embed url="<https://youtu.be/HpDggnWsG1c>" %}

## Screenshots

<div><figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2FHt8DuxxyAaZZj98F6u4q%2Ff-menu.png?alt=media&#x26;token=f540f2e9-a982-46c8-a306-ac60d8eef747" alt=""><figcaption></figcaption></figure> <figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2Fp10zvNkemkp0nMSqyuhl%2Ff-result.png?alt=media&#x26;token=45674cf3-4fb9-42ea-add3-7157053cad81" alt=""><figcaption></figcaption></figure> <figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2F0BqoLRrbnEYFYsITysez%2Ff-settings.png?alt=media&#x26;token=35873e36-9479-479b-8bbb-6d2a61503ef5" alt=""><figcaption></figcaption></figure></div>

<div><figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2Frl9CVUXISljp8KvxeNCE%2Ff-help.png?alt=media&#x26;token=8095c540-4a4d-43b6-b6e0-325d4e10c712" alt=""><figcaption></figcaption></figure> <figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2FDKK5QdXAuimqH41uOgre%2Ff-spoof.png?alt=media&#x26;token=81f53fcd-1f85-4aca-9d83-b00849dff6eb" alt=""><figcaption></figcaption></figure> <figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2FoqrlJzIhky3KCCUVb6Im%2Ff-real.png?alt=media&#x26;token=2fd97521-726a-483b-802b-e1e07041fcf6" alt=""><figcaption></figcaption></figure></div>

## How to Run

### 1. Flutter Setup

Make sure you have Flutter installed.

We have tested the project with Flutter version 3.10.2.

If you don't have Flutter installed, please follow the instructions provided in the official Flutter documentation:

{% embed url="<https://docs.flutter.dev/get-started/install>" %}

### 2. Running the App

Run the following commands:

```bash
flutter clean
flutter pub get
flutter run
```

If you plan to run the iOS app, please refer to the following link for detailed instructions:

{% embed url="<https://docs.flutter.dev/deployment/ios>" %}

## FaceSDK Plugin

### 1. Setup

#### 1.1 \`Face SDK\` Setup

> Android

* Copy the SDK (`libfacesdk` folder) to the `android` folder in your project.
* Add SDK to the project in `settings.gradle`

```gradle
include ':libfacesdk'
```

#### 1.2 \`FaceSDK Plugin\` Setup

* Copy `facesdk_plugin` folder to the root folder of your project.
* Add the dependency in `pubspec.yaml` file.

```yaml
  facesdk_plugin:
    path: ./facesdk_plugin
```

* Import the `facesdk_plugin` package.

```dart
  import 'package:facesdk_plugin/facesdk_plugin.dart';
  import 'package:facesdk_plugin/facedetection_interface.dart';
```

### 2. API Usage&#x20;

#### 2.1 FacesdkPlugin

* Activate the `FacesdkPlugin` by calling the `setActivation` method:

```dart
  final _facesdkPlugin = FacesdkPlugin();
  ...
  await _facesdkPlugin
          .setActivation(
              "Os8QQO1k4+7MpzJ00bVHLv3UENK8YEB04ohoJsU29wwW1u4fBzrpF6MYoqxpxXw9m5LGd0fKsuiK"
              "fETuwulmSR/gzdSndn8M/XrEMXnOtUs1W+XmB1SfKlNUkjUApax82KztTASiMsRyJ635xj8C6oE1"
              "gzCe9fN0CT1ysqCQuD3fA66HPZ/Dhpae2GdKIZtZVOK8mXzuWvhnNOPb1lRLg4K1IL95djy0PKTh"
              "BNPKNpI6nfDMnzcbpw0612xwHO3YKKvR7B9iqRbalL0jLblDsmnOqV7u1glLvAfSCL7F5G1grwxL"
              "Yo1VrNPVGDWA/Qj6Z2tPC0ENQaB4u/vXAS0ipg==")
          .then((value) => facepluginState = value ?? -1);  
```

* Initialize the `FacesdkPlugin`:

```dart
await _facesdkPlugin
          .init()
          .then((value) => facepluginState = value ?? -1)
```

* Set parameters using the `setParam` method:

```dart
await _facesdkPlugin
        .setParam({'check_liveness_level': livenessLevel ?? 0})
```

* Extract face feature using the `extractFaces` method:

```dart
final faces = await _facesdkPlugin.extractFaces(image.path)
```

* Calculate similarity between faces using the `similarityCalculation` method:

```dart
double similarity = await _facesdkPlugin.similarityCalculation(
              face['templates'], person.templates) ??
          -1;
```

#### 2.2 FaceDetectionInterface

To build the native camera screen and process face detection, please refer to the following file in the Github repository.

This file contains the necessary code for implementing the camera screen and performing face detection.

{% embed url="<https://github.com/kby-ai/FaceRecognition-Flutter/blob/main/lib/facedetectionview.dart>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kby-ai.com/help/demo-projects/mobile-android-ios/facerecognition-flutter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
