Computer Vision–Based Autonomous Checkout System
The Smart Cart System is an automated product recognition and checkout system designed for Raspberry Pi. It uses computer vision to identify products placed under a camera, automatically adds them to a digital cart, and provides a complete payment interface. The system consists of a Python backend for image processing and a web-based frontend for user interaction.
- Raspberry Pi - Main processing unit (Model 3B+ or higher recommended)
- USB Camera - For product image capture (Logitech C920 or similar recommended)
- Power Supply - 5V/3A for stable operation
- Display - Optional HDMI monitor or touchscreen
- LED strip light - Image recognition support
- Network - Ethernet or Wi-Fi for web interface access
- Backend: Python 3.11 with OpenCV, TensorFlow Lite, WebSockets
- Frontend: HTML5, CSS3, JavaScript with WebSocket API
- Model: TensorFlow Lite INT8 quantized (96x96x3 input)
- Communication: WebSocket protocol on port 8765
- Web Server: Python HTTP server on port 8000
- Raspberry Pi with 2GB RAM
- 16GB microSD card (Class 10 or higher)
- USB Webcam (720p minimum, 1080p recommended)
- Stable 5V/3A power supply
- LED strip light
- Active cooling (recommended for sustained use)
- Height: 30-40cm above product surface
- Angle: 90 degrees (directly overhead)
- Lighting: Even, diffused lighting without shadows
- Background: Consistent, non-reflective surface
- Focus: Fixed focus set to product distance
- Use official Raspberry Pi power supply
- Avoid powering from computer USB ports
- Consider UPS for retail environments
- Update System
sudo apt update
sudo apt upgrade -y- Install System Dependencies
sudo apt install -y python3-pip python3-venv
sudo apt install -y libatlas-base-dev libhdf5-dev libhdf5-serial-dev
sudo apt install -y libopenjp2-7 libilmbase25 libopenexr25- Create Virtual Environment
cd ~/smart_cart
python3 -m venv smartcart_env
source smartcart_env/bin/activate- Install Python Packages
pip install opencv-python numpy websockets
pip install "numpy<2" # Required for TensorFlow Lite compatibility
pip install tflite-runtime # Or use: pip install tensorflow- Verify Installation
python3 -c "import cv2; print('OpenCV:', cv2.__version__)"
python3 -c "import numpy; print('NumPy:', numpy.__version__)"
python3 -c "import websockets; print('WebSockets OK')"- Model: Mobilenetv2
- Format: TensorFlow Lite (.tflite)
- Quantization: INT8 (optimized for Raspberry Pi)
- Input Size: 96x96 pixels
- Channels: 3 (RGB)
- Classes: 4 (bru, cake, dairymilk, lays) (scale depending upon your usecase)
- File Size: ~2-5MB typical
Place your trained model at:
/home/project/smart_cart/model.tflite
- Dataset: Minimum 100 images per class
- Lighting: Consistent with deployment environment
- Angles: Multiple product orientations
- Background: Consistent plain background
- Augmentation: Rotation, scaling, brightness variation
# Essential configuration section
MODEL_PATH = "/home/project/smart_cart/model.tflite"
CLASS_NAMES = ["bru", "cake", "dairymilk", "lays"]
CAM_INDEX = 0 # USB camera index
WEBSOCKET_PORT = 8765
# Camera settings (optional optimization)
CAPTURE_DELAY = 0.3 # Seconds for camera adjustment
BUFFER_CLEAR_COUNT = 5 # Frames to discard for fresh capture- WebSocket Connection
// Line 383 in JavaScript section
ws = new WebSocket('ws://localhost:8765');
// Change to Raspberry Pi IP if accessing from another device:
// ws = new WebSocket('ws://192.168.1.100:8765');- Product Database
// Line 257 in JavaScript section
const productDatabase = [
{ id: "bru", name: "Bru", price: 10.00, image: "bru.jpg" },
{ id: "cake", name: "Cake", price: 10.00, image: "cake.jpg" },
{ id: "dairymilk", name: "Dairy Milk", price: 10.00, image: "dairymilk.jpg" },
{ id: "lays", name: "Lays", price: 10.00, image: "lays.jpg" }
];Terminal 1 - Backend
cd ~/smart_cart
source smartcart_env/bin/activate
python3 backend.pyTerminal 2 - Frontend
cd ~/smart_cart/frontend
python3 -m http.server 8000- URL:
http://localhost:8000 - Device: Same Raspberry Pi
- Find Raspberry Pi IP:
hostname -I- Access from other devices:
http://[raspberry-pi-ip]:8000
- Frontend: Port 8000 (HTTP)
- Backend: Port 8765 (WebSocket)
If ports conflict:
# Change in backend.py
WEBSOCKET_PORT = 8766
# Change in frontend JavaScript
ws = new WebSocket('ws://localhost:8766');- Power on Raspberry Pi
- Connect camera and ensure proper positioning
- Open terminal and start backend
- Open second terminal and start frontend server
- Open browser to access interface
- Place Product: Position product centered under camera
- Click Scan: Press "Scan Product" button
- Wait Processing: System captures and classifies (2-3 seconds)
- Review Result: Check product name and confidence score
- Add to Cart: Click "Add to Cart" or scan next product
- Add Items: Scan products or click from product list
- Adjust Quantity: Use +/- buttons for each item
- Remove Items: Click trash icon
- View Total: Check bottom of cart section
- Proceed to Payment: Click when cart has items
- Select Method: Choose card, wallet, or cash
- Enter Details: Fill payment form
- Confirm: Complete payment
- Print Receipt: Optional print function
- New Trip: Start fresh shopping session
- Retrain with more varied data
- Adjust camera lighting
- Improve product positioning
- Add data augmentation during training
- Increase training epochs
Adjust in frontend if needed:
// Current: 85% default
const confidence = data.confidence || 0.85;
// Change to: 0.90 for stricter matching- Camera Cleanliness: Lens free from dust/smudges
- Lighting Consistency: Check for shadows/changes
- Network Connectivity: Verify WebSocket connection
- System Temperature: Monitor Pi temperature
- Storage Space: Check available disk space
- Update Software: Security patches and updates
- Backup Configuration: Save model and code
- Clean Logs: Remove old log files
- Test All Functions: Full system test
- Check Hardware: Camera mount stability
- Model Retraining: If accuracy decreases
- System Reboot: Clear memory and cache
- Hardware Inspection: Check cables and connections
- Performance Review: Check inference times
- Backup Creation: Full system backup
- No Authentication: Anyone on network can access
- HTTP Only: No encryption for data transfer
- Local Network: Not designed for internet access
- No User Accounts: Single shared cart
- Add HTTPS: Use SSL certificates
- Implement Authentication: User login system
- Network Segmentation: Isolate on separate VLAN
- Regular Updates: Security patch management
- Firewall Rules: Restrict access to necessary ports
- Retrain Model: Include new classes
- Update CLASS_NAMES: Add to backend list
- Update productDatabase: Add to frontend
- Test Thoroughly: Verify all products work
# For multiple checkout lanes
CAM_INDEX = 0 # Lane 1
# Additional backend instances on different portsPotential extensions:
- Inventory Management: Track stock levels
- Sales Analytics: Collect purchase data
- User Profiles: Save shopping preferences
- Receipt Database: Store transaction history
- Inference Time: 1-3 seconds per product
- Accuracy: >95% with good training data
- Memory Usage: 200-300MB for backend
- CPU Usage: 50-70% during operation
- Network Latency: <100ms for WebSocket
# Check system resources
htop
# Monitor temperature
vcgencmd measure_temp
# Check network
iftop
# Monitor processes
top -u $USERSystem Version: 1.0.0 Last Updated: November 2025 Compatibility: Raspberry Pi OS Bookworm/Bullseye Required Skills: Basic Linux, Python, Web Development