---
agent:
  instructions: "Use this search API to find relevant content across this site (products with prices and stock, collections, guides, articles, courses, help and pages) with keywords or natural-language queries, instead of crawling individual pages. Replace {query} with your URL-encoded query. Results are returned in Markdown."
  endpoint: "https://piaustralia.com.au/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Getting started with the Raspberry Pi AI Camera

What makes the AI Camera different from an ordinary camera module, the one package it needs, and how to run the object-detection and pose demos from the command line or Python.

## What it does

With an ordinary camera module, the Pi receives pictures and has to do any image recognition itself, which keeps the processor busy. The AI Camera's Sony IMX500 sensor has its own neural network accelerator built in. It runs a vision model on every frame as it's captured, then hands the Pi the image together with the results: what it found, where in the frame, and how confident it is.

That leaves the Pi's processor free for the rest of your project, and you don't need a separate AI accelerator board.

| Specification | |
|---|---|
| **Sensor** | Sony IMX500, 12.3 MP |
| **Full resolution** | 4056 × 3040 at 10 fps |
| **Binned mode** | 2028 × 1520 at 30 fps |
| **Video** | 1080p at 30 fps |
| **Field of view** | about 78° |
| **Focus** | Manual: turn the lens by hand |

## Which Raspberry Pi?

The AI Camera is designed for the Raspberry Pi 5 and Pi 4. It also works on other models with a camera connector, such as the Zero 2 W and Pi 3 B+, with minor changes.

It plugs in with a ribbon cable like any other Raspberry Pi camera. A Pi 5 or a Zero needs the standard–mini cable; our [camera guide](/docs/camera-software) explains which cable suits which board and how to fit it the right way round.

## Installing the software

Start with an up-to-date Raspberry Pi OS:

```
sudo apt update
sudo apt full-upgrade
```

Then install the AI Camera package and reboot:

```
sudo apt install imx500-all
sudo reboot
```

That one package brings in everything you need:

- the firmware the sensor loads at start-up;
- a collection of ready-made models, in `/usr/share/imx500-models/`;
- the extra processing stages that let the `rpicam` apps draw results on screen;
- Sony's tools for packaging your own models.

## Running a demo

The demo settings live in `/usr/share/rpi-camera-assets/`. To see object detection in a live preview window:

```
rpicam-hello -t 0s --post-process-file /usr/share/rpi-camera-assets/imx500_mobilenet_ssd.json --viewfinder-width 1920 --viewfinder-height 1080 --framerate 30
```

The camera draws a labelled box around each object it recognises. Press Ctrl+C to stop.

**Be patient the first time.** Before the camera can run a model, the Pi has to upload that model to the sensor, and a progress bar shows how it's going. This can take several minutes for a model the Pi hasn't used before; after that it's cached and starts much faster.

For pose estimation, which marks out people's joints and limbs, swap in a different settings file:

```
rpicam-hello -t 0s --post-process-file /usr/share/rpi-camera-assets/imx500_posenet.json --viewfinder-width 1920 --viewfinder-height 1080 --framerate 30
```

To record ten seconds of video with the detections drawn in, use `rpicam-vid` with the same settings file:

```
rpicam-vid -t 10s -o detections.h264 --post-process-file /usr/share/rpi-camera-assets/imx500_mobilenet_ssd.json --width 1920 --height 1080 --framerate 30
```

### Adjusting the detector

Copy the JSON file somewhere of your own and point `--post-process-file` at the copy. Inside it:

| Setting | What it changes |
|---|---|
| `threshold` | The minimum confidence for a detection to be shown |
| `max_detections` | The most objects (or people) it will report at once |
| `temporal_filter` | Smooths results between frames; delete this section to turn it off |

## Using it from Python

Raspberry Pi publishes Picamera2 examples for the AI Camera. Install the libraries they use, then download them:

```
sudo apt install python3-opencv python3-munkres
git clone https://github.com/raspberrypi/picamera2-examples.git
cd picamera2-examples/examples/imx500
```

Run object detection with one of the bundled models:

```
python imx500_object_detection_demo.py --model /usr/share/imx500-models/imx500_network_ssd_mobilenetv2_fpnlite_320x320_pp.rpk
```

and pose estimation with:

```
python imx500_pose_estimation_higherhrnet_demo.py
```

The same folder has classification and segmentation examples to try. To see every model you can pass to `--model`, list the models folder:

```
ls /usr/share/imx500-models/
```

## Running your own model

You can put your own model on the camera, but it has to be prepared first. The broad steps:

1. **Train** a model in PyTorch or TensorFlow. Sony's AITRIOS developer site covers this side.
2. **Compress and convert it on a desktop computer** with Sony's Edge-MDT tools (`pip install edge-mdt[pt]` for PyTorch, or `edge-mdt[tf]` for TensorFlow; keep the two in separate virtual environments). Convert the compressed model with `imxconv-pt` or `imxconv-tf`, which produces a `packerOut.zip`.
3. **Package it on the Pi**, which is the only place this step runs:

```
sudo apt install imx500-tools
imx500-package -i packerOut.zip -o my-model
```

This produces a `network.rpk` file, which you pass to the demos (or your own code) in place of a bundled model.

## Parts in this guide

- [Raspberry Pi AI Camera](https://piaustralia.com.au/products/raspberry-pi-ai-camera.md)
- [Raspberry Pi Camera Cable Standard - Mini](https://piaustralia.com.au/products/raspberry-pi-camera-cable-standard-mini.md)
- [Raspberry Pi 5](https://piaustralia.com.au/products/raspberry-pi-5.md)
- [Raspberry Pi AI HAT+ (26 TOPS)](https://piaustralia.com.au/products/raspberry-pi-ai-hat-26t.md)

Written by Pi Australia from Raspberry Pi's AI Camera documentation, Raspberry Pi AI Camera product page, Raspberry Pi's Picamera2 examples.
