# Checking Liveness and Face Biometry

{% hint style="info" %}

## **If you use our SDK just for capturing videos, omit this step.**

{% endhint %}

## OzCapsula (SDK v8.22 and newer)

At the [Capturing Videos](https://doc.ozforensics.com/oz-knowledge/guides/developer-guide/sdk/oz-mobile-sdk/capturing-videos#ozcapsula-sdk-v8.22-and-newer) step you've created a data container with all the required information in it , so now just send it to analysis using the `addContainer(container)` and `run` methods.

{% code title="Kotlin" %}

```kotlin
private fun runAnalysis(container: DataContainer?) {
    if (container == null) return
    AnalysisRequest.Builder()
        .addContainer(container)
        .build()
        .run(
            { result ->
                val isSuccess = result.analysisResults.all { it.resolution == Resolution.SUCCESS }
            },
            { /* show error */ },
            { /* update status */ },
        )
}
```

{% endcode %}

## SDK 8.21 and older

To check liveness and face biometry, you need to upload media to our system and then analyze them.

{% hint style="info" %}
To interpret the results of analyses, please refer to [Types of Analyses](https://doc.ozforensics.com/oz-knowledge/guides/developer-guide/api/oz-api/types-of-analyses-and-what-they-check).
{% endhint %}

Here’s an example of performing a check:

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
analysisCancelable = AnalysisRequest.Builder()
 // mediaToAnalyze is an array of OzAbstractMedia that were captured or otherwise created 
    .addAnalysis(Analysis(Analysis.Type.QUALITY, Analysis.Mode.SERVER_BASED, mediaToAnalyze))// or ON_DEVICE if you want the on-device analysis
    .build()
//initiating the analyses and setting up a listener
    .run(object : AnalysisRequest.AnalysisListener {
        override fun onStatusChange(status: AnalysisRequest.AnalysisStatus) { handleStatus(status) // or your status handler
        }
        override fun onSuccess(result: RequestResult) {
            handleResults(result) // or your result handler
        }
        override fun onError(error: OzException) { handleError(error) // or your error handler 
        }
    })
```

{% endtab %}

{% tab title="Java" %}

```java
analysisCancelable = new AnalysisRequest.Builder()
// mediaToAnalyze is an array of OzAbstractMedia that were captured or otherwise created 
        .addAnalysis(new Analysis(Analysis.Type.QUALITY, Analysis.Mode.SERVER_BASED, mediaToAnalyze)) // or ON_DEVICE if you want the on-device analysis
        .build()
//initiating the analyses and setting up a listener
        .run(new AnalysisRequest.AnalysisListener() { 
            @Override
            public void onSuccess(@NonNull RequestResult list) { handleResults(list); } // or your result handler
            @Override
            public void onError(@NonNull OzException e) { handleError(e); } // or your error handler
            @Override
            public void onStatusChange(@NonNull AnalysisRequest.AnalysisStatus analysisStatus) { handleStatus(analysisStatus); } // or your status handler
        })
```

{% endtab %}
{% endtabs %}

To delete media files after the checks are finished, use the `clearActionVideos` method.

### Adding Metadata

To add metadata to a folder, use the `addFolderMeta` method.

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
    .addFolderMeta(
        mapOf(
            "key1" to "value1",
            "key2" to "value2"
        )
    )
```

{% endtab %}

{% tab title="Java" %}

<pre class="language-java"><code class="lang-java"><strong>.addFolderMeta(Collections.singletonMap("key", "value")) 
</strong></code></pre>

{% endtab %}
{% endtabs %}

### Extracting the Best Shot

In the `params` field of the `Analysis` structure, you can pass any additional parameters (key + value), for instance, to extract the best shot on the server side.

```kotlin
mapOf("extract_best_shot" to true)
```

### Using Media from Another SDK

To use a media file that is captured with another SDK (not Oz Android SDK), specify the path to it in [OzAbstractMedia](https://doc.ozforensics.com/oz-knowledge/guides/developer-guide/sdk/oz-mobile-sdk/android-sdk-methods-and-properties#h.s2ye0si7dzc2):

```java
       val file = File(context.filesDir, "media.mp4") // use context.getExternalFilesDir(null) instead of context.filesDir for external app storage
       val media = OzAbsractMedia.OzVideo(OzMediaTag.VideoSelfieSmile, file.absolutePath)
```

### Adding Media to a Certain Folder

If you want to add your media to the existing folder, use the `setFolderId` method:

```kotlin
    .setFolderId(folderId)
```
