# 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>
