← Back to blog

Computer Vision

Building an AI-Powered Smart Cart: What Computer Vision Taught Me About Retail

Smart Cart started as a simple question: what if the checkout counter moved into the cart itself? Instead of unloading a basket onto a belt and waiting for someone to scan every item, the cart would already know what was inside it the moment an item went in.

The project uses a camera mounted on the cart, a lightweight object-detection model, and a running total that updates the instant a product crosses into frame. Under the hood it's Python, OpenCV for the vision pipeline, and Flask serving a simple interface that shows the live bill. No barcode scanning, no waiting in line just walk up, drop items in, and check the total on a screen.

Why object detection instead of barcodes

Barcode scanning is reliable, but it puts all the work on the shopper every item has to be individually presented to a scanner. The goal here was the opposite: let the system do the noticing. That meant training and tuning a detector that could recognize common grocery items from different angles, under cart-level lighting, in a single frame that might contain more than one product at once.

Getting this right meant accepting a few real constraints early on:

What the pipeline actually does

Each frame from the cart's camera is passed through the detection model, which returns bounding boxes and class labels for anything it recognizes. Those detections get matched against a small product catalog with prices, and the running bill updates live. A basic tracking layer prevents the same item from being counted twice as it settles into the cart.

The interesting engineering problem wasn't "can the model see the item" it was "how do we know it's a new item and not the same can rolling into view again."

That tracking logic ended up being just as important as the detection accuracy itself. Without it, every shake of the cart risked inflating the total.

Where it fell short and what that taught me

Smart Cart is a prototype, not a finished retail product, and it's honest about that. Packaged goods with clear, distinct shapes detect well. Loose produce, near-identical packaging, and items stacked directly on top of each other are still the hardest cases the same problems that make self-checkout kiosks frustrating in the real world.

That's the biggest lesson from building it: computer vision projects rarely fail on the "does the model work" question in isolation. They succeed or fail on the edge cases — the half-hidden item, the bad lighting, the shopper who tosses a bag of chips in at an angle. Designing for those cases, not just the clean demo case, is most of the actual work.

Where this could go next

A few directions I'd explore if I kept building this out: weight sensors as a second signal to cross-check vision-based counts, a mobile app so shoppers can review their live cart on their own phone, and a feedback loop where corrected items get folded back into training data over time.

How I actually tested it

I didn't rely on a single clean dataset to judge whether this worked. I ran the cart through three conditions on purpose: a well-lit setup similar to a demo booth, a dimmer "back corner of the store" setup, and a deliberately cluttered cart with items stacked and overlapping. Detection confidence in the first case was consistently strong; in the cluttered case, it dropped noticeably whenever two items shared more than roughly half their visible surface. That gap between the best-case and worst-case results is the number that actually matters for a project like this a demo reel only shows the best case, and it would have been easy to stop testing there.

I also timed the pipeline end to end, from frame capture to updated bill, because a system that's accurate but slow doesn't actually solve the checkout problem it's meant to solve. Keeping the detection step lightweight enough to run close to real time on ordinary hardware, rather than reaching for the largest available model, was a deliberate tradeoff a marginally more accurate model that lags behind the shopper's hand isn't actually more useful.

The stack, and why each piece earned its place

OpenCV handles the lower-level image work frame capture, preprocessing, and drawing the bounding boxes used during debugging. Python was the natural choice for gluing the detection model to the billing logic, since most computer vision tooling is Python-first and the ecosystem for both machine learning and simple web serving overlaps heavily there. Flask, rather than a heavier framework, was enough to expose a live bill to a browser without adding infrastructure the project didn't need. None of these choices are exotic the interesting engineering happened in how the pieces were wired together, not in picking unusual tools.

Frequently asked questions

Does Smart Cart work with any grocery store's existing inventory?

Not out of the box. The detector is trained against a specific product catalog, so a real deployment would need retraining or fine-tuning on a store's actual product range and packaging, plus a maintained catalog of prices to match detections against.

How is this different from Amazon's "Just Walk Out" style systems?

Conceptually similar in spirit using computer vision instead of manual scanning but at a completely different scale. Large "grab and go" systems typically use dozens of ceiling-mounted cameras and shelf-level sensors across a whole store. Smart Cart is a single-camera, cart-level prototype built to explore the same core problem on far more modest hardware.

What was the biggest technical limitation?

Occlusion. When two items overlap heavily in the frame, detection confidence drops in a way that's hard to fully engineer around without adding a second sensing modality, like a weight sensor, to confirm what the camera alone can't resolve.

You can look through the code on GitHub it's a good starting point if you're curious how a real-time detection-to-billing pipeline is wired together end to end.

PythonOpenCVComputer VisionFlaskRetail Tech

Further reading & references:

NM

Written by Niyati Malla

Niyati is a Kathmandu-based developer and designer who builds computer-vision, web, and mobile products end-to-end from model to interface. Smart Cart is one of several hands-on OpenCV and Python projects she's built and documented; she also maintains a facial-recognition attendance system and a React Native app for roadside assistance in Nepal.

Published March 4, 2026. Based on hands-on testing of the project described; code and results are publicly available on GitHub for verification.

(have a project in mind)

Let's build something together.

Get in touch ↗︎