# Sample Application

## 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/2cfmyjmzhncsqjqy5tdv4/ID_SDK.zip?rlkey=o3wn5hin2hud0idx47benc2xv\&st=p5shq37x\&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="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FhvjSriTwSyHLgBmuRmz7%2Fidsdk_flask.png?alt=media&#x26;token=c2657aaf-0635-4088-8f39-b7b3857e4809" 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="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2F2u4lP8vpi5lAUZ9hlk6I%2Fidsdk_flask_result.png?alt=media&#x26;token=1ef77e4f-1a12-4c26-9ec4-cee2da3c6aa7" 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="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2F1vOAHtQlIik5slQr2X6M%2Fidsdk_gradio_result.png?alt=media&#x26;token=eabf637e-2ff3-4303-b1c9-599ebe3909cd" alt=""><figcaption><p>Gradio Demo</p></figcaption></figure>

<div><figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2F0rHms86rkA1pL7FgBD83%2Fidsdk_gradio_result_1.png?alt=media&#x26;token=6d057937-1b25-49c8-be73-8db110686924" alt=""><figcaption></figcaption></figure> <figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FUv13IMaKKkqWE5kJ5Ehr%2Fidsdk_gradio_result_2.png?alt=media&#x26;token=fdfb05cd-5a09-4e7a-bc09-e33139c1be70" alt=""><figcaption></figcaption></figure> <figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2F6X1Wr868vE6tOoZbISJQ%2Fidsdk_gradio_result_3.png?alt=media&#x26;token=e0493d3a-7e44-4fea-a171-5fe4769e4b2f" alt=""><figcaption></figcaption></figure></div>
