VELE_OS v2.6
← back to vele_os
parking-counter.py
EMBEDDED + AI

AI parking-lot monitor

Counts cars in and out of a parking lot with YOLO11n on a Raspberry Pi 4, deployed on site at the Innovation Centre.

PROBLEM
Know whether the parking lot is full without walking out to check.
DID
YOLO11 car detection and the full Python pipeline, on a Raspberry Pi 4 with a webcam. Set up the on-site networking.
RESULT
Deployed on site during vacation work at the Innovation Centre.
  • Python
  • YOLO11
  • OpenCV
  • NCNN
  • Raspberry Pi

The counter watches the lot entrance with a USB webcam on a Raspberry Pi 4. Instead of running detection on the whole frame, it only looks at two small zones marked with printed ArUco codes, which keeps the model’s work small enough for the Pi’s CPU.

A car that passes zone A and then zone B is counted as an entry; B then A is an exit. The tally is kept between zero and the lot’s capacity, and two LEDs show at a glance whether there is space.

A car crossing zone A then zone B under a USB webcam; the Pi drives a sign showing NOT FULL, 37 of 40.
fig. 1 How it counts cars. Two printed ArUco markers mark zones A and B. A car that crosses A then B is an entry (+1); B then A is an exit (−1). Only the two zone boxes are checked, not the whole frame.
Flowchart from printing markers and calibrating zones to the live loop of grabbing frames, cropping zones, YOLO11n inference, debounce, direction and tally.
fig. 2 From two paper markers to a live tally. Setup runs once (calibrate.py finds the markers and saves zones.json); the live loop crops each zone, runs YOLO11n exported to NCNN on the Pi's CPU, debounces over 2 frames and decides direction before updating the tally.
Breadboard wiring of a green LED on GPIO17 and a red LED on GPIO27 to the Raspberry Pi 4 header, each through a resistor, with the USB webcam plugged in.
fig. 3 Wiring it up. Green LED on GPIO17 lights when there is space, red on GPIO27 when the lot is full, each with its own resistor; BCM numbering, driven with gpiozero.
Terminal dashboard showing both zones' state, a crossing in progress, the tally 37/40 NOT FULL and recent entry and exit events.
fig. 4 What the Pi shows while it runs. Which zone a car is in, crossings in progress, the tally against capacity, and recent events; every entry and exit is also saved to tally_log.csv.