# License Plate Recognition-Server

`KBY-AI`'s `LPR` on-premise server `SDK` utilizes artificial intelligence and machine learning to greatly surpass legacy solutions. Now, in real-time, users can receive a `vehicle's license plate number`.

`Automatic license-plate recognition (ALPR)` is a technology that uses `OCR(optical character recognition)` on images to read `vehicle registration plates`. It can use existing closed-circuit television, road-rule enforcement cameras, or cameras specifically designed for the task. `ALPR` can be used by police forces around the world for law enforcement purposes, including to check if a vehicle is registered or licensed. It is also used for electronic toll collection on `pay-per-use` roads and as a method of cataloguing the movements of traffic, for example by highways agencies.

## Features

* [x] Vehicle License Plate Reader
* [x] OCR Based License Number Parser
* [x] Vehicle Detection & Tracking
* [x] Export License Plate Coordinate
* [x] Support Car, Truck, Bus, etc
* [x] Support Various License Plates From 180+ Counrtries
* [x] On-Premise, Offline Work on Self-hosted Server Instance

## License

We offer `lifetime license(perpetual license)` tied to `machine ID` from 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>" %}

{% embed url="<https://youtu.be/sLBYxgMdXlA>" %}

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

```python
from alprsdk import initSDK, getLicensePlate, getMachineCode, freeLicenseResults, setActivation
```

## Initializing SDK

* Obtain the `machine code` to activate and request a license.

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

* Activate the `SDK` using the license key.

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

* Initializing `SDK`

```python
ret = initSDK()
```

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

## APIs

### 1. Getting License Number & Coordinate

The `SDK` provides a single API for getting license plate number and its coordinate(x, y, width, height).\
The function can be used as follows:

```python
recog_array = (c_int * 1024)()  # Assuming a maximum of 256 rectangles
license_plate_ptr = POINTER(c_char_p)()
cnt = getLicensePlate(img_byte, len(img_byte), byref(license_plate_ptr), recog_array)
```

* `recog_array`: coordinate(`x`, `y`, `width`, `height`).
* `img_byte`: image data in binary format.
* `license_plate_ptr`: pointer to variable with license plate number.

### 2. Analyzing the result from `SDK`

Result values from `SDK` inference can be analyzed as follows.

```python
license_plate = [license_plate_ptr[i].decode('utf-8') for i in range(cnt)]
rectangles = [
(recog_array[i * 4], recog_array[i * 4 + 1], recog_array[i * 4 + 2], recog_array[i * 4 + 3])
for i in range(cnt)]

freeLicenseResults(license_plate_ptr, cnt)

print("number: ", cnt, rectangles, license_plate)
```

* `cnt`: the number of detected license plate.
* `rectangles`: list of `coordinate`.
* `license plate`: list of `license number`.

### 3. Free Memory

```python
freeLicenseResults(license_plate_ptr, cnt)
```
