# ID Card Recognition SDK - Server

{% hint style="info" %}
We provide the ID Card Recognition SDK for both Windows and Linux.
{% endhint %}

## Features

* [x] Support ID documents from 200+ countries
* [x] Document Detection
* [x] Recognition of ID Cards, Passports, Driver's Licenses
* [x] MRZ Recognition
* [x] Document Image Extraction
* [x] Portrait Image Extraction
* [x] 130+ languages, by including Greek, Arabic, Latin, Cyrillic, Hebrew, Chinese, and more

## License

We offer `lifetime license(perpetual license)` based on `machine ID` for server(Windows, Linux). The license is available for `one-time payment`. In other words, once you purchase license from me, you can use our SDK permanently.

To request a license, please contact us:

> **Email:** <contact@kby-ai.com>&#x20;
>
> **Telegram:** @kbyaisupport&#x20;
>
> **WhatsApp:** +19092802609

## System Requirements

### 1. Windows

* **CPU:** 2 cores or more (Recommended: 2 cores)
* **RAM:** 4 GB or more (Recommended: 8 GB)
* HDD: 4 GB or more (Recommended: 8 GB)
* **OS:** Windows 7 or later
* **Architecture:** x64

### 2. Linux

* **CPU:** 2 cores or more (Recommended: 2 cores)
* **RAM:** 4 GB or more (Recommended: 8 GB)
* HDD: 4 GB or more (Recommended: 8 GB)
* **OS:** Ubuntu 20.04 or later
* **Architecture:** x64

## Import SDK

1. Python

```python
from idsdk import getMachineCode
from idsdk import setActivation
from idsdk import initSDK
from idsdk import idcardRecognition
```

2. C++

```cpp
#include "idsdk.h"
```

```cmake
# CMake for Windows
target_link_libraries(your_app_name
    /path/to/library/idsdk.lib
)

# CMake for Linux
target_link_libraries(your_app_name
    /path/to/library/libidsdk.so
)
```

## Initializing SDK

1. Step one

* First, obtain the machine code for activation and request a license based on the `machine code`.

```python
# Python code example

machineCode = getMachineCode()
print("machineCode: ", machineCode.decode('utf-8'))
```

```cpp
// C++ code example

printf("machine code: %s\n", getMachineCode());
```

2. Step Two

* Next, activate the SDK using the received license.

```python
# Python code example

setActivation(license.encode('utf-8'))
```

```cpp
// C++ code example

int ret = setActivation("...");
```

* If activation is successful, the return value will be `SDK_SUCCESS`. Otherwise, an error value will be returned.

3. Step Three

* After activation, call the initialization function of the SDK.

```python
# Python code example

initSDK()
```

```cpp
// C++ code example

ret = initSDK();
```

{% hint style="danger" %}
The 'data' model directory should be located in the same path as the library.\
\
For example:\
\|--data\
\|     |--model1.bin\
\|     |--model2.bin\
\|     |--model3.bin\
\|--libidsdk.so\
...
{% endhint %}

* The first parameter is the path to the model.
* If initialization is successful, the return value will be `SDK_SUCCESS`. Otherwise, an error value will be returned.

## APIs

### 1. getMachineCode

First, obtain the machine code for activation and request a license based on the `machine code`.

```python
# Python code example

machineCode = getMachineCode()
print("machineCode: ", machineCode.decode('utf-8'))
```

```cpp
// C++ code example

printf("machine code: %s\n", getMachineCode());
```

### 2. setActivation

Next, activate the SDK using the received license.

```python
# Python code example

setActivation(license.encode('utf-8'))
```

```cpp
// C++ code example

int ret = setActivation("...");
```

If activation is successful, the return value will be `SDK_SUCCESS`. Otherwise, an error value will be returned.

### 3. initSDK

After activation, call the initialization function of the SDK.

```python
# Python code example

initSDK()
```

```cpp
// C++ code example

ret = initSDK();
```

The first parameter is the path to the model.

If initialization is successful, the return value will be `SDK_SUCCESS`. Otherwise, an error value will be returned.

### 4. idcardRecognition

The SDK provides a `single API` for `ID card recognition`.&#x20;

The function can be used as follows:

```python
# Python code example

jsonResult = idcardRecognition(base64_image.encode('utf-8'))
```

```cpp
// C++ code example

char* jsonResult = idcardRecognition(base64_image);
```

The function accepts only one parameter, which should be the `base64-encoded` format of the image (e.g., `JPG`, `PNG`, etc.).

If the recognition is successful, the function will return a `JSON-formatted` string containing the recognized information. In case of failure, the return value will be `NULL`.
