An automated inventory tracking system that uses webcam capture, Claude AI vision analysis, and PostgreSQL to monitor pantry changes in real-time.
The Pantry Monitor automatically tracks inventory changes by capturing daily webcam images of your pantry and using Claude's vision AI to detect what's been added, removed, or changed. All changes are stored in a PostgreSQL database and displayed in a real-time web dashboard.
- Automated Image Capture: Daily webcam snapshots of your pantry
- AI-Powered Analysis: Claude Sonnet 4.5 vision model detects inventory changes
- Smart Change Tracking: Identifies added, removed, and quantity-changed items
- PostgreSQL Database: Persistent storage with full change history
- Real-Time Dashboard: Flask web app with live inventory view
- API Cost Tracking: Monitor Claude API usage and costs
- Change History: Complete timeline of all inventory modifications
- Backend: Python 3.x, Flask
- Database: PostgreSQL
- AI: Anthropic Claude API (Sonnet 4.5)
- Computer Vision: OpenCV (webcam capture)
- Frontend: HTML/CSS/JavaScript (dashboard)
- Python 3.8+
- PostgreSQL 12+
- Webcam
- Anthropic API key
- Clone the repository
git clone https://github.com/yourusername/pantry-monitor.git
cd pantry-monitor- Install dependencies
pip install -r requirements.txt- Configure PostgreSQL
# Install PostgreSQL if not already installed
# On macOS:
brew install postgresql
# On Ubuntu:
sudo apt-get install postgresql postgresql-contrib
# Start PostgreSQL service
# On macOS:
brew services start postgresql
# On Ubuntu:
sudo service postgresql start- Set up configuration
Edit pantry_config.py with your settings:
# Your Anthropic API Key
ANTHROPIC_API_KEY = "your-api-key-here"
# Webcam settings
WEBCAM_INDEX = 0 # Change if you have multiple cameras
# Database configuration
DATABASE_CONFIG = {
'host': 'localhost',
'port': 5432,
'database': 'pantry_monitor',
'user': 'postgres',
'password': 'your-password-here'
}- Initialize the database
python setup_database.pyCapture a new image and analyze changes:
python pantry_scanner.pyThe scanner will:
- Capture a webcam image
- Send it to Claude for analysis
- Detect added/removed items
- Update the PostgreSQL database
- Display changes in the terminal
Check current inventory from the command line:
python view_inventory.pyLaunch the web interface:
python app.pyThen open your browser to http://localhost:5000
The dashboard displays:
- Live Pantry View: Most recent webcam capture
- Current Inventory: All active items with quantities
- Recent Changes: Timeline of additions/removals
- API Cost Tracker: Claude API usage statistics
pantry_scans
- Stores each scan record with image path and API metadata
pantry_items
- Tracks current inventory with quantities and timestamps
inventory_changes
- Complete history of all detected changes
The system uses Claude Sonnet 4.5:
- Input: $3 per million tokens
- Output: $15 per million tokens
Typical scan costs: $0.005 - $0.02 per image analysis
WEBCAM_INDEX = 0 # Adjust for multiple cameras# Current model (recommended)
CLAUDE_MODEL = "claude-sonnet-4-5-20250929"
# Faster/cheaper alternative
CLAUDE_MODEL = "claude-haiku-4-5-20251001"
# Most powerful (higher cost)
CLAUDE_MODEL = "claude-opus-4-5-20251101"Set up automated scans with cron (Linux/Mac):
# Daily scan at 6 AM
0 6 * * * /usr/bin/python3 /path/to/pantry_scanner.pyOr Task Scheduler (Windows)
# Try different camera indices
WEBCAM_INDEX = 1 # or 2, 3, etc.- Verify PostgreSQL is running
- Check credentials in
pantry_config.py - Ensure database exists:
python setup_database.py
python reset_database.pypantry-monitor/
├── pantry_scanner.py # Main scanning script
├── app.py # Flask web dashboard
├── database.py # Database operations
├── pantry_config.py # Configuration
├── setup_database.py # Database initialization
├── reset_database.py # Database reset utility
├── view_inventory.py # CLI inventory viewer
├── templates/ # HTML templates
├── static/ # CSS/JS assets
└── pantry_images/ # Stored webcam captures
- Expiration date tracking
- Shopping list generation
- Mobile app integration
- Multi-pantry support
- Recipe suggestions based on inventory
- Barcode scanning integration
MIT License - See LICENSE file for details
- Built with Anthropic Claude
- Database: PostgreSQL
- Web framework: Flask
Contributions welcome! Please open an issue or submit a pull request.
Note: This project requires an active Anthropic API key. API usage will incur costs based on Claude's current pricing.
