Picture this: you pull into a busy community parking lot or a shopping mall, and instead of driving circles to hunt for an open space, a digital sign or an app guides you straight to the nearest empty spot. Thatโs the promise of an automated, camera-based parking detection system. In this post, weโll take a no-fuss approach to show how you can use VisionAgent to build just thatโwithout layers of complex logic. VisionAgent is a generative Visual AI application builder that follows an agentic framework to handle complex visual tasks requiring reasoning. It modularizes tool selection to pick the best visual tool for a task and leverages built-in visual design patterns to solve particularly complex visual problems.
Why This Matters
- Saves Time: No more circling around looking for a space. Drivers can see free spots immediately.
- Reduces Congestion: Less wandering traffic means fewer queues and less frustration.
- Easy Setup: A few cameras placed around the lot, plus VisionAgentโs detection tools, can get you started quickly.
The Basic Idea
- Camera Feeds: You install a camera (or cameras) overlooking rows of parking spaces.
- Car Detection: Every few seconds, you capture a frame from the camera and feed it into your application created using vision code generated by VisionAgent.
- Empty Spot Identification: Identify which parking stalls are unoccupied by spotting gaps between detected cars (or by labeling parking stall outlines). VisionAgent helps you write the initial code for this, which you can modify yourself or re-prompt VisionAgent to optimize for you.
- Live Updates: Show a list of empty spots or a real-time feed with bounding boxes drawn in green for empty spaces and red for occupied.
How VisionAgent Helps
- Easy Chat Interface: You can prompt the VisionAgent, and it analyzes your prompt to find an optimal solution by breaking down the problem into several solvable steps. Generally, most steps involve writing vision code to solve your problem. For this application, I gave the initial prompt, โfind empty car spots,โ along with an image, and the VisionAgent planner agentically comes out with the following execution pathway:
- Use
countgd_object_detection
model to detect all cars in the image. - Sort and group detections into horizontal lines.
- Analyze gaps between cars to identify empty spots.
- Combine car detections and empty spots.
- Visualize results with bounding boxes and save the final image.
- Use
- Quick Object Detection: VisionAgent has a built-in library of models that it uses to find a suitable model for you, like
countgd_object_detection
, which can readily identify cars (and even trucks, SUVs, etc.), potentially saving tons of time that goes into model selection and configuration. - Flexible Integration: In just a few lines of Python (often combined with Streamlit), you can build a straightforward web interface for viewing camera feeds and utilizing the code generated by the VisionAgent.
A Lightweight Pipeline
1. Capture an Image From a webcam, IP camera, or a static snapshot. 2. Detect Carsdetections = countgd_object_detection("car", image)
3. Identify Empty Spots
Either by computing gaps between bounding boxes or by detecting each stall (if you have labeled them in advance). Mark those empty stallย ย ย ย ย ย regions as โempty_spotโ with a green bounding box.
4. Visualize & Report
Draw bounding boxes:
Print or display the number of cars vs. empty spots.
overlay_bounding_boxes(image, all_detections)
Example Code Snippet
from vision_agent.tools import countgd_object_detection, overlay_bounding_boxes
def detect_parking(image):
# 1. Detect cars
car_detections = countgd_object_detection("car", image)
# 2. Find empty spots (simplified approach: check horizontal gaps, etc.)
# ... minimal logic to find 'empty_spot' bounding boxes ...
empty_spots = [
{"label": "empty_spot", "bbox": [100, 50, 200, 120], "color": (0, 255, 0)}
]
# 3. Combine results & overlay
all_detections = car_detections + empty_spots
annotated_img = overlay_bounding_boxes(image, all_detections)
return annotated_img, all_detections
You would then display annotated_img
ย in your interface and maybe show the count of detected cars vs. empty spots.
Challenges & Tips
- Camera Angle: Make sure the camera has a clear view of each parking space.
- Lighting: Day vs. night can change how well cars are detected. Infrared cameras or good lighting can help.
- Parking Layout: Some lots have angled slots or half-faded lines, so you might need to tweak your logic for finding empty spots.
- Performance: If you want real-time detection (e.g., multiple frames per second), you might have to train an efficient model using VisionAgentโs custom model feature where you can input your data and train custom models tailored specifically to your task.
Bring It All Together
- Install the VisionAgent Python package.
- Set up a camera or upload test photos.
- Write a short script or a Streamlit app that:
- Grabs a frame from the camera.
- Calls
detect_parking
(or your variant). - Displays the annotated image, plus simple stats like โCars: X, Empty Spots: Y.โ
- Refine as neededโperhaps add a โParking Occupancy: 80% Fullโ to your user interface.