# About RECOGNITO

NIST FRVT TOP #1 Face Recognition Algorithm Developer

<figure><img src="/files/PTQI6q7mFiwqx08TTLDh" alt=""><figcaption><p><a href="https://recognito.vision">https://recognito.vision</a></p></figcaption></figure>

**RECOGNITO** is a global leader and trusted provider of face biometric and ID document verification solutions that are fully optimized for usability, security, and privacy.&#x20;

With RECOGNITO's **NIST FRVT Top 1 Face Recognition** technology, clients provide safer environments for their valued customers, patients, guests, employees, and associates.&#x20;

## Product

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th align="center"></th><th></th><th></th><th></th><th data-hidden></th><th data-hidden></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Face Recognition SDK</strong></td><td align="center"></td><td>🏆 NIST FRVT Top 1 Face Recognition</td><td> 1:1 Face Matching, 1:N Face Identification</td><td></td><td></td><td></td><td></td><td><a href="/pages/ArDkWzEZ8zEzzgBwMdVl">/pages/ArDkWzEZ8zEzzgBwMdVl</a></td></tr><tr><td><strong>Face Liveness Detection SDK</strong></td><td align="center"></td><td>2D/3D Passive Liveness Detection  </td><td>DeepFake Detection</td><td></td><td></td><td></td><td></td><td><a href="/pages/IMJkbM8Pd0F2kUkENdRI">/pages/IMJkbM8Pd0F2kUkENdRI</a></td></tr><tr><td><strong>ID Document Recognition SDK</strong></td><td align="center"></td><td>14k+ Document Types</td><td>250+ Countries &#x26; Territories</td><td>140+ Languages &#x26; Scripts</td><td></td><td></td><td></td><td><a href="/pages/etAIr46ZpoJ62O9Tsb5R">/pages/etAIr46ZpoJ62O9Tsb5R</a></td></tr><tr><td><strong>ID Document Liveness Detection SDK</strong></td><td align="center"></td><td>Screen Replay Attacks</td><td>Printed Copy Attacks</td><td>Portrait Replace Attacks</td><td></td><td></td><td></td><td><a href="/pages/sFglztiaf9ca56fX3f0R">/pages/sFglztiaf9ca56fX3f0R</a></td></tr></tbody></table>

## Online Demo

{% embed url="<https://recognito.vision/face-biometric-playground/>" %}

{% embed url="<https://recognito.vision/id-document-verification-playground/>" %}

## Feature

* **On-premise**, **Fully offline** and **On-device** SDK
* Compact **Library-type** SDK for easy on-premise installation.
* **Simple and comprehensive** API.
* **Licensing model** based on the actual use of the system.

## Platform

&#x20;  Android, iOS, Windows and Linux platforms.

## Application

* eKYC
* ID verification
* Digital onboarding
* Online banking
* Payments
* Shops self-checkout
* Government e-services
* Social networks and media sharing service

