Get in Touch

Knowing When to Send the Truck: Camera-Based Container Fill Monitoring 

Overview

Companies that place large open-top containers at customer sites face the same question every day: which containers are full and need a pickup, and which can wait? A truck sent too early wastes fuel and driver time. A truck sent too late means an overflowing container and an unhappy customer.
Our client, a regional operator with a fleet of containers across many customer locations, planned pickups from phone calls and fixed schedules. They wanted to point low-cost IP cameras at the containers and let software estimate how full each one is.
Postindustria built the proof of concept: a pipeline from camera stream to a fill-level estimate exposed through an API, plus the machine learning work needed to produce that estimate without any labeled photos.

Key Highlights

01

Working pipeline in about four weeks

Camera capture, message queueing, processing workers, API, and ML inference connected as one system by a team of three.

02

Fill-level estimates from day one

A zero-shot approach combining text-prompted segmentation with a vision-language model produced usable estimates on the client's real camera frames with no training.

03

Labeled training data without annotators

A parametric 3D container scene plus depth-conditioned image generation produced photorealistic training images where the fill level is set, not guessed.

04

Event-driven, horizontally scalable architecture

The Challenge

The problem sounds simple, but several factors made it hard:
  • No labeled data. The client had cameras but no photos paired with known fill levels. Hand-labeling thousands of images would take months before training could start.
  • Unreliable cameras in the field. Outdoor IP cameras go offline and return broken streams. The system had to tolerate this and report it.
  • Several containers per camera. One camera often sees two to four containers. Each one needed its own estimate.
  • An API, not a script. A scheduling tool or mobile app had to be able to call the service.
  • Short timeline. The goal was a demonstration that would let the client decide whether to move to a field pilot.

The Journey

  1. Scoping the Opportunity

    We split the work into three parallel tracks: image ingestion, backend platform, and machine learning. Simple message contracts between them let three engineers work without blocking each other.

    We also set a clear boundary. The system would produce a fill level per container and expose it through the API. Route planning and dispatch rules would stay in the client's scheduling workflow, which would read from that API.

  2. Strategic Development

    Two ML approaches, with a planned handover between them. This was the central product decision.

    The zero-shot approach was built first for immediate results. A text-prompted segmentation model finds every container in the frame, each one is cropped and outlined in red, and the crop goes to a vision-language model with the question: "How full is the container outlined in red? Answer with a single integer from 0 to 100." It needs no training data and gave the client a demo on real frames within days. Its drawbacks are a paid API call per container per capture and dependence on an external service.

    The trained classifier was built in parallel as the long-term path. It runs locally and can be improved with real data. It predicts three categories instead of a percentage: low (0 to 40 percent), medium (40 to 80 percent), and high (above 80 percent). A dispatcher does not act differently on 63 percent versus 71 percent; the decision is "not yet", "soon", or "now". Three categories map to that decision and are a much easier target for a model trained on synthetic images.

    The planned transition: run the zero-shot path first, use its estimates to pre-label the real photos the cameras collect, have a human correct those labels, then fine-tune the classifier on real data and switch over.

  3. Synthetic data

    To train the classifier before real data existed, we built a 3D scene where the fill level is a single input parameter, rendered depth maps from random viewpoints, and used a depth-conditioned diffusion model to turn each depth map into a photorealistic image. The geometry comes from the depth map, so the label stays exact.

    Fill-level monitoring: synthetic training data pipeline
  4. Event-driven backend

    The backend is a FastAPI service plus a set of workers talking over queue. The NiFi processor publishes messages, so the Java side and the Python side share one message bus with no glue code. Each stage of processing is its own queue and worker:

    • Photo intake: looks up which containers are assigned to the camera and forwards the job.
    • Fill-level inference: runs the model on the image.
    • Result persistence: writes one result row per container, with photo URL and fill level, inside a database transaction.
    • Camera health: updates the camera's status and timestamp.

    Because each step is a separate queue, the slow ML stage can run on GPU machines while the rest stays on cheap instances, and the model can be swapped without touching ingestion or the API.

    Fill-level monitoring: event-driven backend
  5. Iterative Execution

    What we tried, what failed, and what we changed:

    • Fixed-vocabulary segmentation did not fit. A general semantic segmentation model has no "industrial container" class, and point-prompted Segment Anything needs a human to click each container. Text-prompted segmentation (Grounding DINO + Segment Anything) found containers from a plain-English prompt with no clicks, so we kept it.
    • Text-to-image generation could not produce labels. Our first synthetic images came from plain text-to-image and inpainting prompts. The pictures looked fine, but nobody could say how full the container in them was. That is why we moved to a 3D scene and depth-conditioned generation: the fill level is set before the image exists.
    • The red outline fixed ambiguity. With several containers in one frame, the vision-language model answered about the wrong one or averaged them. Drawing a red outline around the target container and asking specifically about it made answers consistent across containers in the same frame.
    • The classifier learned the synthetic background. Early runs overfit to the uniform generated background. Compositing each container onto a random real-world scene, plus blur, lighting, and geometric augmentation, forced the model to look at the container itself.

The Technology

  • Image ingestion: Apache NiFi custom processor (Java), FFmpeg for single-frame capture from RTSP streams.
  • Backend: Python, FastAPI, Celery with RabbitMQ, SQLAlchemy and Alembic, PostgreSQL, nginx, containerized services. REST API with Google sign-in and JWT.
  • Zero-shot inference: LangSAM (Grounding DINO + Segment Anything), OpenCV, GPT-4 Vision.
  • Synthetic data: Blender with Geometry Nodes, randomized camera placement, depth-map rendering; Stable Diffusion XL with a depth ControlNet via Hugging Face Diffusers.
  • Training: PyTorch, EfficientNet-B5, Albumentations, Places365 backgrounds, MLflow.

The Results

The engagement ended at the proof-of-concept stage. What it established:
  • The existing camera placement is usable. Frames from the client's own fixed cameras were enough for the segmentation model to find each container and for the vision-language model to answer.
  • Fill levels can be produced with no labeled data. The zero-shot path ran on real frames end to end: capture, detection, estimate, database record, API response.
  • Training data is no longer the blocker. The synthetic pipeline generates labeled images on demand with varied viewpoints, contents, and backgrounds. The classifier and training loop are ready for fine-tuning on real photos.
  • Camera failures are visible in the same system. Every capture produces a status event, so operators see which cameras are down next to the fill levels.
What remained before operational use: collecting real photos through the deployed pipeline, validating the zero-shot estimates against human judgment, fine-tuning the classifier on those photos, and connecting the API to the client's scheduling workflow in a field pilot.

Conclusion

The project shows how to make progress on a computer vision problem when the usual starting point, a labeled dataset, does not exist. A zero-shot model gave the client something to evaluate the same month. A synthetic data pipeline and a local classifier gave them a path to a model they own, with a clear plan for moving from one to the other as real data arrives.

Key Takeaways:

  • Start zero-shot, plan the handover: Foundation models give a usable baseline before any data exists, and that baseline becomes the labeling assistant for the model that replaces it.
  • Set the label, do not guess it: A parametric 3D scene plus depth-conditioned generation produces training images where the fill level is an input, not an annotator's estimate.
  • Match model output to the decision: Three fill categories are what a dispatcher acts on, and a far easier target than an exact percentage.
  • Queues between stages: Separate workers for capture, inference, and persistence let the slow stage scale alone and let the model change without touching the rest.