A system that can be used to automatically detect the available parking spaces in a local parking lot.
This system was in use by the municipality I live in, installed in a local parking lot: Municipality Website, System Website
Actually, there are only two components in the system:
- Raspberry Pi 4B
- Camera (connected to the Raspberry)
These two are installed on a building next to the parking lot, so that the camera sees most of it, and an almost unobstructed view of the cars.
The first step of the system is detecting all the cars visible in the image, something which requires a Machine Learning (AI) model. The most important factor for choosing a model was the accuracy, as long as the time was at most ~1min.
After checking the YOLOv5 model (which was very fast but inaccurate) and the Mask-RCNN model (which was very accurate but takes at least a minute for inference), I concluded that the latter was a better option.
The next step is selecting the parking spaces in the image itself and saving it to a pickle file.
After that, the detection script checks each parking space with each car and finds the IoU (Intersection over Union) of each pair. Then, It finds the maximum IoU for each parking space, and if it exceeds a specific thresold it is considered taken.
Code (detection and availability check)
I have added a text (on the top right) on the website that informs the citizens about the last time the data were updated.
I have also made a php script that runs every 10 minutes and sends an email to me and the municipality IT Manager if the system has not sent data in the last 10 minutes, so that I access it remotely and restart it.
The detection script is also being run at startup (with crontab), as well as in a loop (using a watch command), so that when it stops it is run again automatically.
The availability data are then encoded to JSON and sent to an online database via some PHP files.
Website (Link)
The website consists of a map that:
- Either shows each parking lot (and its status, using a red or green rectangle) individually, if the map is sufficiently zoomed in
- Or shows a marker for each parking lot that contains information about the number of available parking spaces (if there is any, which is shown with the color of the marker