[![Visitors](https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fdocs.recognito.vision%2F\&label=VISITORS\&countColor=%23263759)](https://visitorbadge.io/status?path=https%3A%2F%2Fdocs.recognito.vision%2F)


# Performance Overview

NIST FRTE Top 1 Face Recognition Algorithm

In **Face Recognition Vendor Test (FRVT) | NIST (National Institute of Standards and Technology)**, RECOGNITO's facial recognition algorithm scored among the top algorithms in both 1:1 verification and 1:N identification scenarios.

**In particular,** **the&#x20;***<mark style="color:purple;">**recognito-001**</mark>***&#x20;algorithm currently ranks Top 1 in NIST FRVT 1:1 verification performance.**

<figure><img src="/files/ezCsxGosarknHYwWR6eM" alt=""><figcaption><p><a href="https://pages.nist.gov/frvt/html/frvt11.html">FRTE 1:1 Performance Latest Update [2024-04-17]</a></p></figcaption></figure>

{% hint style="info" %}
FRVT used 1999 to 2023 is being retired.

FRVT has been rebranded and split into **FRTE (Face Recognition Technology Evaluation)** and **FATE (Face Analysis Technology Evaluation)**.
{% endhint %}

## Technology evaluation in NIST FRTE 1:1 Verification

RECOGNITO algorithm(*<mark style="color:purple;">**recognito\_000, recognito\_001**</mark>*) ranked Top 1 in **NIST FRTE 1:1 verification** performance among 570 vendors.

The table shows the top performing 1:1 algorithms measured on **false non-match rate** (**FNMR**) across several different datasets.

<figure><img src="/files/fQ77r4I85f4FVFvsikgr" alt=""><figcaption><p><a href="https://pages.nist.gov/frvt/html/frvt11.html">FRTE 1:1 Performance Latest Update [2024-04-17]</a></p></figcaption></figure>

## FALSE NON-MATCH RATE (FNMR)

**FNMR** is the proportion of mated comparisons below a threshold set to achieve the FMR given in the header on the fourth row. **FMR** is the proportion of impostor comparisons at or above that threshold. **The light grey values give rank over all algorithms in that column.**&#x20;

<figure><img src="/files/iN2am0dRRxJur7fZoU7V" alt=""><figcaption><p>FALSE NON-MATCH RATE (FNMR)</p></figcaption></figure>

## Summary FNMR value in FRTE 1:1&#x20;

The 3rd column is summary FNMR value (so that readers can look at the more accurate algorithms first)

<figure><img src="/files/1JuYpvCc3tQuU9kfdTXx" alt=""><figcaption><p>Summary FNMR value in FRTE 1:1</p></figcaption></figure>

## Comparison of FNMR values ​​according to dataset

### - Dataset: VISA vs BORDER | FNMR @ FMR = 0.000001

The test was performed by comparing high-quality images from the **VISA** dataset against lower quality images from the **BORDER** dataset. Both datasets include subjects from more than 100 countries, with specific imbalances due to visa issuance patterns and border-crossing demographics correspondingly.

RECOGNITO algorithm accuracy in this scenario was **0.16% FNMR (Top1)** at 0.0001% FMR.&#x20;

<figure><img src="/files/Drpu5PRb43u9byrVxDKg" alt=""><figcaption><p>Dataset: VISA vs BORDER | FNMR @ FMR = 0.000001 and Algorithm (Submission Date)</p></figcaption></figure>

### - Dataset: VISA | FNMR @ FMR = 0.000001

The dataset represents typical photos of US visa applicants. The face images are generally high quality. Part of the images are live capture and the other part is photographed from paper photos.

RECOGNITO algorithm accuracy in this scenario was **0.06% FNMR** **(Top1)** at 0.0001% FMR.&#x20;

<figure><img src="/files/XSshS3NROmnCsM16VHjM" alt=""><figcaption><p>Dataset: VISA | FNMR @ FMR = 0.000001 and Algorithm (Submission Date)</p></figcaption></figure>

### - Dataset: MUGSHOT | FNMR @ FMR = 0.000010

The dataset represents typical photos of suspects taken by law enforcement officers. The photos were taken in a controlled environment thus their quality is high.

RECOGNITO algorithm accuracy in this scenario was **0.21% FNMR** **(Top1)** at 0.001% FMR.&#x20;

<figure><img src="/files/sykOA9swF9G1GRlswi5U" alt=""><figcaption><p>Dataset: MUGSHOT | FNMR @ FMR = 0.000010 and Algorithm (Submission Date)</p></figcaption></figure>

**RECOGNITO Face Recognition Algorithm also has been tested by hundreds of our Partners & Customers.**


# Integration Guide


# Linux

Face Recognition SDK for Linux

This guide introduces RECOGNITO Linux-Face Recognition SDK (updated version) for onboarding & eKYC cases.

&#x20;After completing this guide, you will have downloaded SDK, run the Demo, tested each SDK APIs, and successfully integrated SDK into Your Application!

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Linux-Face Recognition SDK (updated version)</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">C++/Python</td></tr><tr><td><strong>Face Detection</strong></td><td align="center">Single Face [Multiple Faces Detection Expandable]</td></tr><tr><td><strong>Face Feature Extraction</strong></td><td align="center">Yes, 2048bytes (512 x Float32, Little endian)</td></tr><tr><td><strong>Face Liveness Detection</strong></td><td align="center">No</td></tr><tr><td><strong>Face Attribute Analysis</strong></td><td align="center">No</td></tr><tr><td><strong>1:N Identifiability</strong></td><td align="center">Expandable</td></tr><tr><td><strong>Inference Time</strong><br>(1 face template extraction)</td><td align="center">&#x3C; 280ms, Intel(R) Xeon(R) Gold 5315Y CPU @ 3.20GHz CPU: 8, RAM: 40 GB</td></tr></tbody></table>

{% hint style="info" %}
[How to implement 1:N identification with RECOGNITO SDK?](/how-to-implement-1-n-identification-with-recognito-sdk)
{% endhint %}

## Recommended System Requirements

* **Operating System:** Ubuntu 20.04 or 22.04
* **CPU:** 8 cores
* **RAM:** 8 GB
* **HDD:** 8 GB


# Installation

## Download SDK

Download [**face-recognition\_engine.zip \[191.1M\]**](https://www.dropbox.com/scl/fi/xnoykpxw3idxz9lhtxxax/face-recognition_engine.zip?rlkey=ilbg5rehu1hiz2oz72kout4ed\&st=8s19qd70\&dl=0)

Unpack the `face-recognition_engine.zip` archive into the desired directory.

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th width="227"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td><strong>openvino\</strong></td><td>openvino so files</td></tr><tr><td></td><td>libimutils.so</td><td>libimutils so file for Ubuntu20.04</td></tr><tr><td></td><td>libimutils.so_for_ubuntu22</td><td>libimutils so file for Ubuntu22.04</td></tr><tr><td><strong>engine\</strong></td><td><strong>bin\</strong></td><td>SDK binary files</td></tr><tr><td></td><td>header.py</td><td>Header file</td></tr><tr><td></td><td>librecognition_v6.so</td><td>SDK so file</td></tr></tbody></table>

## Install dependencies

* Install packages and requirements:

{% code overflow="wrap" %}

```sh
sudo apt-get update -y && sudo apt-get install -y python3 python3-pip libcurl4-openssl-dev libssl-dev libtbb-dev
```

{% endcode %}

* Copy dependency libraries:

{% code overflow="wrap" %}

```sh
sudo cp -f dependency/libimutils.so /usr/lib
sudo cp -rf dependency/openvino /usr/lib
```

{% endcode %}

{% hint style="warning" %}
If the Ubuntu version is 22.04:

{% code overflow="wrap" %}

```sh
sudo cp -f dependency/libimutils.so_for_ubuntu22 /usr/lib/libimutils.so
```

{% endcode %}
{% endhint %}


# API Reference

### get\_version

```python
def get_version() -> str:
```

<table data-header-hidden><thead><tr><th width="136"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>get_version</td></tr><tr><td><strong>Description</strong></td><td>Retrieves the SDK version information from a library.</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td>The version string is returned as a standard Python string.</td></tr></tbody></table>

### get\_device\_id <a href="#get_device_id" id="get_device_id"></a>

```python
def get_device_id() -> str:
```

<table data-header-hidden><thead><tr><th width="136"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>get_device_id</td></tr><tr><td><strong>Description</strong></td><td>Retrieves the Hardware ID from a library.</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td>The Hardware ID is returned as a standard Python string.</td></tr></tbody></table>

### init\_sdk

{% code overflow="wrap" %}

```python
def init_sdk(dict_path: str, online_key: str) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init_sdk</td></tr><tr><td><strong>Description</strong></td><td>Initializes the SDK in online mode.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>dict_path</strong> (str): Path to the engine binary files directory</li><li><strong>online_key</strong> (str): Online key string </li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of the initialization.</p><ul><li>0: Success</li><li>Non-zero: Initialization failed</li></ul></td></tr></tbody></table>

### init\_sdk\_offline

{% code overflow="wrap" %}

```python
def init_sdk_offline(dict_path: str, offline_key_path: str) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init_sdk_offline</td></tr><tr><td><strong>Description</strong></td><td>Initializes the SDK in offline mode.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>dict_path</strong> (str): Path to the engine binary files directory</li><li><strong>offline_key</strong> (str): Path to the offline license key file</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of the initialization.</p><ul><li>0: Success</li><li>Non-zero: Initialization failed</li></ul></td></tr></tbody></table>

### extract\_template

{% code overflow="wrap" %}

```python
def extract_template(image: np.ndarray, width: int, height: int, face_bbox: np.ndarray, template: np.ndarray, template_len: np.ndarray) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>extract_template</td></tr><tr><td><strong>Description</strong></td><td>Extracts a template from an image</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>image</strong> (numpy.ndarray): Input image matrix</li><li><strong>width</strong> (int): Width of the input image</li><li><strong>height</strong> (int): Height of the input image</li><li><strong>face_bbox</strong> (numpy.ndarray): Face bounding box coordinates. Extracted face bbox will be stored</li><li><strong>template</strong> (numpy.ndarray): Template buffer. Extracted template will be stored</li><li><strong>template_len</strong> (numpy.ndarray): Length of the extracted template</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of the template extraction.</p><ul><li>>0: Success</li><li>0: No Face</li><li>-1: SDK Activation Error</li><li>-2: SDK Initialization Error</li></ul></td></tr></tbody></table>

### calculate\_similarity

```python
def calculate_similarity(feature_1: np.ndarray, feature_2: np.ndarray) -> float:
```

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>calculate_similarity</td></tr><tr><td><strong>Description</strong></td><td>Calculates the similarity between two features</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>feature_1</strong> (numpy.ndarray): 1st feature</li><li><strong>feature_2</strong> (numpy.ndarray): 2nd feature</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Similarity score between the two features</p><p>The score ranges from 0.0 to 1.0<br><strong>Default Threshold is 0.67</strong></p></td></tr></tbody></table>


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your HWID (Hardware ID)

To activate SDK, you have to first get your Hardware ID by using the [get\_device\_id ](/face-recognition-sdk/integration-guide/linux/api-reference#get_device_id)function.

<figure><img src="/files/RoLliKfnYsiEqb7h0Raw" alt=""><figcaption></figcaption></figure>

## Request License

After getting HWID, share it with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Initializes ](/face-recognition-sdk/integration-guide/linux/api-reference#init_sdk_offline)the SDK with license key. Should be called before using of any other functions.

```python
init_sdk_offline("engine/bin", "license.txt")
```


# Sample Application

Linux-Face Recognition SDK(updated version) Flask, Gradio Demo (1:1 Matching)

{% hint style="info" %}
**Looking for 1:N face search demo?**

<https://github.com/recognito-vision/Linux-FaceRecognition-FaceLivenessDetection/tree/main/Identification(1%3AN)-Demo>
{% endhint %}

***

## Docker

Pull the Docker image and run the container:

{% code overflow="wrap" %}

```sh
sudo docker pull recognito/face-recognition:latest
sudo docker run -it -e FR_LICENSE_KEY="XXXXX-XXXXX-XXXXX-XXXXX" -p 8001:8000 -p 7861:7860 recognito/face-recognition:latest [OPTION --gradio(-g), --flask(-f)]
```

{% endcode %}

***

## Installation

### - Download

Download [**FaceRecognition-Demo.zip\[191M\]**](https://www.dropbox.com/scl/fi/vm876tpz4c3l8sg54qei5/FaceRecognition-Demo.zip?rlkey=hins6w1t55stu1lwsdfhu2gxf\&st=r5a8n4rn\&dl=0)

The Demo directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="206"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td>Dependency files</td></tr><tr><td><strong>engine\</strong></td><td>SDK engine files</td></tr><tr><td><strong>examples\</strong></td><td>Sample images for face recognition</td></tr><tr><td><strong>flask\</strong></td><td>Flask server side demo code</td></tr><tr><td><strong>gradio\</strong></td><td>Gradio demo code</td></tr><tr><td>Dockerfile</td><td>Dockerfile for building a Docker image</td></tr><tr><td>install.sh</td><td>Script for install environment</td></tr><tr><td>license.txt</td><td>License key file</td></tr><tr><td>run_demo.sh</td><td>Script for run demo</td></tr></tbody></table>

### - Install dependencies

Run the `install.sh` script to install dependencies:

```sh
./install.sh
```

### - Setting Up SDK License Key

* **Online Licensing:** Set the online license key as an environment variable:

{% code overflow="wrap" %}

```sh
export FR_LICENSE_KEY="XXXXX-XXXXX-XXXXX-XXXXX"
```

{% endcode %}

* **Offline Licensing:** Copy the `license.txt` license file to the demo directory.

***

## Test

### - Run Demo

Run the demo script with the desired option:

{% code overflow="wrap" %}

```sh
./run_demo.sh [OPTION --gradio(-g), --flask(-f), --help(-h)]
```

{% endcode %}

<figure><img src="/files/TQ3RxnaUkPE7wjziljCv" alt=""><figcaption></figcaption></figure>

### - Test Flask Server APIs

To test the Flask Server API, you can use [Postman](https://www.postman.com/downloads/). Here are the endpoints for testing:

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/compare\_face

&#x20; Perform face match between two face image files

&#x20;   **Parameters**

&#x20;        **image1:** image file for the 1st face

&#x20;        **image2:** image file for the 2nd face

&#x20;   **Response**&#x20;

&#x20;        **result:** face match result

&#x20;        **similarity:** similarity between two faces

&#x20;        **detection:** face bounding boxes of two faces

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/compare\_face\_base64

&#x20; Perform face match between two face base64 images

&#x20;   **Parameters**

&#x20;        **image1:** base64 image for the 1st face

&#x20;        **image2:** base64 image for the 2nd face

&#x20;   **Response**&#x20;

&#x20;        **result:** face match result

&#x20;        **similarity:** similarity between two faces

&#x20;        **detection:** face bounding boxes of two faces

<figure><img src="/files/5qBAi2lGDilO349HAokh" alt=""><figcaption><p>Postman usage guide for Flask Demo</p></figcaption></figure>

### - Test Gradio

Go to <http://127.0.0.1:7860/> on a web browser.

<figure><img src="/files/hrzWbe7YJzOaSy3Zk0xq" alt=""><figcaption><p>Gradio Demo</p></figcaption></figure>


# Windows

Face Recognition SDK for Windows

This guide introduces RECOGNITO Windows-Face SDK for onboarding & eKYC.

&#x20;After completing this guide, you will have downloaded SDK, run the Demo, tested each SDK APIs, and successfully integrated SDK into Your Application!

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Windows-Face SDK</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">C++/Python</td></tr><tr><td><strong>Face Detection</strong></td><td align="center">Multiple Faces</td></tr><tr><td><strong>Face Feature Extraction</strong></td><td align="center">Yes, 2056bytes</td></tr><tr><td><strong>Face Liveness Detection</strong></td><td align="center">Yes</td></tr><tr><td><strong>Face Attribute Analysis</strong></td><td align="center">Age, Gender, Mask, Glass</td></tr><tr><td><strong>1:N Identifiability</strong></td><td align="center">Yes</td></tr></tbody></table>

{% hint style="info" %}
[How to implement 1:N identification with RECOGNITO SDK?](/how-to-implement-1-n-identification-with-recognito-sdk)
{% endhint %}

## Recommended System Requirements

* **Windows System:** Windows 10 or later
* **CPU:** 8 cores
* **RAM:** 8 GB
* **HDD:** 8 GB


# Installation

## Download SDK

Download [**win\_engine(pwd\_123).rar \[123M\]**](https://www.dropbox.com/scl/fi/rh5hhyjwu11m91ov79o1l/win_engine-pwd_123.rar?rlkey=mpsip9dfw5dydvaq541lqp0jl\&st=j2tivykp\&dl=0)

Unpack the `win_engine(pwd_123).rar` archive into the desired directory. The password of archive file is `123`.

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th width="227"></th><th></th></tr></thead><tbody><tr><td><strong>dependency</strong></td><td>python-3.8.9.exe</td><td>Python executable file for Python version 3.8.9</td></tr><tr><td></td><td>VC_redist.2013.exe</td><td>Microsoft Visual C++ Redistributable Package for Visual Studio 2013</td></tr><tr><td></td><td>VC_redist.2015-2022.exe</td><td>Microsoft Visual C++ Redistributable Package for Visual Studio versions 2015 through 2022</td></tr><tr><td><strong>engine\</strong></td><td>header.py</td><td>Header file</td></tr><tr><td></td><td>hwid.txt</td><td>Hardware ID dump file</td></tr><tr><td></td><td>license.txt</td><td>License key file</td></tr><tr><td></td><td>libttvrecog.dll</td><td>SDK dll file 1</td></tr><tr><td></td><td>libttvsdk.dll</td><td>SDK dll file 2</td></tr><tr><td></td><td>ttvfacewrapper.dll</td><td>SDK dll file 3</td></tr><tr><td></td><td>opencv_world300.dll</td><td>OpenCV library version 3.0.0</td></tr></tbody></table>

## Install dependencies

* Install `python-3.8.9.exe`, `VC_redist.2013.exe`, `VC_redist.2015-2022.exe` files from `dependency` directory.

{% hint style="warning" %}
When install `python-3.8.9.exe`, have to tick the `Add Python3.8 to PATH` option.

<img src="/files/KH9f4qKZ6cPflsoxKEG7" alt="" data-size="original">
{% endhint %}


# API Reference

### init\_sdk

{% code overflow="wrap" %}

```python
def init_sdk() -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init_sdk</td></tr><tr><td><strong>Description</strong></td><td>Initializes the SDK.</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of the initialization.</p><ul><li>0: Success</li><li>Non-zero: Initialization failed</li></ul></td></tr></tbody></table>

### get\_attribute

{% code overflow="wrap" %}

```python
def get_attribute(image: np.ndarray, width: int, height: int, face_results: ctypes.POINTER(FaceResult), max_face_num: int, mode: int) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>get_attribute</td></tr><tr><td><strong>Description</strong></td><td>Detects and analyzes face.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>image</strong> (numpy.ndarray): Input image matrix</li><li><strong>width</strong> (int): Width of the input image</li><li><strong>height</strong> (int): Height of the input image</li><li><strong>face_results</strong> (ctypes.POINTER): Pointer to a structure containing face results</li><li><strong>max_face_num</strong> (int): Maximum number of faces to detect</li><li><strong>mode</strong> (int): 0-> Enroll mode, 1-> Identify mode</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of getting attribute.</p><ul><li>>0: Number of detected faces</li><li>0: No Face</li><li>otherwise: Error</li></ul></td></tr></tbody></table>

Here is **`FaceResult`** Structure.

```python
class FaceResult(Structure):
    _fields_ = [
        ("x1", c_int32),
        ("y1", c_int32),
        ("x2", c_int32),
        ("y2", c_int32),
        ("liveness", c_int32),
        ("mask", c_int32),
        ("glass", c_int32),
        ("age", c_int32),
        ("gender", c_int32),
        ("feature", c_ubyte * 2056)
    ]
```

<table data-header-hidden><thead><tr><th width="226"></th><th></th></tr></thead><tbody><tr><td><strong>(x1, y1)</strong></td><td>Coordinate of the top-left corner of the bounding box of the detected face.</td></tr><tr><td><strong>(x2, y2)</strong></td><td>Coordinate of the bottom-right corner of the bounding box of the detected face.</td></tr><tr><td><strong>liveness</strong></td><td><p>Liveness score of detected face</p><ul><li>0 -> SPOOF</li><li>1 -> REAL</li><li>-3 -> TOO SMALL FACE</li><li>-4 -> TOO LARGE FACE</li><li>-102 -> NO FACE</li><li>-103 -> LIVENESS CHECK FAILED</li></ul></td></tr><tr><td><strong>mask</strong></td><td><p>Mask detection of the detected face</p><ul><li>0 -> No, 1 -> Yes</li></ul></td></tr><tr><td><strong>glass</strong></td><td><p>Glass detection of the detected face</p><ul><li>0 -> No, 1 -> Yes</li></ul></td></tr><tr><td><strong>age</strong></td><td>Estimated age of the detected face</td></tr><tr><td><strong>gender</strong></td><td><p>Gender prediction of the detected face</p><ul><li>0 -> Male, 1 -> Female</li></ul></td></tr><tr><td><strong>feature</strong></td><td>Template buffer. Extracted template will be stored</td></tr></tbody></table>

### calculate\_similarity

{% code overflow="wrap" %}

```python
def calculate_similarity(feature_1: np.ndarray, feature_2: np.ndarray) -> float:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>calculate_similarity</td></tr><tr><td><strong>Description</strong></td><td>Calculates the similarity between two features</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>feature_1</strong> (numpy.ndarray): 1st feature</li><li><strong>feature_2</strong> (numpy.ndarray): 2nd feature</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Similarity score between the two features</p><p>The score ranges from 0.0 to 1.0<br><strong>Default Threshold is 0.82</strong></p></td></tr></tbody></table>


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your HWID (Hardware ID)

To activate SDK, you have to first get your Hardware ID by using the [init\_sdk](/face-recognition-sdk/integration-guide/windows/api-reference#init_sdk) function.

<figure><img src="/files/78qyOqybhetb1HQAKd9r" alt=""><figcaption></figcaption></figure>

## Request License

After getting HWID, share it with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Initializes](/face-recognition-sdk/integration-guide/windows/api-reference#init_sdk) the SDK after copying license key file into `engine` directory. Should be called before using of any other functions.

<figure><img src="/files/QiFKNaLJmFWw2PjUH8Th" alt=""><figcaption></figcaption></figure>


# Sample Application

Windows-Face SDK(lite version) Flask, Gradio, Surveillance Demo

## Installation

### - Download

Download [**WinFaceSDKDemo.rar \[145M\]**](https://www.dropbox.com/scl/fi/wvhguyzfgz8hlwmzoxolh/WinFaceSDKDemo.rar?rlkey=k62d1p3krii7yjyy4i8yn2cen\&st=oirp9nz0\&dl=0)

The Demo directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="206"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td>Dependency files</td></tr><tr><td><strong>engine\</strong></td><td>SDK engine files</td></tr><tr><td><strong>examples\</strong></td><td>Sample images</td></tr><tr><td><strong>flask\</strong></td><td>Flask server side demo code</td></tr><tr><td><strong>gradio\</strong></td><td>Gradio demo code</td></tr><tr><td><strong>video_surveillance_demo\</strong></td><td>1:N Video Surveillance demo code</td></tr></tbody></table>

### - Install dependencies

Install `python-3.8.9.exe`, `VC_redist.2013.exe`, `VC_redist.2015-2022.exe` files from `dependency` directory.

{% hint style="warning" %}
When install `python-3.8.9.exe`, have to tick the `Add Python3.8 to PATH` option.

<img src="/files/KH9f4qKZ6cPflsoxKEG7" alt="" data-size="original">
{% endhint %}

### - Setting Up SDK License Key

Copy the `license.txt` license file to the `engine` directory.

<figure><img src="/files/ZyEg5IaVih2uhc00dqiZ" alt=""><figcaption></figcaption></figure>

***

## Test

### - Test Flask Server APIs

* Install sub-dependencies for Flask Demo

{% code overflow="wrap" %}

```sh
cd flask
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="/files/YUvjevNtPVw90gJMP8lR" alt=""><figcaption></figcaption></figure>

* To test the Flask Server API, you can use [Postman](https://www.postman.com/downloads/). Here are the endpoints for testing:

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/analyze\_face

&#x20; Perform face analysis on an image file

&#x20;   **Parameters**

&#x20;        **image:** image file

&#x20;   **Response**&#x20;

&#x20;        **result:** face detection result

&#x20;        **face\_rect:** face bounding box of detected face

&#x20;        **attribute:** attributes(age, gender, liveness, mask,  wear\_glass) of detected face

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/compare\_face

&#x20; Perform face match between two face image files

&#x20;   **Parameters**

&#x20;        **image1:** image file for the 1st face

&#x20;        **image2:** image file for the 2nd face

&#x20;   **Response**&#x20;

&#x20;        **result:** face match result

&#x20;        **similarity:** similarity between two faces

&#x20;        **detection:** face bounding boxes of two faces

<figure><img src="/files/Rx0NCK0ldH6YpQ8BSgOx" alt=""><figcaption><p>Postman usage guide for Flask Demo (analyze_face)</p></figcaption></figure>

<figure><img src="/files/fCUlE6PkuBTk2MloW6Yw" alt=""><figcaption><p>Postman usage guide for Flask Demo (compare_face)</p></figcaption></figure>

### - Test Gradio

* Install sub-dependencies for Gradio Demo

{% code overflow="wrap" %}

```sh
cd gradio
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="/files/iEK28u6oGFFHAeQFcP3Q" alt=""><figcaption></figcaption></figure>

* Go to <http://127.0.0.1:7860/> on a web browser.

<figure><img src="/files/bNstcjGQyIsOi3HXG0CD" alt=""><figcaption><p>Gradio Demo (face attribute)</p></figcaption></figure>

<figure><img src="/files/lpboPVhZefBxYuRsRy2k" alt=""><figcaption><p>Gradio Demo (face recognition)</p></figcaption></figure>

### - Test 1:N Surveillance

* Install sub-dependencies for Surveillance Demo

{% code overflow="wrap" %}

```sh
cd video_surveillance_demo
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="/files/HwBVle116nMc5Dc0jAZ3" alt=""><figcaption></figcaption></figure>

* Main Page

When you run the `app.py` script, the main page appears first.

<figure><img src="/files/y6PnoLDgYTfiX3E52yoB" alt=""><figcaption><p>main page in 1:N surveillance</p></figcaption></figure>

* Register Person Page

You can enroll user from image.

<figure><img src="/files/bh01mvdhNkCd8Jd6q3qa" alt=""><figcaption><p>user registration page</p></figcaption></figure>

* User List Page

The registered user list is displayed.

<figure><img src="/files/IPBgCzmBOY26gOMvdmbr" alt=""><figcaption><p>user list page</p></figcaption></figure>

* Photo Match Page

You can identify registered users from selected image.

<figure><img src="/files/hy90BGRNotsmsmoLCRWF" alt=""><figcaption><p>photo match page</p></figcaption></figure>

* Video Surveillance Page

You can identify registered users from video stream.

Media file, RTSP stream, Web Camera can be used as video stream.

<figure><img src="/files/RByCitx6pUB5etIn3K6S" alt=""><figcaption><p>select video stream page</p></figcaption></figure>

<figure><img src="/files/5YXWL65097ffXDpQquEq" alt=""><figcaption><p>video surveillance page</p></figcaption></figure>


# Android

Face Recognition SDK for Android

This guide introduces RECOGNITO Android-Face SDK for onboarding & eKYC cases.

**Face SDK (Core)** = Face Recognition + Face Liveness Detection

**Face SDK (Pro)** = Face Recognition + Face Liveness Detection + Face Attribute

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Face SDK - Core</th><th align="center">Face SDK - Pro</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">Kotlin/Java</td><td align="center">Kotlin/Java</td></tr><tr><td><strong>Face Detection</strong></td><td align="center">Multiple Faces</td><td align="center">Multiple Face</td></tr><tr><td><strong>Face Feature Extraction</strong></td><td align="center">Yes, 512bytes</td><td align="center">Yes, 512bytes</td></tr><tr><td><strong>Face Liveness Detection</strong></td><td align="center">Yes</td><td align="center">Yes</td></tr><tr><td><strong>Face Attribute Analysis</strong></td><td align="center">Pitch, Yaw, Roll</td><td align="center">Pitch, Yaw, Roll<br>Age, Gender<br>Eye Open<br>Mouth Close<br>Face Occlusion<br>Face Quality<br>Face Luminance</td></tr><tr><td><strong>1:N Identifiability</strong></td><td align="center">Yes</td><td align="center">Yes</td></tr></tbody></table>

{% hint style="info" %}
[How to implement 1:N identification with RECOGNITO SDK?](/how-to-implement-1-n-identification-with-recognito-sdk)
{% endhint %}

## System Requirements

* Android 5.0 (API level 21) OS or newer
* At least 256 MB of free RAM should be available for the application.
* Java SE JDK 8 (or higher)
* Android Studio 4.0 IDE
* Android SDK 21+ API level


# Installation

The Android-FaceSDK is provided in **Android Library Project (AAR)** format.

## Download SDK

[**libfacesdk\_core.zip \[33M\]**](https://www.dropbox.com/scl/fi/6udmto3acu8mt7y4x66y9/libfacesdk_core.zip?rlkey=w7gnhvxz8njcvpnssb59a5u60\&st=xsnzpbx1\&dl=0)

[**libfacesdk\_pro.zip \[46M\]**](https://www.dropbox.com/scl/fi/m02ykp7ilfevowd7hv6m7/libfacesdk_pro.zip?rlkey=632d06uqpc5s4fhi6cvka9c2a\&st=6vkiadun\&dl=0)

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th></th></tr></thead><tbody><tr><td>build.gradle</td><td>Gradle build file</td></tr><tr><td>facesdk.aar</td><td>FaceSDK AAR file</td></tr></tbody></table>

## Add FaceSDK to Android Project <a href="#adding-the-android-sdk" id="adding-the-android-sdk"></a>

* Add the SDK folder to your Android project's root directory.
* Open the `build.gradle` file corresponding to the new, or existing Android Studio project that you want to integrate. Typically, this is the `build.gradle` file for the `app` module.
* Add the SDK to the `dependencies` section in your `build.gradle` file:

{% code overflow="wrap" %}

```gradle
dependencies {
    implementation project(path: ':libfacesdk')
}
```

{% endcode %}

* Include the SDK in your `settings.gradle` file:

{% code overflow="wrap" %}

```gradle
rootProject.name = "YourProjectName"
include ':app'
include ':libfacesdk'
```

{% endcode %}

* Build your project

<figure><img src="/files/W9O4dbV9iT8TRtclOop5" alt=""><figcaption></figcaption></figure>


# API Reference

### setActivation

{% code overflow="wrap" %}

```kotlin
public static native int setActivation(String var0);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>setActivation</td></tr><tr><td><strong>Description</strong></td><td>Activate SDK</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (String): The license string</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>The SDK activation status code.</p><ul><li>0: Success</li><li>Non-zero: Activation failed</li></ul></td></tr></tbody></table>

### init

{% code overflow="wrap" %}

```kotlin
public static native int init(AssetManager var0);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init</td></tr><tr><td><strong>Description</strong></td><td>Initiate SDK</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (AssetManager): An instance of AssetManager used to access application assets</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>The SDK initialization status code.</p><ul><li>0: Success</li><li>-1: License Key Error</li><li>-2: License AppID Error</li><li>-3: License Expired</li><li>-4: Activate Error</li><li>-5: Initialize SDK Error</li></ul></td></tr></tbody></table>

### yuv2Bitmap

{% code overflow="wrap" %}

```kotlin
public static native Bitmap yuv2Bitmap(byte[] nv21, int width, int height, int orientation);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>yuv2Bitmap</td></tr><tr><td><strong>Description</strong></td><td>Convert YUV camera frame to Bitmap image</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>nv21</strong> (byte[]): Byte array representing the YUV image data in NV21 format</li><li><strong>width</strong> (int): Width of the image</li><li><strong>height</strong> (int): Height of the image</li><li><strong>orientation</strong> (int): Orientation of the image</li></ul><p>       1 -> No processing<br>       2 -> Flip horizontally<br>       3 -> Flip horizontally first and then flip vertically<br>       4 -> Vertical flip<br>       5 -> Transpose<br>       6 -> Rotate 90° clockwise<br>       7 -> Horizontal and vertical flip --> Transpose<br>       8 -> Rotate 90° counterclockwise</p></td></tr><tr><td><strong>Output</strong></td><td>A Bitmap object representing the converted image</td></tr></tbody></table>

### faceDetection

{% code overflow="wrap" %}

```kotlin
public static native List<FaceBox> faceDetection(Bitmap var0, FaceDetectionParam var1);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>faceDetection</td></tr><tr><td><strong>Description</strong></td><td>Detect Face</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (Bitmap): The Bitmap image</li><li><strong>var1</strong> (<a href="#facedetectionparam"><strong>FaceDetectionParam</strong></a>): Parameters for face detection</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A list of <a href="#facebox"><strong>FaceBox</strong> </a>objects representing the detected faces.</td></tr></tbody></table>

#### FaceDetectionParam

* **FaceSDK - Core**

{% code overflow="wrap" %}

```kotlin
public class FaceDetectionParam {
    public boolean check_liveness = false;
    public int check_liveness_level = 0; // 0: more accurate model, 1: lighter model
}
```

{% endcode %}

* **FaceSDK - Pro**

{% code overflow="wrap" %}

```kotlin
public class FaceDetectionParam {
    public boolean check_liveness = false;
    public int check_liveness_level = 0; // 0: more accurate model, 1: lighter model
    public boolean check_eye_closeness = false;
    public boolean check_face_occlusion = false;
    public boolean check_mouth_opened = false;
    public boolean estimate_age_gender = false;
}
```

{% endcode %}

#### FaceBox

* **FaceSDK - Core**

{% code overflow="wrap" %}

```kotlin
public class FaceBox {
    public int x1;
    public int y1;
    public int x2;
    public int y2;
    public float liveness;
    public float yaw;
    public float roll;
    public float pitch;
}
```

{% endcode %}

* **FaceSDK - Pro**

{% code overflow="wrap" %}

```kotlin
public class FaceBox {
    public int x1;
    public int y1;
    public int x2;
    public int y2;
    public float yaw;
    public float roll;
    public float pitch;
    public float face_quality;
    public float face_luminance;
    public float liveness;
    public float left_eye_closed;
    public float right_eye_closed;
    public float face_occlusion;
    public float mouth_opened;
    public int age;
    public int gender;
    public float[] landmarks_68;
}
```

{% endcode %}

The liveness score ranges from 0.0 to 1.0\
**Default Liveness Threshold is 0.7**

### templateExtraction

{% code overflow="wrap" %}

```kotlin
public static native byte[] templateExtraction(Bitmap var0, FaceBox var1);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>templateExtraction</td></tr><tr><td><strong>Description</strong></td><td>Extract face feature</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (Bitmap): The Bitmap image</li><li><strong>var1</strong> (<a href="#facebox"><strong>FaceBox</strong></a>): The bounding box of the detected face</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A byte array representing the extracted template from the face</td></tr></tbody></table>

### similarityCalculation

{% code overflow="wrap" %}

```kotlin
public static native float similarityCalculation(byte[] var0, byte[] var1);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>similarityCalculation</td></tr><tr><td><strong>Description</strong></td><td>Calculate similarity between two face features</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (byte[]): The byte array representing the first face template</li><li><strong>var1</strong> (byte[]): The byte array representing the second face template</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A float value representing the similarity score between the two face templates<br>The score ranges from 0.0 to 1.0<br><strong>Default Threshold is 0.8</strong></td></tr></tbody></table>


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your Application ID

To activate SDK, you have to first get your Application ID in your `build.gradle` file:

```gradle
 android { 
     namespace 'com.bio.facerecognition' 
     compileSdk 33 
  
     defaultConfig { 
         applicationId "com.bio.facerecognition" 
         minSdk 24 
         targetSdk 33 
         versionCode 4 
         versionName "1.3" 
```

## Request License

Share your Application ID with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Activate](/face-recognition-sdk/integration-guide/android/api-reference#setactivation) the SDK with license key. Should be called before using of any other functions.

{% code title="MainActivity.kt" %}

```kotlin
import com.bio.facesdk.FaceSDK

val license_str = application.assets.open("license").bufferedReader().use{ 
    it.readText() 
} 
  
var ret = FaceSDK.setActivation(license_str) 
  
if (ret == FaceSDK.SDK_SUCCESS) { 
    ret = FaceSDK.init(assets) 
} 
```

{% endcode %}


# Sample Application

1:N Face Identification and Liveness Detection SDK Android Demo

{% embed url="<https://www.youtube.com/watch?v=9HM70PFa4lQ>" %}
NIST FRVT #1 Face Recognition, Liveness Detection Mobile SDK Demo
{% endembed %}

***

### Download APK

<table data-view="cards" data-full-width="false"><thead><tr><th></th><th data-hidden></th><th data-hidden></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Recognito_FaceDemo_Core.apk</td><td></td><td></td><td><a href="/files/3o0HeYVavQGPi0XBmvWy">/files/3o0HeYVavQGPi0XBmvWy</a></td><td><a href="https://www.dropbox.com/scl/fi/w11b9wl80tqo9mf9op33f/Recognito_FaceDemo_Core.apk?rlkey=ne9r67ixan6xk4luau9eucj7g&#x26;st=531h7h34&#x26;dl=0">https://www.dropbox.com/scl/fi/w11b9wl80tqo9mf9op33f/Recognito_FaceDemo_Core.apk?rlkey=ne9r67ixan6xk4luau9eucj7g&#x26;st=531h7h34&#x26;dl=0</a></td></tr><tr><td>Recognito_FaceDemo_Pro.apk</td><td></td><td></td><td><a href="/files/3o0HeYVavQGPi0XBmvWy">/files/3o0HeYVavQGPi0XBmvWy</a></td><td><a href="https://www.dropbox.com/scl/fi/n8eqf1y6ah021n38s3gvv/Recognito_FaceDemo_Pro.apk?rlkey=1mfhdcb23l788jo1v4t5kazno&#x26;st=bni6aqae&#x26;dl=0">https://www.dropbox.com/scl/fi/n8eqf1y6ah021n38s3gvv/Recognito_FaceDemo_Pro.apk?rlkey=1mfhdcb23l788jo1v4t5kazno&#x26;st=bni6aqae&#x26;dl=0</a></td></tr></tbody></table>

***

## Build Project

### - Download and Open Project

* Download&#x20;
  * [**Recognito\_Face\_Android\_Core.zip\[33.6M\]**](https://www.dropbox.com/scl/fi/jqku6qlfwkdavq808wycv/Recognito_Face_Android_Core.zip?rlkey=z5pfxpt094qhjhwq7mbia3r57\&st=tjprdgef\&dl=0)
  * [**Recognito\_Face\_Android\_Pro.zip\[46.7M\]**](https://www.dropbox.com/scl/fi/oszbz04zb9ucp0zdf4lxf/Recognito_Face_Android_Pro.zip?rlkey=yvk93jbxbtlvmcl7g57gohym1\&st=3cuu99is\&dl=0)
* Open the `FaceRecognition` project in Android Studio.

### - Setting Up SDK License Key

* Add license to `assets/license` file:

{% code title="Android-FaceRecognition-FaceLivenessDetection/app/src/main/assets/license" lineNumbers="true" %}

```
 BsTr9o4f4R/rM3TxbCWVb/hrOJuOIdz8ArQ/t2IgQFFUQzGHOLNNaMJiK/fUfr5zo005zoTA/cm6 
 VoZ6iGl+/hZGA3R5T/VWwhxekbw8JVz9sNesU6rMG5+1cNSN75trH2tpzdCPZ28ZDnZlttmiuUoC 
 9QazRe1xKi5tUXa+xgIxzL0vE6UW2dLKWaEXjn3fSJfLxXWw0q+UZP0hQAXb5Y9Yl/NVi7y3d0xT 
 Vq6/weuMQkgLcNdLqFRvQXup0M9W/pvuhaubySAxHCKVY8wToygN2iM78cOkyyAbGVwZeGQP0Jfd 
 46VZo+w+KCNw355j3osVVMghrOcVZnfbp1dNyg== 
```

{% endcode %}

* Build Project.

### - Integration Guide

* Import FaceSDK

```kotlin
import com.bio.facesdk.FaceBox
import com.bio.facesdk.FaceDetectionParam
import com.bio.facesdk.FaceSDK
```

* Activate and Initialize FaceSDK

```kotlin
var ret = FaceSDK.setActivation(license_str)

if (ret == FaceSDK.SDK_SUCCESS) {
    ret = FaceSDK.init(assets)
}
```

* YUV to Bitmap for camera frame

```kotlin
override fun process(frame: Frame) {
    val bitmap = FaceSDK.yuv2Bitmap(frame.image, frame.size.width, frame.size.height, cameraOrientation)
    ...
```

* Set `FaceDetectionParam` and Detect Face

```kotlin
val faceDetectionParam = FaceDetectionParam()
faceDetectionParam.check_liveness = true
faceDetectionParam.check_liveness_level = SettingsActivity.getLivenessModelType(this)
faceDetectionParam.check_eye_closeness = true // available for pro version
faceDetectionParam.check_face_occlusion = true // available for pro version
faceDetectionParam.check_mouth_opened = true // available for pro version
faceDetectionParam.estimate_age_gender = true // available for pro version
var faceBoxes: List<FaceBox>? = FaceSDK.faceDetection(bitmap, faceDetectionParam)
```

* Extract Face Template

```kotlin
val faceBox = faceBoxes[0]
val templates = FaceSDK.templateExtraction(bitmap, faceBox)
```

* Calculate Similarity

```kotlin
val similarity = FaceSDK.similarityCalculation(templates, person.templates)
```

***

## Application UI

<div><figure><img src="/files/jGuNuRDga2c4QnDsDdaz" alt=""><figcaption></figcaption></figure> <figure><img src="/files/tdXFr34AIpk2rhS6IGuK" alt=""><figcaption></figcaption></figure> <figure><img src="/files/uLOLbY0893owYQtCNN3A" alt=""><figcaption></figcaption></figure> <figure><img src="/files/ghDaUvVcX5HfkE2CB4Nt" alt=""><figcaption></figcaption></figure> <figure><img src="/files/Mv2RxbjrmZd3rwI9Ez8b" alt=""><figcaption></figcaption></figure> <figure><img src="/files/oJEIK3rZY8RUYq7i7c0q" alt=""><figcaption></figcaption></figure></div>


# iOS

Face Recognition SDK for iOS

This guide introduces RECOGNITO iOS-Face SDK for onboarding & eKYC cases.

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">iOS-Face SDK</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">Objective C/Swift</td></tr><tr><td><strong>Face Detection</strong></td><td align="center">Multiple Faces</td></tr><tr><td><strong>Face Feature Extraction</strong></td><td align="center">Yes, 512bytes</td></tr><tr><td><strong>Face Liveness Detection</strong></td><td align="center">Yes</td></tr><tr><td><strong>Face Attribute Analysis</strong></td><td align="center">Pitch, Yaw, Roll</td></tr><tr><td><strong>1:N Identifiability</strong></td><td align="center">Yes</td></tr></tbody></table>

{% hint style="info" %}
[How to implement 1:N identification with RECOGNITO SDK?](/how-to-implement-1-n-identification-with-recognito-sdk)
{% endhint %}

## System Requirements

* Mac running macOS 10.13 or newer
* Xcode 9.3 or newer
* iPhone 5S or newer iPhone (iOS 11.0 or newer)


# Installation

The iOS-FaceSDK is provided in **Framework** format.

## Download SDK

Download [**ios\_facesdk.zip \[21M\]**](https://www.dropbox.com/scl/fi/xtwc12fdeq5h9k7t5r2ny/ios_facesdk.zip?rlkey=wsjmyakre6c09ocbs1xytrnts\&st=lmryo8kt\&dl=0)

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th></th></tr></thead><tbody><tr><td><strong>facesdk.framework</strong></td><td>FaceSDK framework file</td></tr><tr><td>FaceDemo-Bridging-Header.h</td><td>Bridging Header file for Objective-C and Swift</td></tr></tbody></table>

## Add FaceSDK to iOS Project <a href="#adding-the-android-sdk" id="adding-the-android-sdk"></a>

* Copy and Add `facesdk.framework` into the project

<figure><img src="/files/piMZ63PxPPzAyQ6DoB4G" alt=""><figcaption></figcaption></figure>

* Add `FaceDemo-Bridging-Header.h` to Build Settings

<figure><img src="/files/mSeXJZ5gfA48D01DPHVw" alt=""><figcaption></figcaption></figure>

* Build your project

<figure><img src="/files/nUnNPU413EqwAwLqFUOw" alt=""><figcaption></figcaption></figure>


# API Reference

### setActivation

{% code overflow="wrap" %}

```swift
+(int)setActivation:(NSString*)license;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>setActivation</td></tr><tr><td><strong>Description</strong></td><td>Activate SDK</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>license</strong> (NSString*): The license string</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>The SDK activation status code.</p><ul><li>0: Success</li><li>Non-zero: Activation failed</li></ul></td></tr></tbody></table>

### initSDK

{% code overflow="wrap" %}

```swift
+(int)initSDK;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>initSDK</td></tr><tr><td><strong>Description</strong></td><td>Initiate SDK</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td><p>The SDK initialization status code.</p><ul><li>0: Success</li><li>-1: License Key Error</li><li>-2: License AppID Error</li><li>-3: License Expired</li><li>-4: Activate Error</li><li>-5: Initialize SDK Error</li></ul></td></tr></tbody></table>

### faceDetection

{% code overflow="wrap" %}

```swift
+(NSMutableArray*)faceDetection:(UIImage*)image;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>faceDetection</td></tr><tr><td><strong>Description</strong></td><td>Detect Face</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>image</strong> (UIImage*): The input image</li></ul></td></tr><tr><td><strong>Output</strong></td><td>An array of <a href="/pages/acYCwClH0Eh3auberFsG#facebox"><strong>FaceBox</strong></a> objects representing the detected faces.</td></tr></tbody></table>

#### FaceBox

{% code overflow="wrap" %}

```swift
@interface FaceBox : NSObject

@property (nonatomic) int x1;
@property (nonatomic) int y1;
@property (nonatomic) int x2;
@property (nonatomic) int y2;
@property (nonatomic) float liveness;
@property (nonatomic) float yaw;
@property (nonatomic) float roll;
@property (nonatomic) float pitch;
@end
```

{% endcode %}

The liveness score ranges from 0.0 to 1.0\
**Default Liveness Threshold is 0.7**

### templateExtraction

{% code overflow="wrap" %}

```swift
+(NSData*)templateExtraction:(UIImage*)image faceBox:(FaceBox*)faceBox;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>templateExtraction</td></tr><tr><td><strong>Description</strong></td><td>Extract face feature</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>image</strong> (UIImage*): The input image</li><li><strong>faceBox</strong> (<a href="#facebox"><strong>FaceBox</strong></a><strong>*</strong>): The bounding box of the detected face</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A NSData representing the extracted template from the face</td></tr></tbody></table>

### similarityCalculation

{% code overflow="wrap" %}

```swift
+(float)similarityCalculation:(NSData*)templates1 templates2:(NSData*)templates2;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>similarityCalculation</td></tr><tr><td><strong>Description</strong></td><td>Calculate similarity between two face features</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>templates1</strong> (NSData*): The first face template</li><li><strong>templates2</strong> (NSData*): The second face template</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A float value representing the similarity score between the two face templates<br>The score ranges from 0.0 to 1.0<br><strong>Default Threshold is 0.8</strong></td></tr></tbody></table>


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your Bundle ID

To activate SDK, you have to first get your Bundle ID:

<figure><img src="/files/c8QFrEcQxb2E07icB867" alt=""><figcaption></figcaption></figure>

## Request License

Share your Bundle ID with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Activate](/face-recognition-sdk/integration-guide/ios/api-reference#setactivation) the SDK with license key. Should be called before using of any other functions.

```swift
override func viewDidLoad() {
    super.viewDidLoad()
    var ret = SDK_LICENSE_KEY_ERROR.rawValue
    if let filePath = Bundle.main.path(forResource: "license", ofType: "txt") {
        do {
            let license = try String(contentsOfFile: filePath, encoding: .utf8)
            ret = FaceSDK.setActivation(license)
        } catch {
            print("Error reading file: \(error)")
        }
    } else {
        print("File not found")
    }
    
    if(ret == SDK_SUCCESS.rawValue) {
        ret = FaceSDK.initSDK()
    }
```


# Sample Application

1:N Face Identification and Liveness Detection SDK iOS Demo

{% embed url="<https://www.youtube.com/watch?v=9HM70PFa4lQ>" %}
NIST FRVT #1 Face Recognition, Liveness Detection Mobile SDK Demo
{% endembed %}

***

## Build Project

### - Download and Open Project

* Download [**Recognito\_Face\_iOS.zip \[21.8M\]**](https://www.dropbox.com/scl/fi/2f9kmzk4pvt1a1835c04t/Recognito_Face_iOS.zip?rlkey=xqny98ifgsgoglgwfc6edvsvb\&st=w8h1uv4b\&dl=0)
* Open the `FaceDemo` project in Xcode.

### - Setting Up SDK License Key

* Add your license to `license.txt` file:

{% code title="iOS-FaceRecognition-FaceLivenessDetection/license.txt" lineNumbers="true" %}

```
 jwIUC3mm7P9uJDPxx/gRUttdS3bDg5n3QFnyySRB/E776MSPQAMubdyFTuzFb7BCdOx4EuoHmcsO 
 rpeGfI+Z371p/7cInVsnxLZU7PcSJh45Dd7c6maTg0QPwNLDHqdyNzRLFwKXXOX/IVuQNh6Dsen1 
 mwk6RGQZfReSUU6nLvWzC5sPgYhBVemExbbIa3UdDbBC+Bm4qNeXQ2i/08s9GFrhhbuvdYyI5TGl 
 6aVFjSGoHQhm/ENI1916+ck7BiguXMA1KFRTlchSWKhyb9CllHOGTomkoBUD3ykLlMGkcuZE8wT6 
 qpaHrtnmz1TgkP3tjK7L61BaEpWNib3uH29hWA== 
```

{% endcode %}

* Build Project.

### - Integration Guide

* Activate and Initialize FaceSDK

```swift
override func viewDidLoad() {
    super.viewDidLoad()
    var ret = SDK_LICENSE_KEY_ERROR.rawValue
    if let filePath = Bundle.main.path(forResource: "license", ofType: "txt") {
        do {
            let license = try String(contentsOfFile: filePath, encoding: .utf8)
            ret = FaceSDK.setActivation(license)
        } catch {
            print("Error reading file: \(error)")
        }
    } else {
        print("File not found")
    }
    
    if(ret == SDK_SUCCESS.rawValue) {
        ret = FaceSDK.initSDK()
    }
```

* Detect Face from Camera Frame

```swift
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {    
    guard let pixelBuffer: CVPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
    
    CVPixelBufferLockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly)
    let ciImage = CIImage(cvPixelBuffer: pixelBuffer)
    
    let context = CIContext()
    let cgImage = context.createCGImage(ciImage, from: ciImage.extent)
    let image = UIImage(cgImage: cgImage!)
    CVPixelBufferUnlockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly)

    // Rotate and flip the image
    var capturedImage = image.rotate(radians: .pi/2)
    if(cameraLens_val == .front) {
        capturedImage = capturedImage.flipHorizontally()
    }
    
    let faceBoxes = FaceSDK.faceDetection(capturedImage)
```

* Extract Face Template

```swift
let faceBox = faceBoxes[0] as! FaceBox 
if(faceBox.liveness > livenessThreshold) {
    let templates = FaceSDK.templateExtraction(capturedImage, faceBox: faceBox)
    ...
```

* Calculate Similarity

```swift
let similarity = FaceSDK.similarityCalculation(templates, templates2: personTemplates)                    
```

***

## Application UI

<div><figure><img src="/files/gNM7fqcRqAeL7xwU0aIl" alt=""><figcaption></figcaption></figure> <figure><img src="/files/8CukMIvv7dOxOsiDjYzG" alt=""><figcaption></figcaption></figure> <figure><img src="/files/wgLcL2ti5csrbOHf5VkR" alt=""><figcaption></figcaption></figure> <figure><img src="/files/bOmqH54bNLg0Lokiltn0" alt=""><figcaption></figcaption></figure> <figure><img src="/files/XA8dMWBXwAM5aJtn6Bsp" alt=""><figcaption></figcaption></figure> <figure><img src="/files/E1qaQgqGVDLL3GQRggUu" alt=""><figcaption></figcaption></figure></div>


# Flutter

Face Recognition SDK for Flutter

This guide introduces RECOGNITO **Flutter-Face SDK** for onboarding & eKYC cases.

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Face SDK - Core</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">Dart</td></tr><tr><td><strong>Face Detection</strong></td><td align="center">Multiple Faces</td></tr><tr><td><strong>Face Feature Extraction</strong></td><td align="center">Yes, 512bytes</td></tr><tr><td><strong>Face Liveness Detection</strong></td><td align="center">Yes</td></tr><tr><td><strong>Face Attribute Analysis</strong></td><td align="center">Pitch, Yaw, Roll</td></tr><tr><td><strong>1:N Identifiability</strong></td><td align="center">Yes</td></tr></tbody></table>

{% hint style="info" %}
[How to implement 1:N identification with RECOGNITO SDK?](/how-to-implement-1-n-identification-with-recognito-sdk)
{% endhint %}


# Installation

## FaceSDK Plugin Setup

* Download plugin package from [**facesdk\_plugin.zip**](https://www.dropbox.com/scl/fi/yp12mnwhtf49fm6g3zi7b/facesdk_plugin.zip?rlkey=noo23lgs9tw04edm8arv2z4pz\&st=dse8bh7w\&dl=0) and extract to the root folder of your flutter project.

<div data-full-width="false"><figure><img src="/files/10TsVGjhHQyqFTGILOVO" alt=""><figcaption></figcaption></figure></div>

* Add `facesdk_plugin` package to `dependencies` in `pubspec.yaml` file.

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

<figure><img src="/files/jF3t5JMa9g2cKROikzhj" alt=""><figcaption></figcaption></figure>

* Import `facesdk_plugin` package in dart files.

<figure><img src="/files/1CprHTjv3142LbIwP5Bs" alt=""><figcaption></figcaption></figure>

## Android Setup

* Download Android SDK from [**libfacesdk\_core.zip**](https://www.dropbox.com/scl/fi/6udmto3acu8mt7y4x66y9/libfacesdk_core.zip?rlkey=w7gnhvxz8njcvpnssb59a5u60\&st=thrgclok\&dl=0) and extract to `android` folder in your flutter project.

<figure><img src="/files/dYG5VY2MthG8WuQaV8iy" alt=""><figcaption></figcaption></figure>

* Add `libfacesdk` to `settings.gradle` in android folder.

<figure><img src="/files/foLBc4EZq9pprCxRbrp5" alt=""><figcaption></figcaption></figure>

## iOS Setup

* iOS SDK `facesdk.framework` is already included in the `facesdk_plugin` package, so you don't need to download and import it into your project.

<figure><img src="/files/FChJNjDjk55gkZIDG0q4" alt=""><figcaption></figcaption></figure>

## Project Setup

For project setup, run the following commands:

```bash
flutter pub get
```


# API Reference

### setActivation

{% code overflow="wrap" %}

```dart
Future<int?> setActivation(String license)
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>setActivation</td></tr><tr><td><strong>Description</strong></td><td>Activate SDK</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>license</strong>: The license string</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>The SDK activation status code.</p><ul><li>0: Success</li><li>Non-zero: Activation failed</li></ul></td></tr></tbody></table>

### init

{% code overflow="wrap" %}

```dart
Future<int?> init() 
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init</td></tr><tr><td><strong>Description</strong></td><td>Initiate SDK</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td><p>The SDK initialization status code.</p><ul><li>0: Success</li><li>-1: License Key Error</li><li>-2: License AppID Error</li><li>-3: License Expired</li><li>-4: Activate Error</li><li>-5: Initialize SDK Error</li></ul></td></tr></tbody></table>

### setParam

{% code overflow="wrap" %}

```dart
Future<void> setParam(Meap<String, Object> params)
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>setParam</td></tr><tr><td><strong>Description</strong></td><td>Set Face Detection parameters </td></tr><tr><td><strong>Input</strong></td><td><ul><li><p><strong>params</strong> face detection parameters</p><pre class="language-dart"><code class="lang-dart">'check_liveness_level'
0: liveness v1 -> more accurate model
1: liveness v2-fast -> lighter model
</code></pre></li></ul></td></tr><tr><td><strong>Output</strong></td><td>None</td></tr></tbody></table>

### extractFaces

{% code overflow="wrap" %}

```kotlin
Future<dynamic> extractFaces(String imagePath)
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>extractFaces</td></tr><tr><td><strong>Description</strong></td><td>Detect and extract face templates from image file</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>imagePath</strong> : Image file path</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Face detection result</p><pre><code>{
 "x1": face.x1,
 "y1": face.y1,
 "x2": face.x2,
 "y2": face.y2,
 "liveness": face.liveness,
 "yaw": face.yaw,
 "roll": face.roll,
 "pitch": face.pitch,
 "templates": templates,
 "faceJpg": faceJpg,
 "frameWidth": bitmap!!.width,
 "frameHeight": bitmap!!.height
}
</code></pre></td></tr></tbody></table>

### similarityCalculation

{% code overflow="wrap" %}

```dart
Future<double?> similarityCalculation(
Uint8List templates1, Uint8List templates2)
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>similarityCalculation</td></tr><tr><td><strong>Description</strong></td><td>Calculate similarity between two face features</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>templates1</strong>: The first face template</li><li><strong>templates2</strong>: The second face template</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A float value representing the similarity score between the two face templates<br>The score ranges from 0.0 to 1.0<br><strong>Default Threshold is 0.8</strong></td></tr></tbody></table>

### onFaceDetected&#x20;

```dart
void onFaceDetected(faces)
```

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>onFaceDetected</td></tr><tr><td><strong>Description</strong></td><td>callback function for face detection on camera stream</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td>Face detection result in camera frame</td></tr></tbody></table>

callback function definition

```java
@Override
    public void onFrame(Bitmap bitmap) {

        ArrayList<HashMap<String, Object>> faceBoxesMap = new ArrayList<HashMap<String, Object>>();
        FaceDetectionParam param = new FaceDetectionParam();
        param.check_liveness = true;
        param.check_liveness_level = FaceDetectionFlutterView.livenessDetectionLevel;

        List<FaceBox> faceBoxes = FaceSDK.faceDetection(bitmap, param);
        for(int i = 0; i < faceBoxes.size(); i ++) {
            FaceBox faceBox = faceBoxes.get(i);
            byte[] templates = FaceSDK.templateExtraction(bitmap, faceBox);
           Bitmap faceImage = Utils.cropFace(bitmap, faceBox);
           ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
           faceImage.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
           byte[] faceJpg = byteArrayOutputStream.toByteArray();

            HashMap<String, Object> e = new HashMap<String, Object>();
            e.put("x1", faceBox.x1);
            e.put("y1", faceBox.y1);
            e.put("x2", faceBox.x2);
            e.put("y2", faceBox.y2);
            e.put("liveness", faceBox.liveness);
            e.put("yaw", faceBox.yaw);
            e.put("roll", faceBox.roll);
            e.put("pitch", faceBox.pitch);
            e.put("templates", templates);
            e.put("faceJpg", faceJpg);
            e.put("frameWidth", bitmap.getWidth());
            e.put("frameHeight", bitmap.getHeight());

            faceBoxesMap.add(e);
        }

        Message message = new Message();
        message.what = 1;
        message.obj = faceBoxesMap;
        channelHandler.sendMessage(message);
    }
```


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Android Activation

To activate Android SDK, you have to first get your Application ID in your `android/app/build.gradle` file:

```gradle
android {
    ...
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.bio.facerecognition_flutter"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 24
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    ...
}
```

## iOS Activation

To activate iOS SDK, you have to get your Bundle ID.

```objectivec
buildSettings = {
	ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
	CLANG_ENABLE_MODULES = YES;
	CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
	DEVELOPMENT_TEAM = "";
	ENABLE_BITCODE = NO;
	INFOPLIST_FILE = Runner/Info.plist;
	LD_RUNPATH_SEARCH_PATHS = (
		"$(inherited)",
		"@executable_path/Frameworks",
	);
	PRODUCT_BUNDLE_IDENTIFIER = com.bio.facedemo;
	PRODUCT_NAME = "$(TARGET_NAME)";
	SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
	SWIFT_VERSION = 5.0;
	VERSIONING_SYSTEM = "apple-generic";
};
```

## Request License

Share your Application ID and Bundle ID with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Activate ](/face-recognition-sdk/integration-guide/flutter/api-reference#setactivation)the SDK with license key. Should be called before using of any other functions.

{% code title="main.dart" %}

```dart
try {
  if (Platform.isAndroid) {
    await _facesdkPlugin
        .setActivation(
            "EO5wcxhdMXJoLRpKq3Lexv2sTHPU8Ehed3vsBwmzdye/MJw+rVJTnY9SidD3vKV/2YNE6kufwIcC"
            "7LvLGFSORk3b14swPe7415aYSLKNI2RaUL5Nfn9oWHBjW1XehQLjLUx3w0Qi8bUth6vyg9Oaj7V7"
            "+dKruxjx/2dD2ddXKBoiIwYDonjW7gx7PmF9W66DXDtfRGpARvKW5Cn+jSCCH8A3Gft8wOBdQXM8"
            "UTDZUZxNbvozkgV6Dw9hMQJSka06iFK1h/UO6NrGLudt1SOC2b3hfoFJcAVjl3W7UTxzVyByJpLp"
            "tYTWJNr36pn1ixWhazLHC4s4TXtyQR67yzN3aw==")
        .then((value) => facepluginState = value ?? -1);
  } else {
    await _facesdkPlugin
        .setActivation(
            "H/Fs6Zgbsi9av6VVDAi54yqpYxnq0eDV3MSZAxMnARvUVePNY85UJu3d95nM7iO2RrCm19/eq+qb"
            "gSDmhJRYVJBMEUcxG+0cPPWVAW7m46dfS1Kpn+Flqbanfbco+Hd9Uda3aAzDkklzgdfYt7TvSXRt"
            "LZ8wW7jLiPjt8Lufj1GvhRzfESARv18VrxfQV+U8x3EqqvfKTJrkkg91NuAKvUZSoao4B5pQLpRd"
            "GwQ/saP9AQSWuyU1Zw+Whw/cnmXY2xZLGx6n/ict3NW9vpttv2tBbPCe/TdofRuJbE7R1Yb60BvQ"
            "ajzoaQWx3RsRgca9ah+Pccxb15tPVzr1apTK7A==")
        .then((value) => facepluginState = value ?? -1);
  }

  if (facepluginState == 0) {
    await _facesdkPlugin
        .init()
        .then((value) => facepluginState = value ?? -1);
  }
} catch (e) {}
```

{% endcode %}


# Sample Application

1:N Face Identification and Liveness Detection SDK Flutter Demo

{% embed url="<https://www.youtube.com/watch?v=9HM70PFa4lQ>" %}
NIST FRVT #1 Face Recognition, Liveness Detection Mobile SDK Demo
{% endembed %}

***

## Build Project

### - Download

* [**FaceRecognition-Flutter-main.zip**](https://www.dropbox.com/scl/fi/ylrp7q8qpet8e02mwtzui/FaceRecognition-Flutter-main.zip?rlkey=426bp3t0c0ekg5sq3k1ekodkt\&st=4u4wccnv\&dl=0)

### - Setting Up SDK License Key

* Add license:

{% code title="main.dart" lineNumbers="true" %}

```dart
if (Platform.isAndroid) {
    await _facesdkPlugin.setActivation(
        "EO5wcxhdMXJoLRpKq3Lexv2sTHPU8Ehed3vsBwmzdye/MJw+rVJTnY9SidD3vKV/2YNE6kufwIcC"
        "7LvLGFSORk3b14swPe7415aYSLKNI2RaUL5Nfn9oWHBjW1XehQLjLUx3w0Qi8bUth6vyg9Oaj7V7"
        "+dKruxjx/2dD2ddXKBoiIwYDonjW7gx7PmF9W66DXDtfRGpARvKW5Cn+jSCCH8A3Gft8wOBdQXM8"
        "UTDZUZxNbvozkgV6Dw9hMQJSka06iFK1h/UO6NrGLudt1SOC2b3hfoFJcAVjl3W7UTxzVyByJpLp"
        "tYTWJNr36pn1ixWhazLHC4s4TXtyQR67yzN3aw==")
    .then((value) => facepluginState = value ?? -1);
} else {
    await _facesdkPlugin.setActivation(
        "H/Fs6Zgbsi9av6VVDAi54yqpYxnq0eDV3MSZAxMnARvUVePNY85UJu3d95nM7iO2RrCm19/eq+qb"
        "gSDmhJRYVJBMEUcxG+0cPPWVAW7m46dfS1Kpn+Flqbanfbco+Hd9Uda3aAzDkklzgdfYt7TvSXRt"
        "LZ8wW7jLiPjt8Lufj1GvhRzfESARv18VrxfQV+U8x3EqqvfKTJrkkg91NuAKvUZSoao4B5pQLpRd"
        "GwQ/saP9AQSWuyU1Zw+Whw/cnmXY2xZLGx6n/ict3NW9vpttv2tBbPCe/TdofRuJbE7R1Yb60BvQ"
        "ajzoaQWx3RsRgca9ah+Pccxb15tPVzr1apTK7A==")
    .then((value) => facepluginState = value ?? -1);
}
```

{% endcode %}

* Build Project.

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

***

## Application UI

<div><figure><img src="/files/jGuNuRDga2c4QnDsDdaz" alt=""><figcaption></figcaption></figure> <figure><img src="/files/tdXFr34AIpk2rhS6IGuK" alt=""><figcaption></figcaption></figure> <figure><img src="/files/uLOLbY0893owYQtCNN3A" alt=""><figcaption></figcaption></figure> <figure><img src="/files/ghDaUvVcX5HfkE2CB4Nt" alt=""><figcaption></figcaption></figure> <figure><img src="/files/Mv2RxbjrmZd3rwI9Ez8b" alt=""><figcaption></figcaption></figure> <figure><img src="/files/oJEIK3rZY8RUYq7i7c0q" alt=""><figcaption></figcaption></figure></div>


# Performance Overview

ISO 30107 compliant face liveness detection

## **ISO 30107 compliant face liveness detection**

<figure><img src="/files/QE9xp8It5yolQiRqloCO" alt="" width="375"><figcaption></figcaption></figure>

**ISO 30107 compliant face liveness detection,** which prevents cheating with a photo in front of a camera, is available in certain RECOGNITO's Face SDKs.&#x20;

**RECOGNITO's Passive liveness detection** is the most sophisticated anti-spoofing technology. It does not require any special hardware, nor does it ask users to perform any actions to prove the liveness - it works just by analyzing images.

RECOGNITO's Passive liveness detection accuracy has been thoroughly **tested by our +70 Partners** and by the development and security teams for hundreds of Apps and numerous State and Federal Governments.

***

## RECOGNITO Passive Liveness Detection&#x20;

RECOGNITO's Face Liveness Detection protects against a full range of attacks, including:

* **Highly scalable digital injected attacks**: replayed or synthetic imagery such as **Deepfakes** that bypass the device camera or are injected into the data stream.
* **Presentation attacks**: physical or digital artifacts presented to the device camera.

**RECOGNITO's Face Liveness Detection is an active threat management technology integral to client protecting against evolving, novel attack methodologies.**


# Integration Guide


# Linux

Face Liveness Detection SDK for Linux

This guide introduces RECOGNITO Linux-Face Liveness Detection SDK (updated version) for onboarding & eKYC cases.

&#x20;After completing this guide, you will have downloaded SDK, run the Demo, tested each SDK APIs, and successfully integrated SDK into Your Application!

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Linux-Face Liveness Detection SDK (updated version)</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">C++/Python</td></tr><tr><td><strong>Face Detection</strong></td><td align="center">Single Face [Multiple Faces Detection Expandable]</td></tr><tr><td><strong>Face Feature Extraction</strong></td><td align="center">No</td></tr><tr><td><strong>Face Liveness Detection</strong></td><td align="center">Yes</td></tr><tr><td><strong>Face Attribute Analysis</strong></td><td align="center">Pitch, Yaw, Roll</td></tr><tr><td><strong>1:N Identifiability</strong></td><td align="center">No</td></tr><tr><td><strong>Inference Time</strong></td><td align="center">&#x3C; 170ms, Intel(R) Xeon(R) Gold 5315Y CPU @ 3.20GHz CPU: 8, RAM: 40 GB</td></tr></tbody></table>

## Recommended System Requirements

* **Operating System:** Ubuntu 20.04 or 22.04
* **CPU:** 8 cores
* **RAM:** 8 GB
* **HDD:** 8 GB


# Installation

## Download SDK

[**face-liveness\_engine\_v7.zip**](https://www.dropbox.com/scl/fi/e22byruod1q3wmjerzb2r/face-liveness_engine_v7.zip?rlkey=vb2i7421otvjn7i11yvg62i8s\&st=61nt21kg\&dl=0)

Unpack the `face-liveness_engine.zip` archive into the desired directory.

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th width="227"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td><strong>openvino\</strong></td><td>openvino so files</td></tr><tr><td></td><td>libimutils.so</td><td>libimutils so file for Ubuntu20.04</td></tr><tr><td></td><td>libimutils.so_for_ubuntu22</td><td>libimutils so file for Ubuntu22.04</td></tr><tr><td><strong>engine\</strong></td><td><strong>bin\</strong></td><td>SDK binary files</td></tr><tr><td></td><td>header.py</td><td>Header file</td></tr><tr><td></td><td>libliveness_v7.so</td><td>SDK so file</td></tr></tbody></table>

## Install dependencies

* Install packages and requirements:

{% code overflow="wrap" %}

```sh
sudo apt-get update -y && sudo apt-get install -y python3 python3-pip libcurl4-openssl-dev libssl-dev libtbb-dev
```

{% endcode %}

* Copy dependency libraries:

{% code overflow="wrap" %}

```sh
sudo cp -f dependency/libimutils.so /usr/lib
sudo cp -rf dependency/openvino /usr/lib
```

{% endcode %}

{% hint style="warning" %}
If the Ubuntu version is 22.04:

{% code overflow="wrap" %}

```sh
sudo cp -f dependency/libimutils.so_for_ubuntu22 /usr/lib/libimutils.so
```

{% endcode %}
{% endhint %}


# API Reference

### get\_version

{% code overflow="wrap" %}

```python
def get_version() -> str:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="136"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>get_version</td></tr><tr><td><strong>Description</strong></td><td>Retrieves the SDK version information from a library.</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td>The version string is returned as a standard Python string.</td></tr></tbody></table>

### get\_deviceid <a href="#get_device_id" id="get_device_id"></a>

{% code overflow="wrap" %}

```python
def get_deviceid() -> str:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="136"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>get_deviceid</td></tr><tr><td><strong>Description</strong></td><td>Retrieves the Hardware ID from a library.</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td>The Hardware ID is returned as a standard Python string.</td></tr></tbody></table>

### init\_sdk

{% code overflow="wrap" %}

```python
def init_sdk(dict_path: str, online_key: str) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init_sdk</td></tr><tr><td><strong>Description</strong></td><td>Initializes the SDK in online mode.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>dict_path</strong> (str): Path to the engine binary files directory</li><li><strong>online_key</strong> (str): Online key string </li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of the initialization.</p><ul><li>0: Success</li><li>Non-zero: Initialization failed</li></ul></td></tr></tbody></table>

### init\_sdk\_offline

{% code overflow="wrap" %}

```python
def init_sdk_offline(dict_path: str, offline_key_path: str) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init_sdk_offline</td></tr><tr><td><strong>Description</strong></td><td>Initializes the SDK in offline mode.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>dict_path</strong> (str): Path to the engine binary files directory</li><li><strong>offline_key</strong> (str): Path to the offline license key file</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of the initialization.</p><ul><li>0: Success</li><li>Non-zero: Initialization failed</li></ul></td></tr></tbody></table>

### detect\_face\_rgb

{% code overflow="wrap" %}

```python
def detect_face_rgb(image: np.ndarray, width: int, height: int, face_bbox: np.ndarray, liveness_score: np.ndarray, angles: np.ndarray) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>detect_face_rgb</td></tr><tr><td><strong>Description</strong></td><td>Detects and analyzes face.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>image</strong> (numpy.ndarray): Input image matrix</li><li><strong>width</strong> (int): Width of the input image</li><li><strong>height</strong> (int): Height of the input image</li><li><strong>face_bbox</strong> (numpy.ndarray): Face bounding box coordinates. Extracted face bbox will be stored</li><li><strong>liveness_score</strong> (numpy.ndarray): Liveness score of detected face</li><li><strong>angles</strong> (numpy.ndarray): Pitch, Yaw, Roll degree of detected face</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of the liveness check.</p><ul><li>>0: Success</li><li>0: No Face</li><li>-1: SDK Activation Error</li><li>-2: SDK Initialization Error</li></ul></td></tr></tbody></table>

#### Liveness Score Values (Default Threshold is 0.5)


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your HWID (Hardware ID)

To activate SDK, you have to first get your Hardware ID by using the [get\_deviceid ](/face-liveness-detection-sdk/integration-guide/linux/api-reference#get_device_id)function.

<figure><img src="/files/0XiLVXc1Va6kD3QBrhsz" alt=""><figcaption></figcaption></figure>

## Request License

After getting HWID, share it with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Initializes ](/face-liveness-detection-sdk/integration-guide/linux/api-reference#init_sdk_offline)the SDK with license key. Should be called before using of any other functions.

{% code overflow="wrap" %}

```python
init_sdk_offline("engine/bin", "license.txt")
```

{% endcode %}


# Sample Application

Linux-Face Liveness Detection SDK(updated version) Flask, Gradio Demo

## Docker

Pull the Docker image and run the container:

{% code overflow="wrap" %}

```sh
sudo docker pull recognito/face-liveness_v7:latest
sudo docker run -it -e FL_LICENSE_KEY="XXXXX-XXXXX-XXXXX-XXXXX" -p 8001:8000 -p 7861:7860 recognito/face-liveness_v7:latest [OPTION --gradio(-g), --flask(-f)]
```

{% endcode %}

***

## Installation

### - Download

[**FaceLivenessDetection-Demo(v7).zip**](https://www.dropbox.com/scl/fi/ee4vvg2powmgvldjq53wr/FaceLivenessDetection-Demo-v7.zip?rlkey=n51m1xg6agi7btd9v2vzkfdys\&st=cpyqrvp3\&dl=0)

The Demo directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="206"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td>Dependency files</td></tr><tr><td><strong>engine\</strong></td><td>SDK engine files</td></tr><tr><td><strong>examples\</strong></td><td>Sample images for face liveness detection</td></tr><tr><td><strong>flask\</strong></td><td>Flask server side demo code</td></tr><tr><td><strong>gradio\</strong></td><td>Gradio demo code</td></tr><tr><td>Dockerfile</td><td>Dockerfile for building a Docker image</td></tr><tr><td>install.sh</td><td>Script for install environment</td></tr><tr><td>license.txt</td><td>License key file</td></tr><tr><td>run_demo.sh</td><td>Script for run demo</td></tr></tbody></table>

### - Install dependencies

Run the `install.sh` script to install dependencies:

```
./install.sh
```

### - Setting Up SDK License Key

* **Online Licensing:** Set the online license key as an environment variable:

{% code overflow="wrap" %}

```sh
export FL_LICENSE_KEY="XXXXX-XXXXX-XXXXX-XXXXX"
```

{% endcode %}

* **Offline Licensing:** Copy the `license.txt` license file to the demo directory.

***

## Test

### - Run Demo

Run the demo script with the desired option:

{% code overflow="wrap" %}

```sh
./run_demo.sh [OPTION --gradio(-g), --flask(-f), --help(-h)]
```

{% endcode %}

<figure><img src="/files/0XiLVXc1Va6kD3QBrhsz" alt=""><figcaption></figcaption></figure>

### - Test Flask Server APIs

To test the Flask Server API, you can use [Postman](https://www.postman.com/downloads/). Here are the endpoints for testing:

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/check\_liveness

&#x20; Perform face liveness detection and attribute analysis on an image file

&#x20;   **Parameters**

&#x20;        **image:** image file

&#x20;   **Response**&#x20;

&#x20;        **result:** face liveness, attribute check result

&#x20;        **liveness\_score:** liveness score of detected face

&#x20;        **face\_rect:** face bounding box of detected face

&#x20;        **angles:** Pitch, Yaw, Roll of detected face

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/check\_liveness\_base64

&#x20; Perform face liveness detection and attribute analysis on a base64 image

&#x20;   **Parameters**

&#x20;        **image:** base64 image

&#x20;   **Response**&#x20;

&#x20;        **result:** face liveness, attribute check result

&#x20;        **liveness\_score:** liveness score of detected face

&#x20;        **face\_rect:** face bounding box of detected face

&#x20;        **angles:** Pitch, Yaw, Roll of detected face

<figure><img src="/files/9oZOe15nHRwMFLJwwJWC" alt=""><figcaption><p>Postman usage guide for Flask Demo</p></figcaption></figure>

### - Test Gradio

Go to <http://127.0.0.1:7860/> on a web browser.

<figure><img src="/files/q1Uyv6VlA2aDxGB8Txdb" alt=""><figcaption><p>Gradio Demo</p></figcaption></figure>


# Windows

Face Liveness Detection SDK for Windows

This guide introduces RECOGNITO Windows-Face SDK for onboarding & eKYC.

&#x20;After completing this guide, you will have downloaded SDK, run the Demo, tested each SDK APIs, and successfully integrated SDK into Your Application!

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Windows-Face SDK</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">C++/Python</td></tr><tr><td><strong>Face Detection</strong></td><td align="center">Multiple Faces</td></tr><tr><td><strong>Face Feature Extraction</strong></td><td align="center">Yes, 2056bytes</td></tr><tr><td><strong>Face Liveness Detection</strong></td><td align="center">Yes</td></tr><tr><td><strong>Face Attribute Analysis</strong></td><td align="center">Age, Gender, Mask, Glass</td></tr><tr><td><strong>1:N Identifiability</strong></td><td align="center">Yes</td></tr></tbody></table>

## Recommended System Requirements

* **Windows System:** Windows 10 or later
* **CPU:** 8 cores
* **RAM:** 8 GB
* **HDD:** 8 GB


# Installation

## Download SDK

Download [**win\_engine(pwd\_123).rar \[123M\]**](https://www.dropbox.com/scl/fi/rh5hhyjwu11m91ov79o1l/win_engine-pwd_123.rar?rlkey=mpsip9dfw5dydvaq541lqp0jl\&st=el5027cq\&dl=0)

Unpack the `win_engine(pwd_123).rar` archive into the desired directory. The password of archive file is `123`.

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th width="227"></th><th></th></tr></thead><tbody><tr><td><strong>dependency</strong></td><td>python-3.8.9.exe</td><td>Python executable file for Python version 3.8.9</td></tr><tr><td></td><td>VC_redist.2013.exe</td><td>Microsoft Visual C++ Redistributable Package for Visual Studio 2013</td></tr><tr><td></td><td>VC_redist.2015-2022.exe</td><td>Microsoft Visual C++ Redistributable Package for Visual Studio versions 2015 through 2022</td></tr><tr><td><strong>engine\</strong></td><td>header.py</td><td>Header file</td></tr><tr><td></td><td>hwid.txt</td><td>Hardware ID dump file</td></tr><tr><td></td><td>license.txt</td><td>License key file</td></tr><tr><td></td><td>libttvrecog.dll</td><td>SDK dll file 1</td></tr><tr><td></td><td>libttvsdk.dll</td><td>SDK dll file 2</td></tr><tr><td></td><td>ttvfacewrapper.dll</td><td>SDK dll file 3</td></tr><tr><td></td><td>opencv_world300.dll</td><td>OpenCV library version 3.0.0</td></tr></tbody></table>

## Install dependencies

* Install `python-3.8.9.exe`, `VC_redist.2013.exe`, `VC_redist.2015-2022.exe` files from `dependency` directory.

{% hint style="warning" %}
When install `python-3.8.9.exe`, have to tick the `Add Python3.8 to PATH` option.

<img src="/files/KH9f4qKZ6cPflsoxKEG7" alt="" data-size="original">
{% endhint %}


# API Reference

### init\_sdk

{% code overflow="wrap" %}

```python
def init_sdk() -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init_sdk</td></tr><tr><td><strong>Description</strong></td><td>Initializes the SDK.</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of the initialization.</p><ul><li>0: Success</li><li>Non-zero: Initialization failed</li></ul></td></tr></tbody></table>

### get\_attribute

{% code overflow="wrap" %}

```python
def get_attribute(image: np.ndarray, width: int, height: int, face_results: ctypes.POINTER(FaceResult), max_face_num: int, mode: int) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>get_attribute</td></tr><tr><td><strong>Description</strong></td><td>Detects and analyzes face.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>image</strong> (numpy.ndarray): Input image matrix</li><li><strong>width</strong> (int): Width of the input image</li><li><strong>height</strong> (int): Height of the input image</li><li><strong>face_results</strong> (ctypes.POINTER): Pointer to a structure containing face results</li><li><strong>max_face_num</strong> (int): Maximum number of faces to detect</li><li><strong>mode</strong> (int): 0-> Enroll mode, 1-> Identify mode</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of getting attribute.</p><ul><li>>0: Number of detected faces</li><li>0: No Face</li><li>otherwise: Error</li></ul></td></tr></tbody></table>

Here is **`FaceResult`** Structure.

```python
class FaceResult(Structure):
    _fields_ = [
        ("x1", c_int32),
        ("y1", c_int32),
        ("x2", c_int32),
        ("y2", c_int32),
        ("liveness", c_int32),
        ("mask", c_int32),
        ("glass", c_int32),
        ("age", c_int32),
        ("gender", c_int32),
        ("feature", c_ubyte * 2056)
    ]
```

<table data-header-hidden><thead><tr><th width="226"></th><th></th></tr></thead><tbody><tr><td><strong>(x1, y1)</strong></td><td>Coordinate of the top-left corner of the bounding box of the detected face.</td></tr><tr><td><strong>(x2, y2)</strong></td><td>Coordinate of the bottom-right corner of the bounding box of the detected face.</td></tr><tr><td><strong>liveness</strong></td><td><p>Liveness score of detected face</p><ul><li>0 -> SPOOF</li><li>1 -> REAL</li><li>-3 -> TOO SMALL FACE</li><li>-4 -> TOO LARGE FACE</li><li>-102 -> NO FACE</li><li>-103 -> LIVENESS CHECK FAILED</li></ul></td></tr><tr><td><strong>mask</strong></td><td><p>Mask detection of the detected face</p><ul><li>0 -> No, 1 -> Yes</li></ul></td></tr><tr><td><strong>glass</strong></td><td><p>Glass detection of the detected face</p><ul><li>0 -> No, 1 -> Yes</li></ul></td></tr><tr><td><strong>age</strong></td><td>Estimated age of the detected face</td></tr><tr><td><strong>gender</strong></td><td><p>Gender prediction of the detected face</p><ul><li>0 -> Male, 1 -> Female</li></ul></td></tr><tr><td><strong>feature</strong></td><td>Template buffer. Extracted template will be stored</td></tr></tbody></table>

### calculate\_similarity

{% code overflow="wrap" %}

```python
def calculate_similarity(feature_1: np.ndarray, feature_2: np.ndarray) -> float:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>calculate_similarity</td></tr><tr><td><strong>Description</strong></td><td>Calculates the similarity between two features</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>feature_1</strong> (numpy.ndarray): 1st feature</li><li><strong>feature_2</strong> (numpy.ndarray): 2nd feature</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Similarity score between the two features</p><p>The score ranges from 0.0 to 1.0<br><strong>Default Threshold is 0.82</strong></p></td></tr></tbody></table>


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your HWID (Hardware ID)

To activate SDK, you have to first get your Hardware ID by using the [init\_sdk](/face-liveness-detection-sdk/integration-guide/windows/api-reference#init_sdk) function.

<figure><img src="/files/78qyOqybhetb1HQAKd9r" alt=""><figcaption></figcaption></figure>

## Request License

After getting HWID, share it with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Initializes](/face-liveness-detection-sdk/integration-guide/windows/api-reference#init_sdk) the SDK after copying license key file into `engine` directory. Should be called before using of any other functions.

<figure><img src="/files/QiFKNaLJmFWw2PjUH8Th" alt=""><figcaption></figcaption></figure>


# Sample Application

Windows-Face SDK(lite version) Flask, Gradio, Surveillance Demo

## Installation

### - Download

Download [**WinFaceSDKDemo.rar \[145M\]**](https://www.dropbox.com/scl/fi/wvhguyzfgz8hlwmzoxolh/WinFaceSDKDemo.rar?rlkey=k62d1p3krii7yjyy4i8yn2cen\&st=m6pgbod5\&dl=0)

The Demo directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="206"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td>Dependency files</td></tr><tr><td><strong>engine\</strong></td><td>SDK engine files</td></tr><tr><td><strong>examples\</strong></td><td>Sample images</td></tr><tr><td><strong>flask\</strong></td><td>Flask server side demo code</td></tr><tr><td><strong>gradio\</strong></td><td>Gradio demo code</td></tr><tr><td><strong>video_surveillance_demo\</strong></td><td>1:N Video Surveillance demo code</td></tr></tbody></table>

### - Install dependencies

Install `python-3.8.9.exe`, `VC_redist.2013.exe`, `VC_redist.2015-2022.exe` files from `dependency` directory.

{% hint style="warning" %}
When install `python-3.8.9.exe`, have to tick the `Add Python3.8 to PATH` option.

<img src="/files/KH9f4qKZ6cPflsoxKEG7" alt="" data-size="original">
{% endhint %}

### - Setting Up SDK License Key

Copy the `license.txt` license file to the `engine` directory.

<figure><img src="/files/ZyEg5IaVih2uhc00dqiZ" alt=""><figcaption></figcaption></figure>

***

## Test

### - Test Flask Server APIs

* Install sub-dependencies for Flask Demo

{% code overflow="wrap" %}

```sh
cd flask
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="/files/YUvjevNtPVw90gJMP8lR" alt=""><figcaption></figcaption></figure>

* To test the Flask Server API, you can use [Postman](https://www.postman.com/downloads/). Here are the endpoints for testing:

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/analyze\_face

&#x20; Perform face analysis on an image file

&#x20;   **Parameters**

&#x20;        **image:** image file

&#x20;   **Response**&#x20;

&#x20;        **result:** face detection result

&#x20;        **face\_rect:** face bounding box of detected face

&#x20;        **attribute:** attributes(age, gender, liveness, mask,  wear\_glass) of detected face

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/compare\_face

&#x20; Perform face match between two face image files

&#x20;   **Parameters**

&#x20;        **image1:** image file for the 1st face

&#x20;        **image2:** image file for the 2nd face

&#x20;   **Response**&#x20;

&#x20;        **result:** face match result

&#x20;        **similarity:** similarity between two faces

&#x20;        **detection:** face bounding boxes of two faces

<figure><img src="/files/Rx0NCK0ldH6YpQ8BSgOx" alt=""><figcaption><p>Postman usage guide for Flask Demo (analyze_face)</p></figcaption></figure>

<figure><img src="/files/fCUlE6PkuBTk2MloW6Yw" alt=""><figcaption><p>Postman usage guide for Flask Demo (compare_face)</p></figcaption></figure>

### - Test Gradio

* Install sub-dependencies for Gradio Demo

{% code overflow="wrap" %}

```sh
cd gradio
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="/files/iEK28u6oGFFHAeQFcP3Q" alt=""><figcaption></figcaption></figure>

* Go to <http://127.0.0.1:7860/> on a web browser.

<figure><img src="/files/bNstcjGQyIsOi3HXG0CD" alt=""><figcaption><p>Gradio Demo (face attribute)</p></figcaption></figure>

<figure><img src="/files/lpboPVhZefBxYuRsRy2k" alt=""><figcaption><p>Gradio Demo (face recognition)</p></figcaption></figure>

### - Test 1:N Surveillance

* Install sub-dependencies for Surveillance Demo

{% code overflow="wrap" %}

```sh
cd video_surveillance_demo
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="/files/HwBVle116nMc5Dc0jAZ3" alt=""><figcaption></figcaption></figure>

* Main Page

When you run the `app.py` script, the main page appears first.

<figure><img src="/files/y6PnoLDgYTfiX3E52yoB" alt=""><figcaption><p>main page in 1:N surveillance</p></figcaption></figure>

* Register Person Page

You can enroll user from image.

<figure><img src="/files/bh01mvdhNkCd8Jd6q3qa" alt=""><figcaption><p>user registration page</p></figcaption></figure>

* User List Page

The registered user list is displayed.

<figure><img src="/files/IPBgCzmBOY26gOMvdmbr" alt=""><figcaption><p>user list page</p></figcaption></figure>

* Photo Match Page

You can identify registered users from selected image.

<figure><img src="/files/hy90BGRNotsmsmoLCRWF" alt=""><figcaption><p>photo match page</p></figcaption></figure>

* Video Surveillance Page

You can identify registered users from video stream.

Media file, RTSP stream, Web Camera can be used as video stream.

<figure><img src="/files/RByCitx6pUB5etIn3K6S" alt=""><figcaption><p>select video stream page</p></figcaption></figure>

<figure><img src="/files/5YXWL65097ffXDpQquEq" alt=""><figcaption><p>video surveillance page</p></figcaption></figure>


# Android

Face Liveness Detection SDK for Android

This guide introduces RECOGNITO Android-Face SDK for onboarding & eKYC cases.

**Face SDK (Core)** = Face Recognition + Face Liveness Detection

**Face SDK (Pro)** = Face Recognition + Face Liveness Detection + Face Attribute

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Face SDK - Core</th><th align="center">Face SDK - Pro</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">Kotlin/Java</td><td align="center">Kotlin/Java</td></tr><tr><td><strong>Face Detection</strong></td><td align="center">Multiple Faces</td><td align="center">Multiple Face</td></tr><tr><td><strong>Face Feature Extraction</strong></td><td align="center">Yes, 512bytes</td><td align="center">Yes, 512bytes</td></tr><tr><td><strong>Face Liveness Detection</strong></td><td align="center">Yes</td><td align="center">Yes</td></tr><tr><td><strong>Face Attribute Analysis</strong></td><td align="center">Pitch, Yaw, Roll</td><td align="center">Pitch, Yaw, Roll<br>Age, Gender<br>Eye Open<br>Mouth Close<br>Face Occlusion<br>Face Quality<br>Face Luminance</td></tr><tr><td><strong>1:N Identifiability</strong></td><td align="center">Yes</td><td align="center">Yes</td></tr></tbody></table>

## System Requirements

* Android 5.0 (API level 21) OS or newer
* At least 256 MB of free RAM should be available for the application.
* Java SE JDK 8 (or higher)
* Android Studio 4.0 IDE
* Android SDK 21+ API level


# Installation

The Android-FaceSDK is provided in **Android Library Project (AAR)** format.

## Download SDK

[**libfacesdk\_core.zip \[33M\]**](https://www.dropbox.com/scl/fi/6udmto3acu8mt7y4x66y9/libfacesdk_core.zip?rlkey=w7gnhvxz8njcvpnssb59a5u60\&st=lckwv8r7\&dl=0)

[**libfacesdk\_pro.zip \[46M\]**](https://www.dropbox.com/scl/fi/m02ykp7ilfevowd7hv6m7/libfacesdk_pro.zip?rlkey=632d06uqpc5s4fhi6cvka9c2a\&st=5lt2kotk\&dl=0)

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th></th></tr></thead><tbody><tr><td>build.gradle</td><td>Gradle build file</td></tr><tr><td>facesdk.aar</td><td>FaceSDK AAR file</td></tr></tbody></table>

## Add FaceSDK to Android Project <a href="#adding-the-android-sdk" id="adding-the-android-sdk"></a>

* Add the SDK folder to your Android project's root directory.
* Open the `build.gradle` file corresponding to the new, or existing Android Studio project that you want to integrate. Typically, this is the `build.gradle` file for the `app` module.
* Add the SDK to the `dependencies` section in your `build.gradle` file:

{% code overflow="wrap" %}

```gradle
dependencies {
    implementation project(path: ':libfacesdk')
}
```

{% endcode %}

* Include the SDK in your `settings.gradle` file:

{% code overflow="wrap" %}

```gradle
rootProject.name = "YourProjectName"
include ':app'
include ':libfacesdk'
```

{% endcode %}

* Build your project

<figure><img src="/files/W9O4dbV9iT8TRtclOop5" alt=""><figcaption></figcaption></figure>


# API Reference

### setActivation

{% code overflow="wrap" %}

```kotlin
public static native int setActivation(String var0);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>setActivation</td></tr><tr><td><strong>Description</strong></td><td>Activate SDK</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (String): The license string</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>The SDK activation status code.</p><ul><li>0: Success</li><li>Non-zero: Activation failed</li></ul></td></tr></tbody></table>

### init

{% code overflow="wrap" %}

```kotlin
public static native int init(AssetManager var0);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init</td></tr><tr><td><strong>Description</strong></td><td>Initiate SDK</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (AssetManager): An instance of AssetManager used to access application assets</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>The SDK initialization status code.</p><ul><li>0: Success</li><li>-1: License Key Error</li><li>-2: License AppID Error</li><li>-3: License Expired</li><li>-4: Activate Error</li><li>-5: Initialize SDK Error</li></ul></td></tr></tbody></table>

### yuv2Bitmap

{% code overflow="wrap" %}

```kotlin
public static native Bitmap yuv2Bitmap(byte[] nv21, int width, int height, int orientation);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>yuv2Bitmap</td></tr><tr><td><strong>Description</strong></td><td>Convert YUV camera frame to Bitmap image</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>nv21</strong> (byte[]): Byte array representing the YUV image data in NV21 format</li><li><strong>width</strong> (int): Width of the image</li><li><strong>height</strong> (int): Height of the image</li><li><strong>orientation</strong> (int): Orientation of the image</li></ul><p>       1 -> No processing<br>       2 -> Flip horizontally<br>       3 -> Flip horizontally first and then flip vertically<br>       4 -> Vertical flip<br>       5 -> Transpose<br>       6 -> Rotate 90° clockwise<br>       7 -> Horizontal and vertical flip --> Transpose<br>       8 -> Rotate 90° counterclockwise</p></td></tr><tr><td><strong>Output</strong></td><td>A Bitmap object representing the converted image</td></tr></tbody></table>

### faceDetection

{% code overflow="wrap" %}

```kotlin
public static native List<FaceBox> faceDetection(Bitmap var0, FaceDetectionParam var1);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>faceDetection</td></tr><tr><td><strong>Description</strong></td><td>Detect Face</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (Bitmap): The Bitmap image</li><li><strong>var1</strong> (<a href="#facedetectionparam"><strong>FaceDetectionParam</strong></a>): Parameters for face detection</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A list of <a href="#facebox"><strong>FaceBox</strong> </a>objects representing the detected faces.</td></tr></tbody></table>

#### FaceDetectionParam

* **FaceSDK - Core**

{% code overflow="wrap" %}

```kotlin
public class FaceDetectionParam {
    public boolean check_liveness = false;
    public int check_liveness_level = 0; // 0: more accurate model, 1: lighter model
}
```

{% endcode %}

* **FaceSDK - Pro**

{% code overflow="wrap" %}

```kotlin
public class FaceDetectionParam {
    public boolean check_liveness = false;
    public int check_liveness_level = 0; // 0: more accurate model, 1: lighter model
    public boolean check_eye_closeness = false;
    public boolean check_face_occlusion = false;
    public boolean check_mouth_opened = false;
    public boolean estimate_age_gender = false;
}
```

{% endcode %}

#### FaceBox

* **FaceSDK - Core**

{% code overflow="wrap" %}

```kotlin
public class FaceBox {
    public int x1;
    public int y1;
    public int x2;
    public int y2;
    public float liveness;
    public float yaw;
    public float roll;
    public float pitch;
}
```

{% endcode %}

* **FaceSDK - Pro**

{% code overflow="wrap" %}

```kotlin
public class FaceBox {
    public int x1;
    public int y1;
    public int x2;
    public int y2;
    public float yaw;
    public float roll;
    public float pitch;
    public float face_quality;
    public float face_luminance;
    public float liveness;
    public float left_eye_closed;
    public float right_eye_closed;
    public float face_occlusion;
    public float mouth_opened;
    public int age;
    public int gender;
    public float[] landmarks_68;
}
```

{% endcode %}

The liveness score ranges from 0.0 to 1.0\
**Default Liveness Threshold is 0.7**

### templateExtraction

{% code overflow="wrap" %}

```kotlin
public static native byte[] templateExtraction(Bitmap var0, FaceBox var1);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>templateExtraction</td></tr><tr><td><strong>Description</strong></td><td>Extract face feature</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (Bitmap): The Bitmap image</li><li><strong>var1</strong> (<a href="#facebox"><strong>FaceBox</strong></a>): The bounding box of the detected face</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A byte array representing the extracted template from the face</td></tr></tbody></table>

### similarityCalculation

{% code overflow="wrap" %}

```kotlin
public static native float similarityCalculation(byte[] var0, byte[] var1);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>similarityCalculation</td></tr><tr><td><strong>Description</strong></td><td>Calculate similarity between two face features</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (byte[]): The byte array representing the first face template</li><li><strong>var1</strong> (byte[]): The byte array representing the second face template</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A float value representing the similarity score between the two face templates<br>The score ranges from 0.0 to 1.0<br><strong>Default Threshold is 0.8</strong></td></tr></tbody></table>


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your Application ID

To activate SDK, you have to first get your Application ID in your `build.gradle` file:

```gradle
 android { 
     namespace 'com.bio.facerecognition' 
     compileSdk 33 
  
     defaultConfig { 
         applicationId "com.bio.facerecognition" 
         minSdk 24 
         targetSdk 33 
         versionCode 4 
         versionName "1.3" 
```

## Request License

Share your Application ID with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Activate](/face-liveness-detection-sdk/integration-guide/android/api-reference#setactivation) the SDK with license key. Should be called before using of any other functions.

{% code title="MainActivity.kt" %}

```kotlin
import com.bio.facesdk.FaceSDK

val license_str = application.assets.open("license").bufferedReader().use{ 
    it.readText() 
} 
  
var ret = FaceSDK.setActivation(license_str) 
  
if (ret == FaceSDK.SDK_SUCCESS) { 
    ret = FaceSDK.init(assets) 
} 
```

{% endcode %}


# Sample Application

1:N Face Identification and Liveness Detection SDK Android Demo

{% embed url="<https://www.youtube.com/watch?v=9HM70PFa4lQ>" %}
NIST FRVT #1 Face Recognition, Liveness Detection Mobile SDK Demo
{% endembed %}

***

### Download APK

<table data-view="cards" data-full-width="false"><thead><tr><th></th><th data-hidden></th><th data-hidden></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Recognito_FaceDemo_Core.apk</td><td></td><td></td><td><a href="/files/3o0HeYVavQGPi0XBmvWy">/files/3o0HeYVavQGPi0XBmvWy</a></td><td><a href="https://www.dropbox.com/scl/fi/w11b9wl80tqo9mf9op33f/Recognito_FaceDemo_Core.apk?rlkey=ne9r67ixan6xk4luau9eucj7g&#x26;st=mvp9c5gd&#x26;dl=0">https://www.dropbox.com/scl/fi/w11b9wl80tqo9mf9op33f/Recognito_FaceDemo_Core.apk?rlkey=ne9r67ixan6xk4luau9eucj7g&#x26;st=mvp9c5gd&#x26;dl=0</a></td></tr><tr><td>Recognito_FaceDemo_Pro.apk</td><td></td><td></td><td><a href="/files/3o0HeYVavQGPi0XBmvWy">/files/3o0HeYVavQGPi0XBmvWy</a></td><td><a href="https://www.dropbox.com/scl/fi/n8eqf1y6ah021n38s3gvv/Recognito_FaceDemo_Pro.apk?rlkey=1mfhdcb23l788jo1v4t5kazno&#x26;st=ls235b8z&#x26;dl=0">https://www.dropbox.com/scl/fi/n8eqf1y6ah021n38s3gvv/Recognito_FaceDemo_Pro.apk?rlkey=1mfhdcb23l788jo1v4t5kazno&#x26;st=ls235b8z&#x26;dl=0</a></td></tr></tbody></table>

***

## Build Project

### - Download and Open Project

* Download&#x20;
  * [**Recognito\_Face\_Android\_Core.zip\[33.6M\]**](https://www.dropbox.com/scl/fi/jqku6qlfwkdavq808wycv/Recognito_Face_Android_Core.zip?rlkey=z5pfxpt094qhjhwq7mbia3r57\&st=gv2v5yfo\&dl=0)
  * [**Recognito\_Face\_Android\_Pro.zip\[46.7M\]**](https://www.dropbox.com/scl/fi/oszbz04zb9ucp0zdf4lxf/Recognito_Face_Android_Pro.zip?rlkey=yvk93jbxbtlvmcl7g57gohym1\&st=tevuby7j\&dl=0)
* Open the `FaceRecognition` project in Android Studio.

### - Setting Up SDK License Key

* Add license to `assets/license` file:

{% code title="Android-FaceRecognition-FaceLivenessDetection/app/src/main/assets/license" lineNumbers="true" %}

```
 BsTr9o4f4R/rM3TxbCWVb/hrOJuOIdz8ArQ/t2IgQFFUQzGHOLNNaMJiK/fUfr5zo005zoTA/cm6 
 VoZ6iGl+/hZGA3R5T/VWwhxekbw8JVz9sNesU6rMG5+1cNSN75trH2tpzdCPZ28ZDnZlttmiuUoC 
 9QazRe1xKi5tUXa+xgIxzL0vE6UW2dLKWaEXjn3fSJfLxXWw0q+UZP0hQAXb5Y9Yl/NVi7y3d0xT 
 Vq6/weuMQkgLcNdLqFRvQXup0M9W/pvuhaubySAxHCKVY8wToygN2iM78cOkyyAbGVwZeGQP0Jfd 
 46VZo+w+KCNw355j3osVVMghrOcVZnfbp1dNyg== 
```

{% endcode %}

* Build Project.

### - Integration Guide

* Import FaceSDK

```kotlin
import com.bio.facesdk.FaceBox
import com.bio.facesdk.FaceDetectionParam
import com.bio.facesdk.FaceSDK
```

* Activate and Initialize FaceSDK

```kotlin
var ret = FaceSDK.setActivation(license_str)

if (ret == FaceSDK.SDK_SUCCESS) {
    ret = FaceSDK.init(assets)
}
```

* YUV to Bitmap for camera frame

```kotlin
override fun process(frame: Frame) {
    val bitmap = FaceSDK.yuv2Bitmap(frame.image, frame.size.width, frame.size.height, cameraOrientation)
    ...
```

* Set `FaceDetectionParam` and Detect Face

```kotlin
val faceDetectionParam = FaceDetectionParam()
faceDetectionParam.check_liveness = true
faceDetectionParam.check_liveness_level = SettingsActivity.getLivenessModelType(this)
faceDetectionParam.check_eye_closeness = true // available for pro version
faceDetectionParam.check_face_occlusion = true // available for pro version
faceDetectionParam.check_mouth_opened = true // available for pro version
faceDetectionParam.estimate_age_gender = true // available for pro version
var faceBoxes: List<FaceBox>? = FaceSDK.faceDetection(bitmap, faceDetectionParam)
```

* Extract Face Template

```kotlin
val faceBox = faceBoxes[0]
val templates = FaceSDK.templateExtraction(bitmap, faceBox)
```

* Calculate Similarity

```kotlin
val similarity = FaceSDK.similarityCalculation(templates, person.templates)
```

***

## Application UI

<div><figure><img src="/files/jGuNuRDga2c4QnDsDdaz" alt=""><figcaption></figcaption></figure> <figure><img src="/files/tdXFr34AIpk2rhS6IGuK" alt=""><figcaption></figcaption></figure> <figure><img src="/files/uLOLbY0893owYQtCNN3A" alt=""><figcaption></figcaption></figure> <figure><img src="/files/ghDaUvVcX5HfkE2CB4Nt" alt=""><figcaption></figcaption></figure> <figure><img src="/files/Mv2RxbjrmZd3rwI9Ez8b" alt=""><figcaption></figcaption></figure> <figure><img src="/files/oJEIK3rZY8RUYq7i7c0q" alt=""><figcaption></figcaption></figure></div>


# iOS

Face Liveness Detection SDK for iOS

This guide introduces RECOGNITO iOS-Face SDK for onboarding & eKYC cases.

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">iOS-Face SDK</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">Objective C/Swift</td></tr><tr><td><strong>Face Detection</strong></td><td align="center">Multiple Faces</td></tr><tr><td><strong>Face Feature Extraction</strong></td><td align="center">Yes, 512bytes</td></tr><tr><td><strong>Face Liveness Detection</strong></td><td align="center">Yes</td></tr><tr><td><strong>Face Attribute Analysis</strong></td><td align="center">Pitch, Yaw, Roll</td></tr><tr><td><strong>1:N Identifiability</strong></td><td align="center">Yes</td></tr></tbody></table>

## System Requirements

* Mac running macOS 10.13 or newer
* Xcode 9.3 or newer
* iPhone 5S or newer iPhone (iOS 11.0 or newer)


# Installation

The iOS-FaceSDK is provided in **Framework** format.

## Download SDK

Download [**ios\_facesdk.zip \[21M\]**](https://www.dropbox.com/scl/fi/xtwc12fdeq5h9k7t5r2ny/ios_facesdk.zip?rlkey=wsjmyakre6c09ocbs1xytrnts\&st=6u8w2x7j\&dl=0)

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th></th></tr></thead><tbody><tr><td><strong>facesdk.framework</strong></td><td>FaceSDK framework file</td></tr><tr><td>FaceDemo-Bridging-Header.h</td><td>Bridging Header file for Objective-C and Swift</td></tr></tbody></table>

## Add FaceSDK to iOS Project <a href="#adding-the-android-sdk" id="adding-the-android-sdk"></a>

* Copy and Add `facesdk.framework` into the project

<figure><img src="/files/piMZ63PxPPzAyQ6DoB4G" alt=""><figcaption></figcaption></figure>

* Add `FaceDemo-Bridging-Header.h` to Build Settings

<figure><img src="/files/mSeXJZ5gfA48D01DPHVw" alt=""><figcaption></figcaption></figure>

* Build your project

<figure><img src="/files/nUnNPU413EqwAwLqFUOw" alt=""><figcaption></figcaption></figure>


# API Reference

### setActivation

{% code overflow="wrap" %}

```swift
+(int)setActivation:(NSString*)license;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>setActivation</td></tr><tr><td><strong>Description</strong></td><td>Activate SDK</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>license</strong> (NSString*): The license string</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>The SDK activation status code.</p><ul><li>0: Success</li><li>Non-zero: Activation failed</li></ul></td></tr></tbody></table>

### initSDK

{% code overflow="wrap" %}

```swift
+(int)initSDK;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>initSDK</td></tr><tr><td><strong>Description</strong></td><td>Initiate SDK</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td><p>The SDK initialization status code.</p><ul><li>0: Success</li><li>-1: License Key Error</li><li>-2: License AppID Error</li><li>-3: License Expired</li><li>-4: Activate Error</li><li>-5: Initialize SDK Error</li></ul></td></tr></tbody></table>

### faceDetection

{% code overflow="wrap" %}

```swift
+(NSMutableArray*)faceDetection:(UIImage*)image;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>faceDetection</td></tr><tr><td><strong>Description</strong></td><td>Detect Face</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>image</strong> (UIImage*): The input image</li></ul></td></tr><tr><td><strong>Output</strong></td><td>An array of <a href="/pages/acYCwClH0Eh3auberFsG#facebox"><strong>FaceBox</strong></a> objects representing the detected faces.</td></tr></tbody></table>

#### FaceBox

{% code overflow="wrap" %}

```swift
@interface FaceBox : NSObject

@property (nonatomic) int x1;
@property (nonatomic) int y1;
@property (nonatomic) int x2;
@property (nonatomic) int y2;
@property (nonatomic) float liveness;
@property (nonatomic) float yaw;
@property (nonatomic) float roll;
@property (nonatomic) float pitch;
@end
```

{% endcode %}

The liveness score ranges from 0.0 to 1.0\
**Default Liveness Threshold is 0.7**

### templateExtraction

{% code overflow="wrap" %}

```swift
+(NSData*)templateExtraction:(UIImage*)image faceBox:(FaceBox*)faceBox;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>templateExtraction</td></tr><tr><td><strong>Description</strong></td><td>Extract face feature</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>image</strong> (UIImage*): The input image</li><li><strong>faceBox</strong> (<a href="#facebox"><strong>FaceBox</strong></a><strong>*</strong>): The bounding box of the detected face</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A NSData representing the extracted template from the face</td></tr></tbody></table>

### similarityCalculation

{% code overflow="wrap" %}

```swift
+(float)similarityCalculation:(NSData*)templates1 templates2:(NSData*)templates2;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>similarityCalculation</td></tr><tr><td><strong>Description</strong></td><td>Calculate similarity between two face features</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>templates1</strong> (NSData*): The first face template</li><li><strong>templates2</strong> (NSData*): The second face template</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A float value representing the similarity score between the two face templates<br>The score ranges from 0.0 to 1.0<br><strong>Default Threshold is 0.8</strong></td></tr></tbody></table>


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your Bundle ID

To activate SDK, you have to first get your Bundle ID:

<figure><img src="/files/c8QFrEcQxb2E07icB867" alt=""><figcaption></figcaption></figure>

## Request License

Share your Bundle ID with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Activate](/face-liveness-detection-sdk/integration-guide/ios/api-reference#setactivation) the SDK with license key. Should be called before using of any other functions.

```swift
override func viewDidLoad() {
    super.viewDidLoad()
    var ret = SDK_LICENSE_KEY_ERROR.rawValue
    if let filePath = Bundle.main.path(forResource: "license", ofType: "txt") {
        do {
            let license = try String(contentsOfFile: filePath, encoding: .utf8)
            ret = FaceSDK.setActivation(license)
        } catch {
            print("Error reading file: \(error)")
        }
    } else {
        print("File not found")
    }
    
    if(ret == SDK_SUCCESS.rawValue) {
        ret = FaceSDK.initSDK()
    }
```


# Sample Application

1:N Face Identification and Liveness Detection SDK iOS Demo

{% embed url="<https://www.youtube.com/watch?v=9HM70PFa4lQ>" %}
NIST FRVT #1 Face Recognition, Liveness Detection Mobile SDK Demo
{% endembed %}

***

## Build Project

### - Download and Open Project

* Download [**Recognito\_Face\_iOS.zip \[21.8M\]**](https://www.dropbox.com/scl/fi/2f9kmzk4pvt1a1835c04t/Recognito_Face_iOS.zip?rlkey=xqny98ifgsgoglgwfc6edvsvb\&st=ntq0lsl3\&dl=0)
* Open the `FaceDemo` project in Xcode.

### - Setting Up SDK License Key

* Add your license to `license.txt` file:

{% code title="iOS-FaceRecognition-FaceLivenessDetection/license.txt" lineNumbers="true" %}

```
 jwIUC3mm7P9uJDPxx/gRUttdS3bDg5n3QFnyySRB/E776MSPQAMubdyFTuzFb7BCdOx4EuoHmcsO 
 rpeGfI+Z371p/7cInVsnxLZU7PcSJh45Dd7c6maTg0QPwNLDHqdyNzRLFwKXXOX/IVuQNh6Dsen1 
 mwk6RGQZfReSUU6nLvWzC5sPgYhBVemExbbIa3UdDbBC+Bm4qNeXQ2i/08s9GFrhhbuvdYyI5TGl 
 6aVFjSGoHQhm/ENI1916+ck7BiguXMA1KFRTlchSWKhyb9CllHOGTomkoBUD3ykLlMGkcuZE8wT6 
 qpaHrtnmz1TgkP3tjK7L61BaEpWNib3uH29hWA== 
```

{% endcode %}

* Build Project.

### - Integration Guide

* Activate and Initialize FaceSDK

```swift
override func viewDidLoad() {
    super.viewDidLoad()
    var ret = SDK_LICENSE_KEY_ERROR.rawValue
    if let filePath = Bundle.main.path(forResource: "license", ofType: "txt") {
        do {
            let license = try String(contentsOfFile: filePath, encoding: .utf8)
            ret = FaceSDK.setActivation(license)
        } catch {
            print("Error reading file: \(error)")
        }
    } else {
        print("File not found")
    }
    
    if(ret == SDK_SUCCESS.rawValue) {
        ret = FaceSDK.initSDK()
    }
```

* Detect Face from Camera Frame

```swift
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {    
    guard let pixelBuffer: CVPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
    
    CVPixelBufferLockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly)
    let ciImage = CIImage(cvPixelBuffer: pixelBuffer)
    
    let context = CIContext()
    let cgImage = context.createCGImage(ciImage, from: ciImage.extent)
    let image = UIImage(cgImage: cgImage!)
    CVPixelBufferUnlockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly)

    // Rotate and flip the image
    var capturedImage = image.rotate(radians: .pi/2)
    if(cameraLens_val == .front) {
        capturedImage = capturedImage.flipHorizontally()
    }
    
    let faceBoxes = FaceSDK.faceDetection(capturedImage)
```

* Extract Face Template

```swift
let faceBox = faceBoxes[0] as! FaceBox 
if(faceBox.liveness > livenessThreshold) {
    let templates = FaceSDK.templateExtraction(capturedImage, faceBox: faceBox)
    ...
```

* Calculate Similarity

```swift
let similarity = FaceSDK.similarityCalculation(templates, templates2: personTemplates)                    
```

***

## Application UI

<div><figure><img src="/files/gNM7fqcRqAeL7xwU0aIl" alt=""><figcaption></figcaption></figure> <figure><img src="/files/8CukMIvv7dOxOsiDjYzG" alt=""><figcaption></figcaption></figure> <figure><img src="/files/wgLcL2ti5csrbOHf5VkR" alt=""><figcaption></figcaption></figure> <figure><img src="/files/bOmqH54bNLg0Lokiltn0" alt=""><figcaption></figcaption></figure> <figure><img src="/files/XA8dMWBXwAM5aJtn6Bsp" alt=""><figcaption></figcaption></figure> <figure><img src="/files/E1qaQgqGVDLL3GQRggUu" alt=""><figcaption></figcaption></figure></div>


# Flutter

Face Liveness Detection SDK for Flutter

This guide introduces RECOGNITO **Flutter-Face SDK** for onboarding & eKYC cases.

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Face SDK - Core</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">Dart</td></tr><tr><td><strong>Face Detection</strong></td><td align="center">Multiple Faces</td></tr><tr><td><strong>Face Feature Extraction</strong></td><td align="center">Yes, 512bytes</td></tr><tr><td><strong>Face Liveness Detection</strong></td><td align="center">Yes</td></tr><tr><td><strong>Face Attribute Analysis</strong></td><td align="center">Pitch, Yaw, Roll</td></tr><tr><td><strong>1:N Identifiability</strong></td><td align="center">Yes</td></tr></tbody></table>


# Installation

## FaceSDK Plugin Setup

* Download plugin package from [**facesdk\_plugin.zip**](https://www.dropbox.com/scl/fi/yp12mnwhtf49fm6g3zi7b/facesdk_plugin.zip?rlkey=noo23lgs9tw04edm8arv2z4pz\&st=f2y6t07h\&dl=0) and extract to the root folder of your flutter project.

<div data-full-width="false"><figure><img src="/files/10TsVGjhHQyqFTGILOVO" alt=""><figcaption></figcaption></figure></div>

* Add `facesdk_plugin` package to `dependencies` in `pubspec.yaml` file.

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

<figure><img src="/files/jF3t5JMa9g2cKROikzhj" alt=""><figcaption></figcaption></figure>

* Import `facesdk_plugin` package in dart files.

<figure><img src="/files/1CprHTjv3142LbIwP5Bs" alt=""><figcaption></figcaption></figure>

## Android Setup

* Download Android SDK from [**libfacesdk\_core.zip**](https://www.dropbox.com/scl/fi/6udmto3acu8mt7y4x66y9/libfacesdk_core.zip?rlkey=w7gnhvxz8njcvpnssb59a5u60\&st=thrgclok\&dl=0) and extract to `android` folder in your flutter project.

<figure><img src="/files/dYG5VY2MthG8WuQaV8iy" alt=""><figcaption></figcaption></figure>

* Add `libfacesdk` to `settings.gradle` in android folder.

<figure><img src="/files/foLBc4EZq9pprCxRbrp5" alt=""><figcaption></figcaption></figure>

## iOS Setup

* iOS SDK `facesdk.framework` is already included in the `facesdk_plugin` package, so you don't need to download and import it into your project.

<figure><img src="/files/FChJNjDjk55gkZIDG0q4" alt=""><figcaption></figcaption></figure>

## Project Setup

For project setup, run the following commands:

```bash
flutter pub get
```


# API Reference

### setActivation

{% code overflow="wrap" %}

```dart
Future<int?> setActivation(String license)
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>setActivation</td></tr><tr><td><strong>Description</strong></td><td>Activate SDK</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>license</strong>: The license string</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>The SDK activation status code.</p><ul><li>0: Success</li><li>Non-zero: Activation failed</li></ul></td></tr></tbody></table>

### init

{% code overflow="wrap" %}

```dart
Future<int?> init() 
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init</td></tr><tr><td><strong>Description</strong></td><td>Initiate SDK</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td><p>The SDK initialization status code.</p><ul><li>0: Success</li><li>-1: License Key Error</li><li>-2: License AppID Error</li><li>-3: License Expired</li><li>-4: Activate Error</li><li>-5: Initialize SDK Error</li></ul></td></tr></tbody></table>

### setParam

{% code overflow="wrap" %}

```dart
Future<void> setParam(Meap<String, Object> params)
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>setParam</td></tr><tr><td><strong>Description</strong></td><td>Set Face Detection parameters </td></tr><tr><td><strong>Input</strong></td><td><ul><li><p><strong>params</strong> face detection parameters</p><pre class="language-dart"><code class="lang-dart">'check_liveness_level'
0: liveness v1 -> more accurate model
1: liveness v2-fast -> lighter model
</code></pre></li></ul></td></tr><tr><td><strong>Output</strong></td><td>None</td></tr></tbody></table>

### extractFaces

{% code overflow="wrap" %}

```kotlin
Future<dynamic> extractFaces(String imagePath)
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>extractFaces</td></tr><tr><td><strong>Description</strong></td><td>Detect and extract face templates from image file</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>imagePath</strong> : Image file path</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Face detection result</p><pre><code>{
 "x1": face.x1,
 "y1": face.y1,
 "x2": face.x2,
 "y2": face.y2,
 "liveness": face.liveness,
 "yaw": face.yaw,
 "roll": face.roll,
 "pitch": face.pitch,
 "templates": templates,
 "faceJpg": faceJpg,
 "frameWidth": bitmap!!.width,
 "frameHeight": bitmap!!.height
}
</code></pre></td></tr></tbody></table>

### similarityCalculation

{% code overflow="wrap" %}

```dart
Future<double?> similarityCalculation(
Uint8List templates1, Uint8List templates2)
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>similarityCalculation</td></tr><tr><td><strong>Description</strong></td><td>Calculate similarity between two face features</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>templates1</strong>: The first face template</li><li><strong>templates2</strong>: The second face template</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A float value representing the similarity score between the two face templates<br>The score ranges from 0.0 to 1.0<br><strong>Default Threshold is 0.8</strong></td></tr></tbody></table>

### onFaceDetected&#x20;

```dart
void onFaceDetected(faces)
```

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>onFaceDetected</td></tr><tr><td><strong>Description</strong></td><td>callback function for face detection on camera stream</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td>Face detection result in camera frame</td></tr></tbody></table>

callback function definition

```java
@Override
    public void onFrame(Bitmap bitmap) {

        ArrayList<HashMap<String, Object>> faceBoxesMap = new ArrayList<HashMap<String, Object>>();
        FaceDetectionParam param = new FaceDetectionParam();
        param.check_liveness = true;
        param.check_liveness_level = FaceDetectionFlutterView.livenessDetectionLevel;

        List<FaceBox> faceBoxes = FaceSDK.faceDetection(bitmap, param);
        for(int i = 0; i < faceBoxes.size(); i ++) {
            FaceBox faceBox = faceBoxes.get(i);
            byte[] templates = FaceSDK.templateExtraction(bitmap, faceBox);
           Bitmap faceImage = Utils.cropFace(bitmap, faceBox);
           ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
           faceImage.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
           byte[] faceJpg = byteArrayOutputStream.toByteArray();

            HashMap<String, Object> e = new HashMap<String, Object>();
            e.put("x1", faceBox.x1);
            e.put("y1", faceBox.y1);
            e.put("x2", faceBox.x2);
            e.put("y2", faceBox.y2);
            e.put("liveness", faceBox.liveness);
            e.put("yaw", faceBox.yaw);
            e.put("roll", faceBox.roll);
            e.put("pitch", faceBox.pitch);
            e.put("templates", templates);
            e.put("faceJpg", faceJpg);
            e.put("frameWidth", bitmap.getWidth());
            e.put("frameHeight", bitmap.getHeight());

            faceBoxesMap.add(e);
        }

        Message message = new Message();
        message.what = 1;
        message.obj = faceBoxesMap;
        channelHandler.sendMessage(message);
    }
```


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Android Activation

To activate Android SDK, you have to first get your Application ID in your `android/app/build.gradle` file:

```gradle
android {
    ...
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.bio.facerecognition_flutter"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 24
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    ...
}
```

## iOS Activation

To activate iOS SDK, you have to get your Bundle ID.

```objectivec
buildSettings = {
	ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
	CLANG_ENABLE_MODULES = YES;
	CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
	DEVELOPMENT_TEAM = "";
	ENABLE_BITCODE = NO;
	INFOPLIST_FILE = Runner/Info.plist;
	LD_RUNPATH_SEARCH_PATHS = (
		"$(inherited)",
		"@executable_path/Frameworks",
	);
	PRODUCT_BUNDLE_IDENTIFIER = com.bio.facedemo;
	PRODUCT_NAME = "$(TARGET_NAME)";
	SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
	SWIFT_VERSION = 5.0;
	VERSIONING_SYSTEM = "apple-generic";
};
```

## Request License

Share your Application ID and Bundle ID with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Activate ](/face-recognition-sdk/integration-guide/flutter/api-reference#setactivation)the SDK with license key. Should be called before using of any other functions.

{% code title="main.dart" %}

```dart
try {
  if (Platform.isAndroid) {
    await _facesdkPlugin
        .setActivation(
            "EO5wcxhdMXJoLRpKq3Lexv2sTHPU8Ehed3vsBwmzdye/MJw+rVJTnY9SidD3vKV/2YNE6kufwIcC"
            "7LvLGFSORk3b14swPe7415aYSLKNI2RaUL5Nfn9oWHBjW1XehQLjLUx3w0Qi8bUth6vyg9Oaj7V7"
            "+dKruxjx/2dD2ddXKBoiIwYDonjW7gx7PmF9W66DXDtfRGpARvKW5Cn+jSCCH8A3Gft8wOBdQXM8"
            "UTDZUZxNbvozkgV6Dw9hMQJSka06iFK1h/UO6NrGLudt1SOC2b3hfoFJcAVjl3W7UTxzVyByJpLp"
            "tYTWJNr36pn1ixWhazLHC4s4TXtyQR67yzN3aw==")
        .then((value) => facepluginState = value ?? -1);
  } else {
    await _facesdkPlugin
        .setActivation(
            "H/Fs6Zgbsi9av6VVDAi54yqpYxnq0eDV3MSZAxMnARvUVePNY85UJu3d95nM7iO2RrCm19/eq+qb"
            "gSDmhJRYVJBMEUcxG+0cPPWVAW7m46dfS1Kpn+Flqbanfbco+Hd9Uda3aAzDkklzgdfYt7TvSXRt"
            "LZ8wW7jLiPjt8Lufj1GvhRzfESARv18VrxfQV+U8x3EqqvfKTJrkkg91NuAKvUZSoao4B5pQLpRd"
            "GwQ/saP9AQSWuyU1Zw+Whw/cnmXY2xZLGx6n/ict3NW9vpttv2tBbPCe/TdofRuJbE7R1Yb60BvQ"
            "ajzoaQWx3RsRgca9ah+Pccxb15tPVzr1apTK7A==")
        .then((value) => facepluginState = value ?? -1);
  }

  if (facepluginState == 0) {
    await _facesdkPlugin
        .init()
        .then((value) => facepluginState = value ?? -1);
  }
} catch (e) {}
```

{% endcode %}


# Sample Application

1:N Face Identification and Liveness Detection SDK Flutter Demo

{% embed url="<https://www.youtube.com/watch?v=9HM70PFa4lQ>" %}
NIST FRVT #1 Face Recognition, Liveness Detection Mobile SDK Demo
{% endembed %}

***

## Build Project

### - Download

* [**FaceRecognition-Flutter-main.zip**](https://www.dropbox.com/scl/fi/ylrp7q8qpet8e02mwtzui/FaceRecognition-Flutter-main.zip?rlkey=426bp3t0c0ekg5sq3k1ekodkt\&st=2w9kk1w9\&dl=0)

### - Setting Up SDK License Key

* Add license:

{% code title="main.dart" lineNumbers="true" %}

```dart
if (Platform.isAndroid) {
    await _facesdkPlugin.setActivation(
        "EO5wcxhdMXJoLRpKq3Lexv2sTHPU8Ehed3vsBwmzdye/MJw+rVJTnY9SidD3vKV/2YNE6kufwIcC"
        "7LvLGFSORk3b14swPe7415aYSLKNI2RaUL5Nfn9oWHBjW1XehQLjLUx3w0Qi8bUth6vyg9Oaj7V7"
        "+dKruxjx/2dD2ddXKBoiIwYDonjW7gx7PmF9W66DXDtfRGpARvKW5Cn+jSCCH8A3Gft8wOBdQXM8"
        "UTDZUZxNbvozkgV6Dw9hMQJSka06iFK1h/UO6NrGLudt1SOC2b3hfoFJcAVjl3W7UTxzVyByJpLp"
        "tYTWJNr36pn1ixWhazLHC4s4TXtyQR67yzN3aw==")
    .then((value) => facepluginState = value ?? -1);
} else {
    await _facesdkPlugin.setActivation(
        "H/Fs6Zgbsi9av6VVDAi54yqpYxnq0eDV3MSZAxMnARvUVePNY85UJu3d95nM7iO2RrCm19/eq+qb"
        "gSDmhJRYVJBMEUcxG+0cPPWVAW7m46dfS1Kpn+Flqbanfbco+Hd9Uda3aAzDkklzgdfYt7TvSXRt"
        "LZ8wW7jLiPjt8Lufj1GvhRzfESARv18VrxfQV+U8x3EqqvfKTJrkkg91NuAKvUZSoao4B5pQLpRd"
        "GwQ/saP9AQSWuyU1Zw+Whw/cnmXY2xZLGx6n/ict3NW9vpttv2tBbPCe/TdofRuJbE7R1Yb60BvQ"
        "ajzoaQWx3RsRgca9ah+Pccxb15tPVzr1apTK7A==")
    .then((value) => facepluginState = value ?? -1);
}
```

{% endcode %}

* Build Project.

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

***

## Application UI

<div><figure><img src="/files/jGuNuRDga2c4QnDsDdaz" alt=""><figcaption></figcaption></figure> <figure><img src="/files/tdXFr34AIpk2rhS6IGuK" alt=""><figcaption></figcaption></figure> <figure><img src="/files/uLOLbY0893owYQtCNN3A" alt=""><figcaption></figcaption></figure> <figure><img src="/files/ghDaUvVcX5HfkE2CB4Nt" alt=""><figcaption></figcaption></figure> <figure><img src="/files/Mv2RxbjrmZd3rwI9Ez8b" alt=""><figcaption></figcaption></figure> <figure><img src="/files/oJEIK3rZY8RUYq7i7c0q" alt=""><figcaption></figcaption></figure></div>


# Performance Overview

Global Coverage ID Document Recognition

**RECOGNITO ID Document Recognition SDK** is covering 14,000+ identity documents from 250+ countries and territories for fast, secure onboarding.

It can also recognize **Bank Credit Cards, MRZ and QR / BarCodes**.

## Supported ID Document Types

Recognito's ID Document Recognition SDK is built for seamless identity verification, efficiently reading and verifying **passports, ID cards, driver's licenses, visas, residence cards, and other ID documents**.\
Its AI-powered SDK quickly captures, reads, and validates data from IDs during remote onboarding, covering 14,000+ identity documents from 250+ countries and territories for fast, secure onboarding.

{% embed url="<https://recognito.vision/wp-content/uploads/2024/11/Recognito-Supported-Document-List.pdf>" %}

## Supported Languages

SDK supports 140+ languages including Latin, Cyrillic, Hebrew, Greek, Arabic, Chinese, and more.

{% embed url="<https://recognito.vision/wp-content/uploads/2024/11/Recognito-Supported-Language-Scripts.pdf>" %}


# Integration Guide


# Linux

ID Document Recognition SDK for Linux

This guide introduces RECOGNITO Linux-ID Document Recognition SDK for identity verification.

&#x20;After completing this guide, you will have downloaded SDK, run the Demo, tested each SDK APIs, and successfully integrated SDK into Your Application!

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Linux-ID Document Recognition SDK</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">C++/Python</td></tr><tr><td><strong>Document Detection and Cropping</strong></td><td align="center">Yes, Supports automatic detection and perspective transformation.</td></tr><tr><td><strong>Text Recognition (OCR)</strong></td><td align="center">Yes, Extracts text fields like name, ID number, date of birth, etc.</td></tr><tr><td><strong>MRZ Extraction</strong></td><td align="center">Yes, Automated MRZ detection and decoding for passports and visa documents.</td></tr><tr><td><strong>Barcode Reading</strong></td><td align="center">Yes, Supports for 1D and 2D barcodes (QR codes, PDF417)</td></tr><tr><td><strong>Portrait Detection and Cropping</strong></td><td align="center">Yes, Detects and extracts ID holder's photo for further processing, such as face matching or liveness detection.</td></tr><tr><td><strong>Field Validation</strong></td><td align="center">No</td></tr><tr><td><strong>Inference Time</strong></td><td align="center">&#x3C; 460ms :  Only Front page<br>&#x3C; 1300ms : Front and Back pages<br>Intel(R) Xeon(R) Gold 5315Y CPU @ 3.20GHz CPU: 8, RAM: 40 GB</td></tr></tbody></table>

## Recommended System Requirements

* **Operating System:** Ubuntu 20.04 or 22.04
* **CPU:** 8 cores
* **RAM:** 8 GB
* **HDD:** 8 GB


# Installation

## Download SDK

Download [**id\_recognition\_engine.zip**](https://www.dropbox.com/scl/fi/bcfbbcn0a6dqv6oa5qk5m/id_recognition_engine.zip?rlkey=08klo2fq8j113fjhcu54cn39w\&st=tb93ngxw\&dl=0)

Unpack the `id_recognition_engine.zip` archive into the desired directory.

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th width="227"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td>libimutils.so</td><td>libimutils so file for Ubuntu20.04</td></tr><tr><td></td><td>libimutils.so_for_ubuntu22</td><td>libimutils so file for Ubuntu22.04</td></tr><tr><td></td><td>libttvcore.so</td><td>OCR dependency so file</td></tr><tr><td><strong>engine\</strong></td><td><strong>bin\</strong></td><td>SDK binary files</td></tr><tr><td></td><td>header.py</td><td>Header file</td></tr><tr><td></td><td>libMetaChecker.so</td><td>File Meta Checking Library</td></tr><tr><td></td><td>libOCR.so</td><td>OCR Engine Library</td></tr></tbody></table>

## Install dependencies

* Install packages and requirements:

{% code overflow="wrap" %}

```sh
sudo apt-get install -y python3 python3-pip libcurl4-openssl-dev libssl-dev libopencv-dev libpcsclite-dev
```

{% endcode %}

* Copy dependency libraries:

{% code overflow="wrap" %}

```sh
sudo cp -f dependency/libimutils.so /usr/lib
sudo cp -f dependency/libttvcore.so /usr/lib
```

{% endcode %}

{% hint style="warning" %}
If the Ubuntu version is 22.04:

{% code overflow="wrap" %}

```sh
sudo cp -f dependency/libimutils.so_for_ubuntu22 /usr/lib/libimutils.so
```

{% endcode %}
{% endhint %}


# API Reference

### get\_deviceid <a href="#get_device_id" id="get_device_id"></a>

```python
def get_deviceid() -> str:
```

<table data-header-hidden><thead><tr><th width="136"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>get_device_id</td></tr><tr><td><strong>Description</strong></td><td>Retrieves the Hardware ID from a library.</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td>The Hardware ID is returned as a standard Python string.</td></tr></tbody></table>

### set\_activation

{% code overflow="wrap" %}

```python
def set_activation(license_key: str) -> str:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>set_activation</td></tr><tr><td><strong>Description</strong></td><td>Activates the OCR engine using the provided license key.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>license_key</strong> (str): License key string, this should be encoded as UTF-8.</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>A JSON-formatted string containing the result of the activation</p><p>Typically includes an "errorCode" field indicating the status of the activation. </p><ul><li>0: Success</li><li>Non-zero: Activation failed</li></ul></td></tr></tbody></table>

### init\_sdk

{% code overflow="wrap" %}

```python
def init_sdk(dict_path: str) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init_sdk</td></tr><tr><td><strong>Description</strong></td><td>Initializes the OCR engine with the required dictionary files.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>dict_path</strong> (str): Path to the engine binary files directory, This path must be provided as a UTF-8 encoded string.</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>A JSON-formatted string containing the result of the initialization. Typically includes an "errorCode" field indicating the status of the initialization.</p><ul><li>0: Success</li><li>Non-zero: Initialization failed</li></ul></td></tr></tbody></table>

### ocr\_id\_card

{% code overflow="wrap" %}

```python
def ocr_id_card(file_path1: str, file_path2: str) -> str
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>ocr_id_card</td></tr><tr><td><strong>Description</strong></td><td>Extracts data from ID card</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>file_path1</strong> (str): The path to the front image file.</li><li><strong>file_path2</strong> (str): The path to the back image file.</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A JSON-formatted string containing the OCR results.</td></tr></tbody></table>

#### Example of ID OCR results

<div><figure><img src="/files/it4aR7qDapsJd15iANCS" alt=""><figcaption></figcaption></figure> <figure><img src="/files/zHFVHd1PU0pFGABcCtRF" alt=""><figcaption></figcaption></figure></div>

```json
{
	"mrz":	{
		"givenNames":"JOHN",
		"name":"DOE JOHN",
		"dateOfExpiry":"2028-12-07",
		"documentClassCode":"ID",
		"nationality":"Ukraine",
		"surname":"DOE",
		"sex":"M",
		"dateOfBirth":"1964-09-02",
		"mrzCode":"IDUKR00235423491964090245614<<^6409029M2812070UKR<<<<<<<<<<<5^DOE<<JOHN<<<<<<<<<<<<<<<<<<<<<",
		"documentNumber":"002354234",
		"issuingStateCode":"UKR",
		"validState":1
	},
	"ocr":{
		"givenNames":"IOHN",
		"name":"DOE IOHN",
		"dateOfExpiry":"2028-12-27",
		"nationality":"Ukraine",
		"surname":"DOE",
		"sex":"M",
		"dateOfBirth":"1964-09-02",
		"documentNumber":"002354234",
		"personalNumber":"1964090245614",
		"dateOfIssue":"2018-12-27",
		"authority":"7110",
		"regCertRegNumber":"3449913065",
		"placeOfBirth":"Y HRYA",
		"validState":1
	},
	"nation":{
		"name":"\xd0\x94\xd0\x9e\xd0\xa3 \xd0\x94\xd0\x96\xd0\x9e\xd0\x9d \xd0\x99\xd0\x9e\xd0\x92\xd0\x90\xd0\x9d\xd0\x9e\xd0\x92\xd0\x98\xd0\xa7",
		"surname":"\xd0\x94\xd0\x9e\xd0\xa3",
		"givenNames":"\xd0\x94\xd0\x96\xd0\x9e\xd0\x9d",
		"fathersName":"\xd0\x99\xd0\x9e\xd0\x92\xd0\x90\xd0\x9d\xd0\x9e\xd0\x92\xd0\x98\xd0\xa7",
		"nationality":"\xd0\xa3\xd0\x9a\xd0\xa0\xd0\x90\xd0\x87\xd0\x9d\xd0\x90",
		"sex":"\xd0\xa7",
		"placeOfBirth":"\xd0\xa1.\xd0\x9f\xd0\x98\xd0\x90\xd0\x93 \xd0\x92\xd0\x90\xd0\x9b"
	},
	"score":0.934643983840942,
	"position":{
		"left":0,
		"top":0,
		"right":601,
		"bottom":384
	},
	"portrait_rect":{
		"bottom":398,
		"left":21,
		"right":255,
		"top":90
	},
	"errorCode":0,
	"documentName":"Id Card",
	"countryName":"Ukraine",
	"image":{
		"ghostPortrait":"/9j/4AAQSkZJRgABAQEAxw...T680Af/9k=",
		"portrait":"/9j/4AAQSkZJRgABAQEAxwDHA...de9P70f8A8RRRTQj/2Q==",
		"signature":"/9j/4AAQSkZJRgABAQEAxwDH...AAD/2wBDAKKEJH/2Q==",
		"documentFrontSide":"/9j/4AAQSkZJRgAB...D/2wKKKKACiiigD/2Q=="
	}
}

```

### ocr\_credit\_card

```python
def ocr_credit_card(file_path: str) -> str:
```

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>ocr_credit_card</td></tr><tr><td><strong>Description</strong></td><td>Etracts data from credit card</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>file_path</strong> (str): The path to the credit card image file.</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A JSON-formatted string containing the OCR results.</td></tr></tbody></table>

### ocr\_barcode

```
def ocr_barcode(file_path: str) -> str:
```

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>ocr_barcode</td></tr><tr><td><strong>Description</strong></td><td>Etracts data from barcode</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>file_path</strong> (str): The path to the barcode image file.</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A JSON-formatted string containing the OCR results.</td></tr></tbody></table>


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your HWID (Hardware ID)

To activate SDK, you have to first get your Hardware ID by using the [get\_device\_id ](broken://pages/UjLSzanLgbpi9IbNPkTi#get_device_id)function.

<figure><img src="/files/IwEForGuYeMHYBDy2GVG" alt=""><figcaption></figcaption></figure>

## Request License

After getting HWID, share it with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Activate ](/id-document-recognition-sdk/integration-guide/linux/api-reference#set_activation)the SDK with license key. Should be called before using of any other functions.

```python
set_activation(offline_key.encode('utf-8')).decode('utf-8')
```


# Sample Application

Linux-ID Document Recognition SDK Flask, Gradio Demo

## Docker

Pull the Docker image and run the container:

{% code overflow="wrap" %}

```sh
sudo docker pull recognito/id-ocr:latest
sudo docker run -it -e LICENSE_KEY="XXXXX-XXXXX-XXXXX-XXXXX" -p 8001:8000 -p 7861:7860 recognito/id-ocr:latest [OPTION --gradio(-g), --flask(-f)]
```

{% endcode %}

## Installation

### - Download

Download [**ID\_SDK.zip**](https://www.dropbox.com/scl/fi/raa1tcvw0fvupjr3tgqui/ID_SDK.zip?rlkey=44ummljjmqbi176kokzlmious\&st=n6m2twsr\&dl=0)

The Demo directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="206"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td>Dependency files</td></tr><tr><td><strong>engine\</strong></td><td>SDK engine files</td></tr><tr><td><strong>examples\</strong></td><td>Sample images</td></tr><tr><td><strong>flask\</strong></td><td>Flask server side demo code</td></tr><tr><td><strong>gradio\</strong></td><td>Gradio demo code</td></tr><tr><td>Dockerfile</td><td>Dockerfile for building a Docker image</td></tr><tr><td>install.sh</td><td>Script for install environment</td></tr><tr><td>license.txt</td><td>License key file</td></tr><tr><td>run_demo.sh</td><td>Script for run demo</td></tr></tbody></table>

### - Install dependencies

Run the `install.sh` script to install dependencies:

```sh
./install.sh
```

### - Setting Up SDK License Key

* **Online Licensing:** Set the online license key as an environment variable:

{% code overflow="wrap" %}

```sh
export LICENSE_KEY="XXXXX-XXXXX-XXXXX-XXXXX"
```

{% endcode %}

* **Offline Licensing:** Copy the `license.txt` license file to the demo directory.

***

## Test

### - Run Demo

Run the demo script with the desired option:

{% code overflow="wrap" %}

```sh
./run_demo.sh [OPTION --gradio(-g), --flask(-f), --help(-h)]
```

{% endcode %}

<figure><img src="/files/gaOsnVIFbOvrWZyCYzI6" alt=""><figcaption></figcaption></figure>

### - Test Flask Server APIs

To test the Flask Server API, you can use [Postman](https://www.postman.com/downloads/). Here are the endpoints for testing:

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/read\_idcard

&#x20; Extract data from ID card.

&#x20;   **Parameters**

&#x20;        **image:** image file for the front of ID card

&#x20;        **image2:** image file for the back of ID card

&#x20;   **Response**&#x20;

&#x20;        **data:** OCR result

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/read\_idcard\_base64

&#x20; Extract data from ID card base64 images.

&#x20;   **Parameters**

&#x20;        **image1:** base64 image for the front image

&#x20;        **image2:** base64 image for the back image

&#x20;   **Response**&#x20;

&#x20;        **data:** OCR result

<figure><img src="/files/r7bgvHHhdri7aOx8OLur" alt=""><figcaption><p>Postman usage guide for Flask Demo</p></figcaption></figure>

### - Test Gradio

Go to <http://127.0.0.1:7860/> on a web browser.

<figure><img src="/files/KsgsBCWMp4MEDuWt7hNh" alt=""><figcaption><p>Gradio Demo</p></figcaption></figure>

<div><figure><img src="/files/CzFTfIfZ2uWD0ZESCShb" alt=""><figcaption></figcaption></figure> <figure><img src="/files/j2DccQ7Wa02jkro4XcTG" alt=""><figcaption></figcaption></figure> <figure><img src="/files/TU8GYmsjx7yWOyGlf9MQ" alt=""><figcaption></figcaption></figure></div>


# Windows

Face Recognition SDK for Windows

This guide introduces RECOGNITO Windows-Face SDK for onboarding & eKYC.

&#x20;After completing this guide, you will have downloaded SDK, run the Demo, tested each SDK APIs, and successfully integrated SDK into Your Application!

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Windows-Face SDK</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">C++/Python</td></tr><tr><td><strong>Face Detection</strong></td><td align="center">Multiple Faces</td></tr><tr><td><strong>Face Feature Extraction</strong></td><td align="center">Yes, 2056bytes</td></tr><tr><td><strong>Face Liveness Detection</strong></td><td align="center">Yes</td></tr><tr><td><strong>Face Attribute Analysis</strong></td><td align="center">Age, Gender, Mask, Glass</td></tr><tr><td><strong>1:N Identifiability</strong></td><td align="center">Yes</td></tr></tbody></table>

{% hint style="info" %}
[How to implement 1:N identification with RECOGNITO SDK?](/how-to-implement-1-n-identification-with-recognito-sdk)
{% endhint %}

## Recommended System Requirements

* **Windows System:** Windows 10 or later
* **CPU:** 8 cores
* **RAM:** 8 GB
* **HDD:** 8 GB


# Installation

## Download SDK

Download [**win\_engine(pwd\_123).rar \[123M\]**](https://drive.google.com/file/d/1GkpMJjMYCwtGpdtuYX2LKYb8VkrlOJqs/view?usp=drive_link)

Unpack the `win_engine(pwd_123).rar` archive into the desired directory. The password of archive file is `123`.

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th width="227"></th><th></th></tr></thead><tbody><tr><td><strong>dependency</strong></td><td>python-3.8.9.exe</td><td>Python executable file for Python version 3.8.9</td></tr><tr><td></td><td>VC_redist.2013.exe</td><td>Microsoft Visual C++ Redistributable Package for Visual Studio 2013</td></tr><tr><td></td><td>VC_redist.2015-2022.exe</td><td>Microsoft Visual C++ Redistributable Package for Visual Studio versions 2015 through 2022</td></tr><tr><td><strong>engine\</strong></td><td>header.py</td><td>Header file</td></tr><tr><td></td><td>hwid.txt</td><td>Hardware ID dump file</td></tr><tr><td></td><td>license.txt</td><td>License key file</td></tr><tr><td></td><td>libttvrecog.dll</td><td>SDK dll file 1</td></tr><tr><td></td><td>libttvsdk.dll</td><td>SDK dll file 2</td></tr><tr><td></td><td>ttvfacewrapper.dll</td><td>SDK dll file 3</td></tr><tr><td></td><td>opencv_world300.dll</td><td>OpenCV library version 3.0.0</td></tr></tbody></table>

## Install dependencies

* Install `python-3.8.9.exe`, `VC_redist.2013.exe`, `VC_redist.2015-2022.exe` files from `dependency` directory.

{% hint style="warning" %}
When install `python-3.8.9.exe`, have to tick the `Add Python3.8 to PATH` option.

<img src="/files/KH9f4qKZ6cPflsoxKEG7" alt="" data-size="original">
{% endhint %}


# API Reference

### init\_sdk

{% code overflow="wrap" %}

```python
def init_sdk() -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init_sdk</td></tr><tr><td><strong>Description</strong></td><td>Initializes the SDK.</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of the initialization.</p><ul><li>0: Success</li><li>Non-zero: Initialization failed</li></ul></td></tr></tbody></table>

### get\_attribute

{% code overflow="wrap" %}

```python
def get_attribute(image: np.ndarray, width: int, height: int, face_results: ctypes.POINTER(FaceResult), max_face_num: int, mode: int) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>get_attribute</td></tr><tr><td><strong>Description</strong></td><td>Detects and analyzes face.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>image</strong> (numpy.ndarray): Input image matrix</li><li><strong>width</strong> (int): Width of the input image</li><li><strong>height</strong> (int): Height of the input image</li><li><strong>face_results</strong> (ctypes.POINTER): Pointer to a structure containing face results</li><li><strong>max_face_num</strong> (int): Maximum number of faces to detect</li><li><strong>mode</strong> (int): 0-> Enroll mode, 1-> Identify mode</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of getting attribute.</p><ul><li>>0: Number of detected faces</li><li>0: No Face</li><li>otherwise: Error</li></ul></td></tr></tbody></table>

Here is **`FaceResult`** Structure.

```python
class FaceResult(Structure):
    _fields_ = [
        ("x1", c_int32),
        ("y1", c_int32),
        ("x2", c_int32),
        ("y2", c_int32),
        ("liveness", c_int32),
        ("mask", c_int32),
        ("glass", c_int32),
        ("age", c_int32),
        ("gender", c_int32),
        ("feature", c_ubyte * 2056)
    ]
```

<table data-header-hidden><thead><tr><th width="226"></th><th></th></tr></thead><tbody><tr><td><strong>(x1, y1)</strong></td><td>Coordinate of the top-left corner of the bounding box of the detected face.</td></tr><tr><td><strong>(x2, y2)</strong></td><td>Coordinate of the bottom-right corner of the bounding box of the detected face.</td></tr><tr><td><strong>liveness</strong></td><td><p>Liveness score of detected face</p><ul><li>0 -> SPOOF</li><li>1 -> REAL</li><li>-3 -> TOO SMALL FACE</li><li>-4 -> TOO LARGE FACE</li><li>-102 -> NO FACE</li><li>-103 -> LIVENESS CHECK FAILED</li></ul></td></tr><tr><td><strong>mask</strong></td><td><p>Mask detection of the detected face</p><ul><li>0 -> No, 1 -> Yes</li></ul></td></tr><tr><td><strong>glass</strong></td><td><p>Glass detection of the detected face</p><ul><li>0 -> No, 1 -> Yes</li></ul></td></tr><tr><td><strong>age</strong></td><td>Estimated age of the detected face</td></tr><tr><td><strong>gender</strong></td><td><p>Gender prediction of the detected face</p><ul><li>0 -> Male, 1 -> Female</li></ul></td></tr><tr><td><strong>feature</strong></td><td>Template buffer. Extracted template will be stored</td></tr></tbody></table>

### calculate\_similarity

{% code overflow="wrap" %}

```python
def calculate_similarity(feature_1: np.ndarray, feature_2: np.ndarray) -> float:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>calculate_similarity</td></tr><tr><td><strong>Description</strong></td><td>Calculates the similarity between two features</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>feature_1</strong> (numpy.ndarray): 1st feature</li><li><strong>feature_2</strong> (numpy.ndarray): 2nd feature</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Similarity score between the two features</p><p>The score ranges from 0.0 to 1.0<br><strong>Default Threshold is 0.82</strong></p></td></tr></tbody></table>


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your HWID (Hardware ID)

To activate SDK, you have to first get your Hardware ID by using the [init\_sdk](broken://pages/KWrLRT4Ouh0XD7zkU37I#init_sdk) function.

<figure><img src="/files/78qyOqybhetb1HQAKd9r" alt=""><figcaption></figcaption></figure>

## Request License

After getting HWID, share it with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Initializes](broken://pages/KWrLRT4Ouh0XD7zkU37I#init_sdk) the SDK after copying license key file into `engine` directory. Should be called before using of any other functions.

<figure><img src="/files/QiFKNaLJmFWw2PjUH8Th" alt=""><figcaption></figcaption></figure>


# Sample Application

Windows-Face SDK(lite version) Flask, Gradio, Surveillance Demo

## Installation

### - Download

Download [**WinFaceSDKDemo.rar \[145M\]**](https://drive.google.com/file/d/1X31r6vHNYGVkhQNO2ph-bJmvCurTkNJX/view?usp=drive_link)

The Demo directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="206"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td>Dependency files</td></tr><tr><td><strong>engine\</strong></td><td>SDK engine files</td></tr><tr><td><strong>examples\</strong></td><td>Sample images</td></tr><tr><td><strong>flask\</strong></td><td>Flask server side demo code</td></tr><tr><td><strong>gradio\</strong></td><td>Gradio demo code</td></tr><tr><td><strong>video_surveillance_demo\</strong></td><td>1:N Video Surveillance demo code</td></tr></tbody></table>

### - Install dependencies

Install `python-3.8.9.exe`, `VC_redist.2013.exe`, `VC_redist.2015-2022.exe` files from `dependency` directory.

{% hint style="warning" %}
When install `python-3.8.9.exe`, have to tick the `Add Python3.8 to PATH` option.

<img src="/files/KH9f4qKZ6cPflsoxKEG7" alt="" data-size="original">
{% endhint %}

### - Setting Up SDK License Key

Copy the `license.txt` license file to the `engine` directory.

<figure><img src="/files/ZyEg5IaVih2uhc00dqiZ" alt=""><figcaption></figcaption></figure>

***

## Test

### - Test Flask Server APIs

* Install sub-dependencies for Flask Demo

{% code overflow="wrap" %}

```sh
cd flask
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="/files/YUvjevNtPVw90gJMP8lR" alt=""><figcaption></figcaption></figure>

* To test the Flask Server API, you can use [Postman](https://www.postman.com/downloads/). Here are the endpoints for testing:

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/analyze\_face

&#x20; Perform face analysis on an image file

&#x20;   **Parameters**

&#x20;        **image:** image file

&#x20;   **Response**&#x20;

&#x20;        **result:** face detection result

&#x20;        **face\_rect:** face bounding box of detected face

&#x20;        **attribute:** attributes(age, gender, liveness, mask,  wear\_glass) of detected face

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/compare\_face

&#x20; Perform face match between two face image files

&#x20;   **Parameters**

&#x20;        **image1:** image file for the 1st face

&#x20;        **image2:** image file for the 2nd face

&#x20;   **Response**&#x20;

&#x20;        **result:** face match result

&#x20;        **similarity:** similarity between two faces

&#x20;        **detection:** face bounding boxes of two faces

<figure><img src="/files/Rx0NCK0ldH6YpQ8BSgOx" alt=""><figcaption><p>Postman usage guide for Flask Demo (analyze_face)</p></figcaption></figure>

<figure><img src="/files/fCUlE6PkuBTk2MloW6Yw" alt=""><figcaption><p>Postman usage guide for Flask Demo (compare_face)</p></figcaption></figure>

### - Test Gradio

* Install sub-dependencies for Gradio Demo

{% code overflow="wrap" %}

```sh
cd gradio
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="/files/iEK28u6oGFFHAeQFcP3Q" alt=""><figcaption></figcaption></figure>

* Go to <http://127.0.0.1:7860/> on a web browser.

<figure><img src="/files/bNstcjGQyIsOi3HXG0CD" alt=""><figcaption><p>Gradio Demo (face attribute)</p></figcaption></figure>

<figure><img src="/files/lpboPVhZefBxYuRsRy2k" alt=""><figcaption><p>Gradio Demo (face recognition)</p></figcaption></figure>

### - Test 1:N Surveillance

* Install sub-dependencies for Surveillance Demo

{% code overflow="wrap" %}

```sh
cd video_surveillance_demo
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="/files/HwBVle116nMc5Dc0jAZ3" alt=""><figcaption></figcaption></figure>

* Main Page

When you run the `app.py` script, the main page appears first.

<figure><img src="/files/y6PnoLDgYTfiX3E52yoB" alt=""><figcaption><p>main page in 1:N surveillance</p></figcaption></figure>

* Register Person Page

You can enroll user from image.

<figure><img src="/files/bh01mvdhNkCd8Jd6q3qa" alt=""><figcaption><p>user registration page</p></figcaption></figure>

* User List Page

The registered user list is displayed.

<figure><img src="/files/IPBgCzmBOY26gOMvdmbr" alt=""><figcaption><p>user list page</p></figcaption></figure>

* Photo Match Page

You can identify registered users from selected image.

<figure><img src="/files/hy90BGRNotsmsmoLCRWF" alt=""><figcaption><p>photo match page</p></figcaption></figure>

* Video Surveillance Page

You can identify registered users from video stream.

Media file, RTSP stream, Web Camera can be used as video stream.

<figure><img src="/files/RByCitx6pUB5etIn3K6S" alt=""><figcaption><p>select video stream page</p></figcaption></figure>

<figure><img src="/files/5YXWL65097ffXDpQquEq" alt=""><figcaption><p>video surveillance page</p></figcaption></figure>


# Android

ID Document Recognition SDK for Android

This guide introduces RECOGNITO Android-ID Document Recognition SDK for identity verification.

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Android-ID Document Recognition SDK</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">Kotlin/Java</td></tr><tr><td><strong>Document Detection and Cropping</strong></td><td align="center">Yes, Supports automatic detection and perspective transformation.</td></tr><tr><td><strong>Text Recognition (OCR)</strong></td><td align="center">Yes, Extracts text fields like name, ID number, date of birth, etc.</td></tr><tr><td><strong>MRZ Extraction</strong></td><td align="center">Yes, Automated MRZ detection and decoding for passports and visa documents.</td></tr><tr><td><strong>Portrait Detection and Cropping</strong></td><td align="center">Yes, Detects and extracts ID holder's photo for further processing, such as face matching or liveness detection.</td></tr><tr><td><strong>Field Validation</strong></td><td align="center">No</td></tr></tbody></table>

## System Requirements

* Android 5.0 (API level 21) OS or newer
* At least 256 MB of free RAM should be available for the application.
* Java SE JDK 8 (or higher)
* Android Studio 4.0 IDE
* Android SDK 21+ API level


# Installation

The Android-ID Document Recognition SDK is provided in **Android Library Project (AAR)** format.

## Download SDK

Download [**libidsdk.zip \[102M\]**](https://www.dropbox.com/scl/fi/f3kfp8bfse929pcb3xk8a/libidsdk.zip?rlkey=x9t86n08il91yv1xo5m0kjo1s\&st=8t118hms\&dl=0)

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th></th></tr></thead><tbody><tr><td>build.gradle</td><td>Gradle build file</td></tr><tr><td>libidsdk.aar</td><td>ID SDK AAR file</td></tr></tbody></table>

## Add ID SDK to Android Project <a href="#adding-the-android-sdk" id="adding-the-android-sdk"></a>

* Add the SDK folder to your Android project's root directory.
* Open the `build.gradle` file corresponding to the new, or existing Android Studio project that you want to integrate. Typically, this is the `build.gradle` file for the `app` module.
* Add the SDK to the `dependencies` section in your `build.gradle` file:

{% code overflow="wrap" %}

```gradle
dependencies {
    implementation project(path: ':libidsdk')
}
```

{% endcode %}

* Include the SDK in your `settings.gradle` file:

{% code overflow="wrap" %}

```gradle
rootProject.name = "YourProjectName"
include ':app'
include ':libidsdk'
```

{% endcode %}

* Build your project

<figure><img src="/files/tmxCpA55EZQTuCRKWJSC" alt=""><figcaption></figcaption></figure>


# API Reference

### setActivation

{% code overflow="wrap" %}

```java
public static native int setActivation(String var0);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>setActivation</td></tr><tr><td><strong>Description</strong></td><td>Activate SDK</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (String): The license string</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>The SDK activation status code.</p><ul><li>0: Success</li><li>Non-zero: Activation failed</li></ul></td></tr></tbody></table>

### init

{% code overflow="wrap" %}

```java
public static native int init(ContextWrapper var0);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init</td></tr><tr><td><strong>Description</strong></td><td>Initiate SDK</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (ContextWrapper ): An instance to access application assets</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>The SDK initialization status code.</p><ul><li>0: Success</li><li>-1: License Key Error</li><li>-2: License AppID Error</li><li>-3: License Expired</li><li>-4: Activate Error</li><li>-5: Initialize SDK Error</li></ul></td></tr></tbody></table>

### yuv2Bitmap

{% code overflow="wrap" %}

```java
public static native Bitmap yuv2Bitmap(byte[] var0, int var1, int var2, int var3);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>yuv2Bitmap</td></tr><tr><td><strong>Description</strong></td><td>Convert YUV camera frame to Bitmap image</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (byte[]): Byte array representing the YUV image data in NV21 format</li><li><strong>var1</strong> (int): Width of the image</li><li><strong>var2</strong> (int): Height of the image</li><li><strong>var3</strong> (int): Orientation of the image</li></ul><p>       1 -> No processing<br>       2 -> Flip horizontally<br>       3 -> Flip horizontally first and then flip vertically<br>       4 -> Vertical flip<br>       5 -> Transpose<br>       6 -> Rotate 90° clockwise<br>       7 -> Horizontal and vertical flip --> Transpose<br>       8 -> Rotate 90° counterclockwise</p></td></tr><tr><td><strong>Output</strong></td><td>A Bitmap object representing the converted image</td></tr></tbody></table>

### idcardRecognition

{% code overflow="wrap" %}

```java
public static native String idcardRecognition(Bitmap var0);
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>idcardRecognition</td></tr><tr><td><strong>Description</strong></td><td>Extract data from ID Document</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>var0</strong> (Bitmap): The Bitmap image</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A string representing the extracted data.</td></tr></tbody></table>

#### Output Example for idcardRecognition

<figure><img src="/files/vV1UMJdk4tYgpjsSEkEQ" alt=""><figcaption></figcaption></figure>

{% code overflow="wrap" %}

```json
{
	"Document Number":"963545627",
	"Nationality":"USA",
	"Date of Issue":"2017-04-14",
	"Document Class Code":"P",
	"Issuing State Code":"USA",
	"Full Name":"JOHN DOE",
	"Date of Birth":"1996-03-15",
	"Sex":"M",
	"Date of Expiry":"2027-04-14",
	"Surname":"JOHN",
	"Given Names":"DOE",
	"Issuing State Name":"United States",
	"Authority":"United States,Department of State",
	"Place of Birth":"CALIFORNIA, U.S.A",
	"Document Name":"Passport",
	"Quality":99,
	"Position": {
		"x1":24,"y1":4294967295,"x2":577,"y2":381
	},
	"MRZ": {
		"Document Number":"963545637",
		"MRZ":"P<USAJOHN<<DOE<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,9635456374USA9603150M2704140202113962<804330",
		"Document Class Code":"P",
		"Issuing State Code":"USA",
		"Full Name":"JOHN DOE",
		"Nationality Code":"USA",
		"Date of Birth":"1996-03-15",
		"Sex":"M",
		"Date of Expiry":"2027-04-14",
		"Surname":"JOHN",
		"Given Names":"DOE",
		"Issuing State Name":"United States",
		"MRZ Type":"ID-3",
		"Validation":1
	},
	"Images":{
		"Portrait":"/9j/4AAQSkZJRgABAQEAxwDH....KUr2P//Z",
		"Document":"/9j/4AAQSkZJRgABAQEAxwDH....o/Dd8yZC"
	}
}
```

{% endcode %}


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your Application ID

To activate SDK, you have to first get your Application ID in your `build.gradle` file:

```gradle
android {
    namespace 'com.bio.idcardrecognition'
    compileSdk 34

    defaultConfig {
        applicationId "com.bio.idcardrecognition"
        minSdk 24
        targetSdk 34
        versionCode 5
        versionName "1.4"
```

## Request License

Share your Application ID with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Activate](/id-document-recognition-sdk/integration-guide/android/api-reference#setactivation) the SDK with license key. Should be called before using of any other functions.

{% code title="MainActivity.kt" %}

```kotlin
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        var ret = IDSDK.setActivation(
            "B3sUmGfASlu/p01TNEJxGHP/WTUk5NORuqgfggB25LQPYQBJzdw1lgiFfkE71/+8YhOKdU9wDVbY" +
            "pe/QHf/VbzO3Of7dME9gKjF2H3aNPHY90XNspz7iT1ntf5qd/STCbJVRJAorwBtPE7+BO3cHdVm8" +
            "CLFSclyUEI3/aiXLiT448B+KjvgEoX0CDswVOzpEVYmYphcUX+AbJQ135ostxmaZOMOhEtALEQYH" +
            "+SEIKrn/2+KOYsinZMOOvSWpeSnIrYj3z/AYHhKyR9doYEyCtc7qDwH9NPX3UC5WZc81ewc/K0JO" +
            "Lpe3a9tpGgFtLFEtVB4BwZdivnTf67BZZMMcAQ=="
        )
        if(ret  == IDSDK.SDK_SUCCESS) {
            ret = IDSDK.init(this)
        }

```

{% endcode %}


# Sample Application

ID Document Recognition Android Demo

{% file src="/files/tHmcjL5Y3o2Iz6KGn6fx" %}

### Download APK

<table data-view="cards" data-full-width="false"><thead><tr><th></th><th data-hidden></th><th data-hidden></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Recognito_IDOCR_Demo.apk</td><td></td><td></td><td><a href="/files/3o0HeYVavQGPi0XBmvWy">/files/3o0HeYVavQGPi0XBmvWy</a></td><td><a href="https://www.dropbox.com/scl/fi/1418y3ehqq21ql7xz3x97/Recognito_IDOCR_Demo.apk?rlkey=k1jaw6l2qzir34odaroy0bnvq&#x26;st=nfm8sclg&#x26;dl=0">https://www.dropbox.com/scl/fi/1418y3ehqq21ql7xz3x97/Recognito_IDOCR_Demo.apk?rlkey=k1jaw6l2qzir34odaroy0bnvq&#x26;st=nfm8sclg&#x26;dl=0</a></td></tr></tbody></table>

***

## Build Project

### - Download and Open Project

* Download [**IDCardRecognition-Android.zip\[103M\]**](https://www.dropbox.com/scl/fi/ivw5hokhmdqtr4k1ztr2r/IDCardRecognition-Android.zip?rlkey=bgjhifwk0qi92fygb5z59m9sz\&st=kg9r7kqw\&dl=0)
* Open the `IDCardRecognition-Android` project in Android Studio.

### - Setting Up SDK License Key

* Add license:

{% code title="IDCardRecognition-Android\app\src\main\java\com\bio\idcardrecognition\MainActivity.kt" lineNumbers="true" %}

```kotlin
var ret = IDSDK.setActivation(
    "B3sUmGfASlu/p01TNEJxGHP/WTUk5NORuqgfggB25LQPYQBJzdw1lgiFfkE71/+8YhOKdU9wDVbY" +
    "pe/QHf/VbzO3Of7dME9gKjF2H3aNPHY90XNspz7iT1ntf5qd/STCbJVRJAorwBtPE7+BO3cHdVm8" +
    "CLFSclyUEI3/aiXLiT448B+KjvgEoX0CDswVOzpEVYmYphcUX+AbJQ135ostxmaZOMOhEtALEQYH" +
    "+SEIKrn/2+KOYsinZMOOvSWpeSnIrYj3z/AYHhKyR9doYEyCtc7qDwH9NPX3UC5WZc81ewc/K0JO" +
    "Lpe3a9tpGgFtLFEtVB4BwZdivnTf67BZZMMcAQ=="
)
```

{% endcode %}

* Build Project.

### - Integration Guide

* Import ID SDK

```kotlin
import com.bio.idsdk.IDSDK
```

* Activate and Initialize ID SDK

```kotlin
var ret = IDSDK.setActivation(
    "B3sUmGfASlu/p01TNEJxGHP/WTUk5NORuqgfggB25LQPYQBJzdw1lgiFfkE71/+8YhOKdU9wDVbY" +
    "pe/QHf/VbzO3Of7dME9gKjF2H3aNPHY90XNspz7iT1ntf5qd/STCbJVRJAorwBtPE7+BO3cHdVm8" +
    "CLFSclyUEI3/aiXLiT448B+KjvgEoX0CDswVOzpEVYmYphcUX+AbJQ135ostxmaZOMOhEtALEQYH" +
    "+SEIKrn/2+KOYsinZMOOvSWpeSnIrYj3z/AYHhKyR9doYEyCtc7qDwH9NPX3UC5WZc81ewc/K0JO" +
    "Lpe3a9tpGgFtLFEtVB4BwZdivnTf67BZZMMcAQ=="
)
if(ret == IDSDK.SDK_SUCCESS) {
    ret = IDSDK.init(this)
}
```

* YUV to Bitmap for camera frame

```kotlin
override fun process(frame: Frame) {
    val bitmap = IDSDK.yuv2Bitmap(frame.image, frame.size.width, frame.size.height, 6)
    ...
```

* Extract Data

```kotlin
val result = IDSDK.idcardRecognition(bitmap)
```

***

## Application UI

<div><figure><img src="/files/8fMQ6MaAIvVKG0j1atQd" alt=""><figcaption></figcaption></figure> <figure><img src="/files/bx1AHazro2egGHLmSNsK" alt=""><figcaption></figcaption></figure> <figure><img src="/files/lDkJvntBX43HZHsNBosk" alt=""><figcaption></figcaption></figure> <figure><img src="/files/5rXJEOCgfhE9yK8aq8RF" alt=""><figcaption></figcaption></figure> <figure><img src="/files/ccGjp0ttBs9y1lDkd2sb" alt=""><figcaption></figcaption></figure> <figure><img src="/files/TBfMKlP1A3eakfHT9VuJ" alt=""><figcaption></figcaption></figure></div>


# iOS

ID Document Recognition SDK for iOS

This guide introduces RECOGNITO iOS-ID Document Recognition SDK for identity verification.

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">iOS-ID Document Recognition SDK</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">Objective C/Swift</td></tr><tr><td><strong>Document Detection and Cropping</strong></td><td align="center">Yes, Supports automatic detection and perspective transformation.</td></tr><tr><td><strong>Text Recognition (OCR)</strong></td><td align="center">Yes, Extracts text fields like name, ID number, date of birth, etc.</td></tr><tr><td><strong>MRZ Extraction</strong></td><td align="center">Yes, Automated MRZ detection and decoding for passports and visa documents.</td></tr><tr><td><strong>Portrait Detection and Cropping</strong></td><td align="center">Yes, Detects and extracts ID holder's photo for further processing, such as face matching or liveness detection.</td></tr><tr><td><strong>Field Validation</strong></td><td align="center">No</td></tr></tbody></table>

## System Requirements

* Mac running macOS 10.13 or newer
* Xcode 9.3 or newer
* iPhone 5S or newer iPhone (iOS 11.0 or newer)


# Installation

The iOS-ID Document Recognition SDK is provided in **Framework** format.

## Download SDK&#x20;

Download [**ios\_idsdk.zip \[146M\]**](https://www.dropbox.com/scl/fi/ycnjtrmxfdlqw52np4t98/ios_idsdk.zip?rlkey=r4ao2owdtrm8e1nv8jlxsf8fs\&st=acrk4ywj\&dl=0)

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th></th></tr></thead><tbody><tr><td><strong>idsdk.framework</strong></td><td>ID Document Recognition SDK framework file</td></tr><tr><td><strong>TTVOCRCore.framework</strong></td><td>OCR framework file</td></tr><tr><td>IDCardRecognition-Bridging-Header.h</td><td>Bridging Header file for Objective-C and Swift</td></tr></tbody></table>

## Add ID SDK to iOS Project <a href="#adding-the-android-sdk" id="adding-the-android-sdk"></a>

* Copy and Add `idsdk.framework` and TTVOCRCore.`framework` into the project

<figure><img src="/files/lolkjlt3rmcsYQNnXf77" alt=""><figcaption></figcaption></figure>

* Add `IDCardRecognition-Bridging-Header.h` to Build Settings

<figure><img src="/files/CvOWKxUFHzXIq14Vmlwk" alt=""><figcaption></figcaption></figure>

* Build your project

<figure><img src="/files/7RuUxAaDsk8eoMcgC1At" alt=""><figcaption></figcaption></figure>


# API Reference

### setActivation

{% code overflow="wrap" %}

```swift
+(int)setActivation:(NSString*)license;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>setActivation</td></tr><tr><td><strong>Description</strong></td><td>Activate SDK</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>license</strong> (NSString*): The license string</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>The SDK activation status code.</p><ul><li>0: Success</li><li>Non-zero: Activation failed</li></ul></td></tr></tbody></table>

### initSDK

{% code overflow="wrap" %}

```swift
+(int)initSDK;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>initSDK</td></tr><tr><td><strong>Description</strong></td><td>Initiate SDK</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td><p>The SDK initialization status code.</p><ul><li>0: Success</li><li>-1: License Key Error</li><li>-2: License AppID Error</li><li>-3: License Expired</li><li>-4: Activate Error</li><li>-5: Initialize SDK Error</li></ul></td></tr></tbody></table>

### idcardRecognition

{% code overflow="wrap" %}

```swift
+(NSMutableDictionary*)idcardRecognition:(UIImage*)image;
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>idcardRecognition</td></tr><tr><td><strong>Description</strong></td><td>Extract data from ID Document</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>image</strong> (UIImage*): The input image</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A dictionary representing the extracted data.</td></tr></tbody></table>

#### Output Example for idcardRecognition

<figure><img src="/files/z8BIXTSsf5vmq2cYHlCI" alt=""><figcaption></figcaption></figure>

{% code overflow="wrap" %}

```json
{
	"Document Number":"963545627",
	"Nationality":"USA",
	"Date of Issue":"2017-04-14",
	"Document Class Code":"P",
	"Issuing State Code":"USA",
	"Full Name":"JOHN DOE",
	"Date of Birth":"1996-03-15",
	"Sex":"M",
	"Date of Expiry":"2027-04-14",
	"Surname":"JOHN",
	"Given Names":"DOE",
	"Issuing State Name":"United States",
	"Authority":"United States,Department of State",
	"Place of Birth":"CALIFORNIA, U.S.A",
	"Document Name":"Passport",
	"Quality":99,
	"Position": {
		"x1":24,"y1":4294967295,"x2":577,"y2":381
	},
	"MRZ": {
		"Document Number":"963545637",
		"MRZ":"P<USAJOHN<<DOE<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,9635456374USA9603150M2704140202113962<804330",
		"Document Class Code":"P",
		"Issuing State Code":"USA",
		"Full Name":"JOHN DOE",
		"Nationality Code":"USA",
		"Date of Birth":"1996-03-15",
		"Sex":"M",
		"Date of Expiry":"2027-04-14",
		"Surname":"JOHN",
		"Given Names":"DOE",
		"Issuing State Name":"United States",
		"MRZ Type":"ID-3",
		"Validation":1
	},
	"Images":{
		"Portrait":"/9j/4AAQSkZJRgABAQEAxwDH....KUr2P//Z",
		"Document":"/9j/4AAQSkZJRgABAQEAxwDH....o/Dd8yZC"
	}
}
```

{% endcode %}


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your Bundle ID

To activate SDK, you have to first get your Bundle ID:

<figure><img src="/files/PeAwNcyYxEQwN9iDBeOr" alt=""><figcaption></figcaption></figure>

## Request License

Share your Bundle ID with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Activate](/id-document-recognition-sdk/integration-guide/ios/api-reference#setactivation) the SDK with license key. Should be called before using of any other functions.

```swift
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    
    var ret = IDSDK.setActivation("QbxKmXkM8E2X+CzScRgJZlVxWxIlQL5Scimac/QMNoCeCEzEyCbrIdd0rKU09QO5Zz9/NiSGk0xd" +
                       "T5TmKuLIAiwiac1GmOcF6yRH8+FeCfLAlX2yoyUI3EuXxgiJ9T+ZQD+y6cW9wOlO5vRxPtPD4H3t" +
                       "xTXkgrUzvKvMNI3e+08jfb7WfJ0VTaL3qzcZtQa9btQT1bNl2baUrWlA5W08P8GETFJq4mjHHusQ" +
                       "GUGx4a4OF78Rs2S3lbMs9XoeKy+aJEET/rPiubCf7Br1hytmYg9CDi+3mtdewL+6OCzWVntdKL4h" +
                       "IRqd+LAWqGgBYbiVzM9lstNiqCuvDE0bJ4Fn0w==")
    print("set activation: ", ret)
    if(ret == SDK_SUCCESS.rawValue) {
        ret = IDSDK.initSDK()
        print("init sdk: ", ret)
    }

}
```


# Sample Application

ID Document Recognition iOS Demo

{% file src="/files/TagauudjcRdk0n0C7CCO" %}

## Build Project

### - Download and Open Project

* Download [**IDCardRecognition-iOS.zip \[147M\]**](https://www.dropbox.com/scl/fi/fb9xeu6l6uetinceabdil/IDCardRecognition-iOS.zip?rlkey=02g8miakb0op9jg1vjajjgjas\&st=uy1od0s9\&dl=0)
* Open the `IDCardRecognition-iOS` project in Xcode.

### - Setting Up SDK License Key

* Add License key:

{% code title="ViewController.swift" lineNumbers="true" %}

```swift
var ret = IDSDK.setActivation("QbxKmXkM8E2X+CzScRgJZlVxWxIlQL5Scimac/QMNoCeCEzEyCbrIdd0rKU09QO5Zz9/NiSGk0xd" +
     "T5TmKuLIAiwiac1GmOcF6yRH8+FeCfLAlX2yoyUI3EuXxgiJ9T+ZQD+y6cW9wOlO5vRxPtPD4H3t" +
     "xTXkgrUzvKvMNI3e+08jfb7WfJ0VTaL3qzcZtQa9btQT1bNl2baUrWlA5W08P8GETFJq4mjHHusQ" +
     "GUGx4a4OF78Rs2S3lbMs9XoeKy+aJEET/rPiubCf7Br1hytmYg9CDi+3mtdewL+6OCzWVntdKL4h" +
     "IRqd+LAWqGgBYbiVzM9lstNiqCuvDE0bJ4Fn0w==")
```

{% endcode %}

* Build Project.

### - Integration Guide

* Activate and Initialize ID SDK

```swift
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    
    var ret = IDSDK.setActivation("QbxKmXkM8E2X+CzScRgJZlVxWxIlQL5Scimac/QMNoCeCEzEyCbrIdd0rKU09QO5Zz9/NiSGk0xd" +
                       "T5TmKuLIAiwiac1GmOcF6yRH8+FeCfLAlX2yoyUI3EuXxgiJ9T+ZQD+y6cW9wOlO5vRxPtPD4H3t" +
                       "xTXkgrUzvKvMNI3e+08jfb7WfJ0VTaL3qzcZtQa9btQT1bNl2baUrWlA5W08P8GETFJq4mjHHusQ" +
                       "GUGx4a4OF78Rs2S3lbMs9XoeKy+aJEET/rPiubCf7Br1hytmYg9CDi+3mtdewL+6OCzWVntdKL4h" +
                       "IRqd+LAWqGgBYbiVzM9lstNiqCuvDE0bJ4Fn0w==")
    print("set activation: ", ret)
    if(ret == SDK_SUCCESS.rawValue) {
        ret = IDSDK.initSDK()
        print("init sdk: ", ret)
    }

}
```

* Extract Data from Camera Frame

```swift
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
    if(self.cameraRunning == false) {
        return
    }
    
    if(Date().timeIntervalSince1970 - startTime <= 1) {
        return
    }

    guard let pixelBuffer: CVPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
           
    CVPixelBufferLockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly)
    let image = CIImage(cvPixelBuffer: pixelBuffer).oriented(CGImagePropertyOrientation.right)
    
    let context = CIContext(options: nil)
    guard let cg = context.createCGImage(image, from: image.extent) else {
        CVPixelBufferUnlockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly)
        return
    }

    let capturedImage = UIImage(cgImage: cg, scale: 1.0, orientation: .upMirrored).fixOrientation()
    CVPixelBufferUnlockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly)
    
    let result = IDSDK.idcardRecognition(capturedImage) as NSDictionary
```

***

## Application UI

<div><figure><img src="/files/0CDGdTgvbxG0cNGTcGgu" alt=""><figcaption></figcaption></figure> <figure><img src="/files/YzlW7k3Z0gXrDVuz0GGY" alt=""><figcaption></figcaption></figure> <figure><img src="/files/oKUmrWr5tstkiflQxtM8" alt=""><figcaption></figcaption></figure> <figure><img src="/files/Ni41YzT8C4yAyS6R0xfR" alt=""><figcaption></figcaption></figure> <figure><img src="/files/0WfHEBKDnM43uWSkNvQ7" alt=""><figcaption></figcaption></figure> <figure><img src="/files/EWOmr2WXEfwTvAmCPKnM" alt=""><figcaption></figcaption></figure></div>


# Performance Overview

ID Document Liveness Detection

**Recognito's ID Document Liveness Detection SDK** is a reliable solution for detecting fraudulent identity document presentation. Designed for digital onboarding, it ensures authenticity and prevents misuse with advanced AI capabilities.

## Comprehensive Fraud Detection

• **Screen Replay Attacks:** Detects when a document is presented on a digital screen such as a monitor, tablet, or mobile phone.&#x20;

• **Printed Copy Attacks:** Identifies documents that are photocopied, printed on paper, and cut to size (not applicable for documents originally printed on paper).&#x20;

• **Portrait Replace Attacks:** Recognizes documents with altered facial images, such as overlays or replacements.

## Key Features

1. **Universal Detection Capability**

&#x20;      • Detects document liveness across a wide range of identity documents, globally.&#x20;

&#x20;      • Requires no prior training on document templates, making it universally applicable.&#x20;

2. **Passive, Single-Image Approach**

&#x20;      • Utilizes advanced neural network technology to analyze a single document image.&#x20;

&#x20;      • No complex instructions or changes to existing user interfaces are required, ensuring easy adoption and user convenience.&#x20;

3. **Ease of Integration**

&#x20;      • Flexible Deployment: Deployable on-premises or in your cloud environment using Docker or SDK.

&#x20;      • Seamless API Integration: Works with a single API call and uses the document image already collected during onboarding, ensuring smooth integration into your digital onboarding tech stack.&#x20;

4. **Accuracy and Reliability**

&#x20;      • Near-complete detection accuracy ensures fraud is minimized without compromising the user experience.&#x20;

&#x20;      • Developed by expert data scientists using state-of-the-art neural network models.


# Integration Guide


# Linux

ID Document Liveness Detection SDK for Linux

This guide introduces RECOGNITO Linux-ID Document Liveness Detection SDK for identity verification.

&#x20;After completing this guide, you will have downloaded SDK, run the Demo, tested each SDK APIs, and successfully integrated SDK into Your Application!

## Feature & Options

<table><thead><tr><th width="319">Features &#x26; Options</th><th align="center">Linux-ID Document Liveness Detection SDK</th></tr></thead><tbody><tr><td><strong>Programming Language</strong></td><td align="center">C++/Python</td></tr><tr><td><strong>Screen Replay Integrity</strong></td><td align="center">Yes</td></tr><tr><td><strong>Portrait Replace Integrity</strong></td><td align="center">Yes</td></tr><tr><td><strong>Printed Cutout Integrity</strong></td><td align="center">Yes</td></tr></tbody></table>

## Recommended System Requirements

* **Operating System:** Ubuntu 22.04
* **CPU:** 8 cores
* **RAM:** 16 GB
* **HDD:** 8 GB


# Installation

## Download SDK

Download [**id\_live\_engine.zip**](https://www.dropbox.com/scl/fi/l664t7z20abeba4e4g47b/id_live_engine.zip?rlkey=x3km2e8niswpc29e12fedv3qp\&st=1jnoozyr\&dl=0)

Unpack the `id_live_engine.zip` archive into the desired directory.

## Directory Structure

The SDK directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="152"></th><th width="227"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td>*.so</td><td>so files for Inference Engine</td></tr><tr><td><strong>engine\</strong></td><td><strong>model\</strong></td><td>Model weights</td></tr><tr><td></td><td><strong>lib\</strong>libidlivesdk.so</td><td>SDK so file</td></tr><tr><td></td><td>header.py</td><td>Header file</td></tr></tbody></table>

## Install dependencies

* Install packages and requirements:

{% code overflow="wrap" %}

```sh
sudo apt-get update -y && sudo apt-get install -y binutils python3 python3-pip python3-opencv

python3 -m pip install --upgrade pip && python3 -m pip install -r requirements.txt
```

{% endcode %}

* Copy dependency libraries:

{% code overflow="wrap" %}

```sh
sudo cp -rf ./dependency/* /usr/lib
```

{% endcode %}


# API Reference

### get\_deviceid <a href="#get_device_id" id="get_device_id"></a>

```python
def get_deviceid() -> str:
```

<table data-header-hidden><thead><tr><th width="136"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>get_device_id</td></tr><tr><td><strong>Description</strong></td><td>Retrieves the Hardware ID.</td></tr><tr><td><strong>Input</strong></td><td>None</td></tr><tr><td><strong>Output</strong></td><td>The Hardware ID is returned as a standard Python string.</td></tr></tbody></table>

### set\_activation

{% code overflow="wrap" %}

```python
def set_activation(license_key: str) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>set_activation</td></tr><tr><td><strong>Description</strong></td><td>Activates the SDK using the provided license key.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>license_key</strong> (str): License key string, this should be encoded as UTF-8.</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of the activation.</p><ul><li>0: Success</li><li>Non-zero: Initialization failed</li></ul></td></tr></tbody></table>

### init\_sdk

{% code overflow="wrap" %}

```python
def init_sdk(model_path: str) -> int:
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>init_sdk</td></tr><tr><td><strong>Description</strong></td><td>Initializes the SDK with the required dictionary files.</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>model_path</strong> (str): Path to the engine binary files directory, This path must be provided as a UTF-8 encoded string.</li></ul></td></tr><tr><td><strong>Output</strong></td><td><p>Status code indicating the result of the initialization.</p><ul><li>0: Success</li><li>Non-zero: Initialization failed</li></ul></td></tr></tbody></table>

### processImage

{% code overflow="wrap" %}

```python
def processImage(image: ndarray, width: int, height: int) -> str
```

{% endcode %}

<table data-header-hidden><thead><tr><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>processImage</td></tr><tr><td><strong>Description</strong></td><td>Processes the ID document liveness check</td></tr><tr><td><strong>Input</strong></td><td><ul><li><strong>image</strong> (ndarray): Numpy array for input image file.</li><li><strong>width</strong> (int): Width of image.</li><li><strong>height</strong> (int): Height of image.</li></ul></td></tr><tr><td><strong>Output</strong></td><td>A JSON-formatted result string</td></tr></tbody></table>

#### Example of Liveness Check Results

```json
{
    "screenReply":0.000424702302553,
    "printedCopy":0.000000003402590,
    "portraitReplace":0.037854608148336,
    "status":"Ok"
}
```

**Liveness Score Values (Default Threshold is 0.5)**

≥ 0.5: Genuine, < 0.5: Spoof


# Licensing

{% hint style="info" %}
Click [Here ](/license-option)to get details about RECOGNITO license option

[License Option](/license-option)
{% endhint %}

## Get your HWID (Hardware ID)

To activate SDK, you have to first get your Hardware ID by using the [get\_device\_id ](/id-document-liveness-detection-sdk/integration-guide/linux/api-reference#get_device_id)function.

<figure><img src="/files/7243MJsIwQvPANP9N7Wl" alt=""><figcaption></figcaption></figure>

## Request License

After getting HWID, share it with us for license key.

[**Contact us**](/contact-and-support)

## Activate SDK

[Activate ](/id-document-liveness-detection-sdk/integration-guide/linux/api-reference#set_activation)the SDK with license key. Should be called before using of any other functions.

```python
set_activation(license_key.encode('utf-8'))
```


# Sample Application

Linux-ID Document Liveness Detection SDK Flask, Gradio Demo

## Docker

Pull the Docker image and run the container:

{% code overflow="wrap" %}

```sh
sudo docker pull recognito/id-live:latest
sudo docker run -it -e LICENSE_KEY="xxxxxxxxxxxxx" -p 9001:9000 -p 7861:7860 recognito/id-live:latest [OPTION --gradio(-g), --flask(-f)]
```

{% endcode %}

or

{% code overflow="wrap" %}

```sh
sudo docker pull recognito/id-live:latest
sudo docker run -it -v ./license.txt:/app/license.txt -p 9001:9000 -p 7861:7860 recognito/id-live:latest [OPTION --gradio(-g), --flask(-f)]
```

{% endcode %}

## Installation

### - Download

Download [**ID\_Live.zip**](https://www.dropbox.com/scl/fi/4hdy8fszmmh7kbu3ludqx/ID_Live.zip?rlkey=dza69bk6g1ptqestca9d2bdtt\&st=qr2feb0k\&dl=0)

The Demo directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="206"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td>Dependency files</td></tr><tr><td><strong>engine\</strong></td><td>SDK engine files</td></tr><tr><td><strong>examples\</strong></td><td>Sample images</td></tr><tr><td><strong>flask\</strong></td><td>Flask server side demo code</td></tr><tr><td><strong>gradio\</strong></td><td>Gradio demo code</td></tr><tr><td>Dockerfile</td><td>Dockerfile for building a Docker image</td></tr><tr><td>install.sh</td><td>Script for install environment</td></tr><tr><td>readme.txt</td><td>Installation Guide</td></tr><tr><td>requirements.txt</td><td>Python requirements file</td></tr><tr><td>run.sh</td><td>Script for run demo</td></tr></tbody></table>

### - Install dependencies

Run the `install.sh` script to install dependencies:

```sh
./install.sh
```

### - Setting Up SDK License Key

* **Offline Licensing:** Copy the `license.txt` license file to the demo directory.

***

## Test

### - Run Demo

Run the demo script with the desired option:

{% code overflow="wrap" %}

```sh
./run.sh [OPTION --gradio(-g), --flask(-f), --help(-h)]
```

{% endcode %}

<figure><img src="/files/5MgUmsEL9HwOJ5VTyu4T" alt=""><figcaption></figcaption></figure>

### - Test Flask Server APIs

To test the Flask Server API, you can use [Postman](https://www.postman.com/downloads/). Here are the endpoints for testing:

#### &#x20; <mark style="background-color:blue;">POST</mark> /process\_image

&#x20; Check Liveness from image file

&#x20;   **Parameters**

&#x20;        **image:** image file for the ID document

&#x20;   **Response**&#x20;

&#x20;        **result:** Liveness check result

#### &#x20; <mark style="background-color:blue;">POST</mark> /process\_image\_base64

&#x20; Check Liveness from base64 image

&#x20;   **Parameters**

&#x20;        **base64:** base64 image for the ID document image

&#x20;   **Response**&#x20;

&#x20;        **result:** Liveness check result

<figure><img src="/files/QRGefX6XDWmwGDfkEG61" alt=""><figcaption><p>Postman usage guide for Flask Demo</p></figcaption></figure>

### - Test Gradio

Go to <http://127.0.0.1:7860/> on a web browser.

<figure><img src="/files/YqJ1BBHuTXpC8wHQWdsW" alt=""><figcaption><p>Gradio Demo</p></figcaption></figure>


# License Option

We offer flexible licensing options for our on-premise SDKs to accommodate various use cases and deployment scenarios. Whether you're evaluating our SDKs with a free trial or ready to purchase a perpetual license for your product, we have licensing solutions to meet your needs.

## License Type

<table data-card-size="large" data-view="cards"><thead><tr><th align="center"></th><th data-hidden></th><th data-hidden></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><strong>Free Trial License (15 Days)</strong></td><td></td><td></td><td><a href="/files/fz92L3g7ONdqq0yt3kcv">/files/fz92L3g7ONdqq0yt3kcv</a></td><td><a href="/pages/BU1QfoXNNpnoyslLguMu#free-trial-license-15-days">/pages/BU1QfoXNNpnoyslLguMu#free-trial-license-15-days</a></td></tr><tr><td align="center"><strong>Paid Perpetual License</strong></td><td></td><td></td><td><a href="/files/bNpzTtQZVH094m4ZQjgd">/files/bNpzTtQZVH094m4ZQjgd</a></td><td><a href="/pages/BU1QfoXNNpnoyslLguMu#paid-perpetual-license">/pages/BU1QfoXNNpnoyslLguMu#paid-perpetual-license</a></td></tr></tbody></table>

### - Free Trial License (15 Days)

Our free trial license allows you to evaluate our SDKs for a period of 15 days. During this trial period, you'll have access to all the features and functionalities of our SDKs, enabling you to thoroughly assess their capabilities and integration suitability for your project. This trial license is ideal for developers and organizations looking to explore our SDKs before making a purchasing decision.

### - Paid Perpetual License

Once you've evaluated our SDKs and are ready to integrate them into your product, you can purchase a perpetual license. Our perpetual license provides you with ongoing access to the SDKs without any time limitations, allowing you to use them indefinitely in your applications.

## Licensing Model

### - Server SDK License (Windows, Linux)

One license is required per server machine, identified by its Hardware ID (HWID).&#x20;

### - Mobile SDK License (Android, iOS)

One license is required per application, identified by its App ID or Bundle ID.&#x20;

## One-Time Licensing Fee

Our licensing model operates on a one-time fee basis. Once you've purchased a license, you'll have perpetual access to the SDKs without any recurring charges. This straightforward pricing structure ensures transparency and predictability in your licensing costs.

The license fee includes future support and updates.

## Contact Us

For detailed information on licensing options, including pricing, please [Contact us](/contact-and-support).


# How to implement 1:N identification with RECOGNITO SDK

Using RECOGNITO FaceSDK, you can implement 1:N face identification function.

## 1. Face Enrollment

<figure><img src="/files/mGLbkUxlwtuH2RnYhL7P" alt=""><figcaption><p>Face Enrollment Step</p></figcaption></figure>

## 2. Face Identification

<figure><img src="/files/TzDZlO55dOROMNu68csT" alt=""><figcaption><p>Face Identification Step</p></figcaption></figure>

### 1:N Face Template Matching Sample Code

{% code title="Android-FaceRecognition-FaceLivenessDetection/app/src/main/java/com/bio/facerecognition /CameraActivityKt.kt" %}

```kotlin
...
if(faceBoxes.size > 0) {
    val faceBox = faceBoxes[0]
    if (faceBox.liveness > SettingsActivity.getLivenessThreshold(context)) {
        val templates = FaceSDK.templateExtraction(bitmap, faceBox)

        var maxSimiarlity = 0f
        var maximiarlityPerson: Person? = null
        for (person in DBManager.personList) {
            val similarity = FaceSDK.similarityCalculation(templates, person.templates)
            if (similarity > maxSimiarlity) {
                maxSimiarlity = similarity
                maximiarlityPerson = person
            }
        }
        if (maxSimiarlity > SettingsActivity.getMatchThreshold(context)) {
            recognized = true
            val identifiedPerson = maximiarlityPerson
            val identifiedSimilarity = maxSimiarlity

            runOnUiThread {
                val faceImage = Utils.cropFace(bitmap, faceBox)
                val intent = Intent(context, ResultActivity::class.java)
                intent.putExtra("identified_face", faceImage)
                intent.putExtra("enrolled_face", identifiedPerson!!.face)
                intent.putExtra("identified_name", identifiedPerson!!.name)
                intent.putExtra("similarity", identifiedSimilarity)
                intent.putExtra("liveness", faceBox.liveness)
                intent.putExtra("yaw", faceBox.yaw)
                intent.putExtra("roll", faceBox.roll)
                intent.putExtra("pitch", faceBox.pitch)
                startActivity(intent)
            }
        }
    }
}
```

{% endcode %}

## Examples

### - Linux 1:N Face Search Demo

{% embed url="<https://github.com/recognito-vision/Linux-FaceRecognition-FaceLivenessDetection/tree/main/Identification(1%3AN)-Demo>" %}

### - Window-Face SDK Video Surveillance Demo

{% content-ref url="/pages/6stv2ijfJ6cGEbebU0gP" %}
[Sample Application](/face-recognition-sdk/integration-guide/windows/sample-application)
{% endcontent-ref %}

### - Android-Face SDK Demo

{% content-ref url="/pages/Qz2IcmBxv25uBiCKrHJO" %}
[Sample Application](/face-recognition-sdk/integration-guide/android/sample-application)
{% endcontent-ref %}


# Contact & Support

At RECOGNITO, we are committed to providing exceptional support and assistance to our valued clients throughout their SDK integration journey. Whether you're evaluating our SDK for the first time, actively testing its capabilities, or integrating it into your product, our dedicated support team is here to help you every step of the way.

## Continuous SDK Updates

With each update, you'll benefit from enhanced performance, security, and functionality, ensuring that your applications remain at the forefront of innovation.

## Active Support & Testing

We actively support our clients in testing and integrating our SDK into their products. Our team of experts is available to assist you with any questions, challenges, or technical issues you may encounter during the integration process.&#x20;

## Contact Us

For any inquiries, questions, or assistance with integrating our SDK, please don't hesitate to contact us.&#x20;

### **- Talk to an Expert**

* **Email**: <hassan@recognito.vision>
* **Whatsapp**: [+14158003112](https://wa.me/+14158003112)
* **Telegram**: [@recognito\_vision](https://t.me/recognito_vision)


