In this project, I'll show you how to transform a Raspberry Pi paired with an AI Camera into an automatic parking monitoring system by installing and modifying a sample application and object detection model.
Here's how it works: You define specific parking zones within the camera's field of view, and the system uses an object detection model to identify vehicles in real-time. When a vehicle enters one of your predefined parking zones, the system automatically marks that space as occupied.
The steps are:
- Installation: Get your hardware and software set up.
- Define parking spaces: Define your parking spaces visually.
- Run the application: Bring it all together for live monitoring.
The script streams frames from the camera, performs object detection (car, bus, truck), tracks these detections through time, and overlays colored annotations on the video.
Each parking space is represented by a polygon loaded from a JSON file.
For every frame:
- If a vehicle intersects a polygon β mark the space red (occupied)
- Otherwise β mark it green (free)
Open a terminal window.
Run the following command to clone the application repository:
git clone git@github.com:SonySemiconductorSolutions/aitrios-rpi-sample-apps.gitCreate a virtual environmentNavigate to the parking monitor directory:
cd aitrios-rpi-sample-apps/examples/parking-monitor/Create a virtual environment using uv:
uv venv --system-site-packagesDefine parking spacesThe application requires a JSON file that specifies the coordinates of parking spaces as 4-point polygons. The application repository includes a sample file named parking_example.json.
You can modify the polygon coordinates directly in parking_example.json.
The App Points Selector is a GUI tool that lets you draw polygons directly on a captured image.
Install required packagesRun the following command to install the necessary packages:
sudo apt-get install python3-pil python3-pil.imagetkLaunch the selector toolRun the following command to start the App Points Selector:
uv run app_pts_selector.py --filename parking_example.jsonUse the selector tool- Select Take Image to capture a frame from your camera.
Click four points on the image to define each parking space polygon in this order:
1. Top left
2. Top right
3. Bottom right
4. Bottom left
- Repeat step 2 for each parking space you want to monitor.
- Select Save to update the JSON file.
NOTE: The tool automatically normalizes the coordinates for use in the application.
Run the applicationRun the following command to start the parking monitor sample app:
uv run app.py --json-file parking_example.jsonThis installs the dependencies automatically and starts the real-time parking monitor.
About this applicationAI modelThis project uses a NanoDet object detection model optimized to run on the IMX500 chip in the AI Camera.
You can download a pre-trained and converted, ready to use, model from the Raspberry Pi Model Zoo.
Key features- Real-time analysis: detects and monitors parking space occupancy in real-time.
- Visual feedback: Live video feed with bounding-box overlays showing detected vehicles.
- Smart detection: Automatically distinguishes free and occupied parking spaces.
- Edge AI processing: Detection is done on the AI Camera for fast and power efficient operation.
Keep these points in mind as you build your system:
- This application only supports 4-point polygons to define parking spaces.
- If you move or adjust your camera, you'll need to redefine your parking zones using the selector tool.
- The first time you upload a new model to the AI Camera, expect a wait of several minutes.
Some suggestions for your next steps:
- Export the results over MQTT.
- Use a map provider to display free spots on a map.
- Integrate the results with a navigation service to help drivers find a free slot.
If you have questions related to Raspberry Pi, please check and utilize the forum below:
Want to learn moreExperiment further with the Raspberry Pi AI Camera by following the Get Started guide on the AITRIOS developer site.
Code






Comments