# Utilizing AI Kit

### Prerequisites

Before you begin, ensure the following:

* You have a Raspberry Pi 5 (RPi5) with the OS installed and booted successfully.
* Your RPi5 is connected to your Wi-Fi network.
* VNC is enabled, and you're using a VNC client (like TigerVNC) to access the RPi5 remotely.

> For help with installing the OS or enabling VNC, refer to the [Getting Started](/documentation-hackerbot-industries/getting-started/what-is-hackerbot.md) section of this documentation.

**About the AI Kit Installation**

If you purchased a complete Hackerbot with an AI Kit (AI, AI Pro, or AI Elite Edition), the AI Kit comes pre-installed. If you purchased the AI Kit separately, follow the hardware installation instructions [here](https://www.raspberrypi.com/documentation/accessories/ai-kit.html#ai-kit-installation).

**USB Camera Requirement**

Make sure a USB camera is connected to the RPi5. Most Hackerbot kits come with a global shutter camera suitable for the examples in this tutorial.

***

### Step 1: Connect and Launch Terminal

Connect to your RPi5 using TigerVNC. Once connected, open a terminal window. All following steps assume you're working from this terminal.

***

### Step 2: Update the System and Firmware

It's important to run the latest software to ensure hardware compatibility and receive security updates.

**Update OS Packages**

Run the following to update all software packages to their latest versions:

```sh
sudo apt update && sudo apt full-upgrade
```

**Check Your Bootloader Firmware**

The firmware controls how the RPi5 interfaces with connected hardware.

```sh
sudo rpi-eeprom-update
```

Check the output. If the date listed is **earlier than December 6, 2023**, you will need to update your firmware.

**Update the Bootloader**

Launch the configuration tool:

```sh
sudo raspi-config
```

* Navigate to: `Advanced Options > Bootloader Version`
* Select `Latest`
* Press `Finish` or `Esc` to exit the config tool

Then, apply the firmware update:

```sh
sudo rpi-eeprom-update -a
```

Reboot the system to apply changes:

```sh
sudo reboot
```

After rebooting, reconnect using TigerVNC and open a new terminal.

***

### Step 3: Enable PCIe Gen 3.0

The AI Kit uses the PCIe interface to communicate at high speed with the RPi5. Enabling Gen 3.0 mode allows full bandwidth operation.

Run the following:

```sh
sudo raspi-config
```

* Go to Advanced Options
* Select PCIe Speed
* Choose Yes to enable PCIe Gen 3.0
* Exit and reboot:

```sh
sudo reboot
```

> **Note**: This reboot may take a few minutes. Be patient and reconnect with TigerVNC once it's ready.

***

### Step 4: Install Hailo Software and Dependencies

The Hailo AI accelerator requires software support to work with the RPi5.

Install the complete package:

```sh
sudo apt install hailo-all
```

This may take several minutes. Once complete, reboot again:

```sh
sudo reboot
```

After reboot, open a new terminal and verify that the device is detected:

```sh
hailortcli fw-control identify
```

Expected output (details may vary):

```
Executing on device: 0000:01:00.0
Identifying board
Control Protocol Version: 2
Firmware Version: 4.19.0
Board Name: Hailo-8
Device Architecture: HAILO8L
...
```

If you receive output like the above, your Hailo hardware is successfully recognized.

***

### Step 5: Install Example Applications

Clone the official example repository from Hailo and run the installer script:

```sh
cd ~/Documents/
git clone https://github.com/hailo-ai/hailo-rpi5-examples.git
cd hailo-rpi5-examples
./install.sh
```

This installs scripts and models that demonstrate real-time AI inference using the Hailo chip.

***

### Step 6: Run Example Pipelines

Each time you reboot the RPi5 or change Python environments, you'll need to source the environment setup script:

```sh
cd ~/Documents/hailo-rpi5-examples
source setup_env.sh
```

Now you can run the example applications. Make sure your USB camera is connected and recognized as `/dev/video0`.

#### Object Detection

```sh
python basic_pipelines/detection.py --input /dev/video0
```

This runs a real-time object detector and displays bounding boxes for detected objects.

#### Human Pose Estimation

```sh
python basic_pipelines/pose_estimation.py --input /dev/video0
```

This tracks and overlays human skeletons on detected individuals.

#### Instance Segmentation

```sh
python basic_pipelines/instance_segmentation.py --input /dev/video0
```

This performs segmentation by coloring each detected object with a unique mask.

***

### Next Steps

Interested in training on your own dataset?\
Check out the retraining guide from Hailo:

👉 [Retraining Example Documentation](https://github.com/hailo-ai/hailo-rpi5-examples/blob/main/doc/retraining-example.md)

***

### Reference Links

* [Raspberry Pi AI Kit Documentation](https://www.raspberrypi.com/documentation/accessories/ai-kit.html)
* [Raspberry Pi AI Compute Docs](https://www.raspberrypi.com/documentation/computers/ai.html)
* [Hailo RPi5 Examples GitHub](https://github.com/hailo-ai/hailo-rpi5-examples)


---

# 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://hackerbot-industries.gitbook.io/documentation-hackerbot-industries/tutorials/utilizing-ai-kit.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.
