# Fire/Smoke Detection-Server

Fires often begin in quiet, low-traffic areas—electrical rooms, loading docks, storage areas—where nobody’s watching. `KBY-AI`'s `fire/smoke detection SDK` turns your existing CCTV into smart fire sentries, instantly detecting smoke or flames before they spiral into a crisis. Perfect for warehouses, industrial sites, and logistics hubs.

## Features

* [x] Fire Detection
* [x] Smoke Detection
* [x] Available on Docker
* [x] Free Trial License
* [x] Free Update & Technical Support
* [x] On-Premise Solution

## 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>" %}

## Recommended Spec.

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

## Setting up SDK & Test

* Pull `Docker`image.

```bash
sudo docker pull kbyai/fire-smoke-detection:latest
```

* Read `machine code`

<pre class="language-bash"><code class="lang-bash"><strong>sudo docker run -e LICENSE="xxxxx" kbyai/fire-smoke-detection:latest
</strong></code></pre>

* Send us `machine code` obtained.

<figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2FHZGiinwLvvrG0bWCIKrR%2Ffire_macinecode_request.png?alt=media&#x26;token=b6b48795-2ef9-4f44-b122-338bcf369ad0" alt=""><figcaption></figcaption></figure>

* Create a `license.txt` file and write the license key that you received from `KBY-AI` team.
* Run `Docker` container

```
sudo docker run -v ./license.txt:/home/openvino/kby-ai-fire/license.txt -p 8081:8080 -p 9001:9000 kbyai/fire-smoke-detection:latest
```

* Here are the endpoints to test the `API` through `Postman`:&#x20;
* To test with an image file, send a `POST` request to `http://{xx.xx.xx.xx}:8081/fire`.\
  To test with a `base64-encoded` image, send a `POST` request to `http://{xx.xx.xx.xx}:8081/fire_base64`.

<figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2Foou15zG3e3oaI168ccbR%2F433255391-8518eb28-23a6-451c-8610-79a5ad560f28.png?alt=media&#x26;token=d589f6ff-2a8f-4f18-be27-2f2eb771fd02" alt=""><figcaption></figcaption></figure>

## APIs

### 1. Getting Machine Code

The `SDK` provides a single API to get `machine code`

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

### 2. Activate `SDK`

Read `license.txt` file and activate `SDK` with `setActivation()` function as follows.

```python
try:
    with open(licensePath, 'r') as file:
        license = file.read().strip()
except IOError as exc:
    print("failed to open license.txt: ", exc.errno)

print("\nlicense: ", license)

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

### 3. Initialize SDK

```python
ret = initSDK()
print("init: ", ret)
```

### 3. Get Detection Result

```python
cnt = getFireDetection(img_byte, len(img_byte), label_array, box_array, score_array)

rectangles = [
(box_array[i * 4], box_array[i * 4 + 1], box_array[i * 4 + 2], box_array[i * 4 + 3])
for i in range(cnt)]
scores = [score_array[i] for i in range(cnt)]
labels = [label_array[i] for i in range(cnt)]
```
