This project demonstrates how the Raspberry Pi AI camera with a object detection model can be used to monitor a queue. Queue monitoring in the project means extracting the amount of people in it. The queue is defined as an area enclosed by polygons, usually a rectangle.
In its simplest form this is just a number of the amount of people but accumulated over time it could provide statistics like:
- Time-based analytics: Identify peak days/hours and waiting time trends
- Queue dynamics: Monitor growth patterns and bottleneck formation
- Multi-object adaptability: Switch detection between people counting and vehicle monitoring for traffic analysis
- Object Detection: The pre-trained object detection model (NanoDet) detects objects in the camera's field of view by providing a bounding box, classification id plus probability score. It focuses on identifying objects with a confidence level above a defined threshold and of class representing people.
- Real-Time Annotation: Detected objects are annotated with bounding boxes, allowing users to visualize the location and size of each detected object in the video feed. The application can also label these objects based on their class IDs.
- Queue Area Definition: Users can define specific areas (queues) within the video frame using a
JSONfile. The application highlights these areas and tracks the number of objects present within them. - Tracking: The
BYTETrackeris used to maintain the identity of detected objects over time, ensuring that the same object is consistently tracked as it moves through the camera's view. - Dynamic Updates: As the camera captures new frames, the application continuously updates the annotations and tracking information, providing a live view of the queue status.
- Traffic Management: Monitor and manage vehicle queues at intersections or toll booths.
- Event Management: Track attendees in queues at events or venues.
- Retail Applications: Analyze customer flow and queue lengths in retail environments.
Overall, the Queue Monitor application enhances the ability to monitor and manage queues effectively, providing real-time data that can inform decision-making and improve operational efficiency.
Try it out!Clone the project repository
Open a terminal on your Raspberry Pi and run:
$ git clone git@github.com:SonySemiconductorSolutions/aitrios-rpi-sample-apps.git
$ cd aitrios-rpi-sample-apps/examples/queue_monitorTo run the application with the provided JSON file:
$ uv run app.pyThe example.json file contains a pre-defined rectangle.
The application requires a configuration JSON file that specifies the coordinates of the area that defines the queue, or queues if more than one is defined. A configuration tool has been integrated into this application to simplify the process of specifying a custom area. To activate this tool, simply click the middle mouse button in the CV window. This will overlay squares/buttons with text on the screen that allow the user to select actions.
To begin, it is recommended to define either polygons or simple rectangles over the designated areas. Once this is done, click "Save" and close the configuration menu by clicking "Close." The newly defined shapes will be active immediately.
More information about the configuration tool can be found here: Configuration Tool Documentation.
A few words about the AI modelThe model used in this project is the NanoDet Plus 416x416. The physical model, the binary, will be automatically downloaded by the applications sdk.
The github repository raspberrypi/imx500-models contains different types of object detection models. The model can be exchanged to a different one if the default one doesn't provide good enough performance for your particular usecase.
Warning: Changing to a new model can make the application start take longer time the first start.
When in TroubleIf 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