Commit Graph

6 Commits

Author SHA1 Message Date
shawn a8b1e694b0 feat: persistence, rerun OCR, Google Gemini, sticker mode, manual entry
- SQLite DB (photos.db) — persists all processed photo records
- Dedup by SHA256 hash — same file upload returns duplicate: true
- /api/photos — list previously processed photos
- /api/photos/{id} — get single record
- /api/photos/{id}/file — serve saved image
- /api/photos/{id}/reprocess — re-run OCR with different engine/model
- Google Gemini OCR engine (gemini-2.5-flash, free tier) alongside
  OpenCode Go LLM and Tesseract
- Sticker mode — specialized LLM/Google prompt for green/orange/yellow
  equipment stickers with 2D barcode + machine ID
- Manual machine ID entry — when GPS exists but OCR fails, show text
  input for manual lookup
- Frontend: Previous Photos section, Re-run OCR per photo, duplicate
  badges, engine dropdown, sticker toggle
2026-05-25 17:42:10 -04:00
shawn 70d8374ca6 feat: batch LLM OCR — multiple images in one API call + downscaling
- Add run_ocr_llm_batch() — sends N images in a single vision API call
  with structured JSON prompt, up to 20 images per batch
- Add _resize_for_llm() — downscales images to 1600px max dimension
  before sending to LLM, reducing per-image token cost
- Update bulk_process() to pre-read all files and batch-OCR in one call
- Graceful fallback: if batch JSON parsing fails, retries individually
- Frontend shows llm_batch engine badge

Without batch: N photos = N API calls (each with full prompt overhead)
With batch: N photos = ceil(N/20) API calls + image downscaling savings
2026-05-25 17:26:10 -04:00
shawn 3a67070063 Add LLM OCR engine via OpenCode Go + mimo-v2-omni
Adds optional LLM-based OCR as an alternative to Tesseract for reading
machine IDs from photos.

Backend (server.py):
- New run_ocr_llm() function calls OpenCode Go API (mimo-v2-omni model)
- Auto-falls back to Tesseract if API key missing or call fails
- Endpoints /api/analyze and /api/bulk-process accept ?ocr_engine=llm
  query param (default: tesseract) and ?ocr_model for model override
- Configurable via env vars: OPENCODE_GO_API_KEY, LLM_OCR_MODEL
- Requires User-Agent: Hermes-Agent/1.0 header for OpenCode Go API

Frontend (static/index.html):
- Toggle checkbox 'Use LLM OCR' in the UI
- OCR engine badge shown in results (llm vs tesseract + model name)
- getOcrParams() helper appends ?ocr_engine=llm to API calls

Infrastructure:
- .gitignore for uploads/ directory

Closes: #2
2026-05-25 17:12:37 -04:00
shawn c1516471ac Bulk OCR + GPS push: process multiple GPS photos, match assets, push coordinates to DB with Leaflet map 2026-05-25 00:55:35 -04:00
shawn 6adaf97958 Add asset lookup from canteen DB — auto-match OCR machine IDs to asset records 2026-05-25 00:43:44 -04:00
shawn b079c9bf8f EXIF scanner: multi-photo gallery with GPS detection 2026-05-25 00:32:16 -04:00