# Palmprint Recognition SDK - Server

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

## Features

* [x] Hand Landmark Extraction
* [x] Hand Detection
* [x] Palmprint ROI extraction(alignment)
* [x] Palmprint Feature Extraction
* [x] Palmprint Feature Comparison, Matching
* [x] Gradio Demo For Checking API

## License

We offer `lifetime license(perpetual license)` based on `machine ID` for every 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;

{% embed url="<https://wa.me/+19092802609>" %}

{% embed url="<https://t.me/kbyaisupport>" %}

{% embed url="<https://discord.gg/6wm383re2s>" %}

{% embed url="<https://teams.live.com/l/invite/FAAYGB1-IlXkuQM3AQ>" %}

## System Requirements

### 1. 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:** Windows 7 or later
* **Architecture:** x64

### 2. 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:** Ubuntu 20.04 or later
* **Architecture:** x64

## Import SDK

1. Python

```python
# Python code example
import handtool
```

2. C++

```cpp
#include <palm_feature/facade.h>
#include <palm_feature/status.h>
#include <crop/hand.h>

using namespace HandLib;
using palm_feature::PalmFeatureFacade;
using palm_feature::Status;
```

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

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

## Initializing SDK

* First, create new object for using `SDK`.

```python
# Python code example
config = handtool.EncoderConfig()
encoder = handtool.create_encoder(config)  
```

* Obtain `macihne code` to activate and request license.

```python
# Python code example
machineCode = encoder.getMachineCode()
print("\nmachineCode: ", machineCode.decode('utf-8'))
```

* Activate `SDK` using licnese key

```python
# Python code example
ret = encoder.setActivation(license.encode('utf-8'))
print("\nactivation: ", ret)
```

* Once `ret` value is zero, `SDK` can get work started.

## APIs

### 1. getMachineCode

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

```python
# Python code example
achineCode = encoder.getMachineCode()
print("\nmachineCode: ", machineCode.decode('utf-8'))
```

### 2. setActivation

Next, activate the `SDK` using the received license.

```python
# Python code example
ret = encoder.setActivation(license.encode('utf-8'))
print("\nactivation: ", ret)
```

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

### 3. Hand Detection

The `SDK` provides a single API for detecting hands, determining `hand landmark`.\
The function can be used as follows.

```python
# Python code example
hand_type, x1, y1, x2, y2, detect_state = encoder.detect_using_bytes(img)
roi = mat_to_bytes(get_roi(img, hand_type, x1, y1, x2, y2))
```

* `hand_type`: it indicates hand type value, `0` value: `left hand`, `1` value: `right hand`.
* `x1`, `y1`, `x2`, `y2`: hand landmark points to get `ROI` image.
* `roi`: hand `ROI(Region Of Interest)` image to get palm feature.

### 4. Feature Extraction

`encode_using_bytes` function returns palmprint feature against `ROI` data.&#x20;

The function can be used as follows:

```python
# Python code example
palmprint = encoder.encode_using_bytes(roi)
```

* `roi`: hand `ROI(Region Of Interest)` image to get palm feature.
* `palmprint`: palmprint feature calculated from hand `ROI` data.

### 5. Palmprint Comparison(Matching API)

The `compare_to` function takes two palmprint `feature`s as a parameter and returns `score` value to determine whether `2` input hands are from the same or different.

Palmprint data can be matched based on similarity score from matching API as follows.

```python
# Python code example
one_palmprint_code = encoder.encode_using_bytes(roi1)
another_palmprint_code = encoder.encode_using_bytes(roi2)
score = one_palmprint_code.compare_to(another_palmprint_code)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kby-ai.com/help/product/palm-recognition-sdk/palmprint-recognition-sdk-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
