How neslang-05/alpr-using-goggle-cloud-vision-api-on-raspberry-pi-4-with-a-web-dashboard works
Project Type and Purpose
• This is an IoT-enabled, full‐stack ALPR (Automated License Plate Recognition) system.
• The “edge” (Raspberry Pi + sensors + camera) captures and preprocesses images, sends them to Google Cloud for OCR, then relays results to a Node.js web dashboard.
File Structure
• Hardware/Edge side (Python)
– car.py, ocr_script.py, runner.py, test.py
– files/ (license_plates.csv, license_plates.json, ocr_result.txt)
• Cloud integration
– test.py or ocr_script.py calls Google Cloud Storage & Vision API
• Backend
– server.js, package.json, node_modules
• Frontend (public/)
– index.html, learn.html, main.html
– CSS: index.css, style.css
– JS: script.js
• Utility / orchestrator
– runner.py triggers the pipeline
README for Insights
• Hardware components: Camera, IR sensor, optional servo motor
• GCP services: Cloud Storage (images), Vision API (OCR)
• Dashboard: Node.js server (real-time updates), frontend files
Main Components
A. Hardware Layer (on‐premises / Raspberry Pi)
1. IR Sensor (Vehicle Detection)
2. Camera (Image Capture)
3. (Optional) Servo Motor (Gate Control)
4. Raspberry Pi – runs Python scripts
• runner.py (entry point)
• test.py (core ALPR logic)
• ocr_script.py (image preprocessing & GCP API calls)
• car.py (license‐plate detection helper)
• Local storage: files/license_plates.csv, JSON, text logs
B. Cloud Layer
1. Google Cloud Storage Bucket (stores captured images)
2. Google Cloud Vision API (OCR processing)
C. Backend Layer
1. Node.js Server (server.js)
• Receives processed plate data via HTTP/REST or WebSocket
• Serves API endpoints and static files
D. Frontend Layer
1. Public Folder – Dashboard UI
• index.html, learn.html, main.html
• style.css, index.css
• script.js (fetches data, updates UI in real time)
E. Data Stores & Logs
• Local CSV/JSON/text files on Pi
• (Future) External database
Interactions & Data Flow
1. IR Sensor → Raspberry Pi (GPIO event)
2. Raspberry Pi (runner.py) triggers Camera → captures image
3. test.py (orchestrator) → optional local preprocessing (car.py)
4. test.py/ocr_script.py → Upload image to Cloud Storage
5. Cloud Storage → Vision API (OCR call) → returns raw text
6. ocr_script.py → Text cleaning → Append to CSV/JSON + write ocr_result.txt
7. Python script → HTTP POST (JSON payload: plate, timestamp) → Node.js server
8. Node.js server → Broadcast via WebSocket/emit → Frontend script.js
9. Frontend (index.html) → Update UI with image, plate number, timestamp
10. (Optional) Node.js → GPIO control API → Pi → Servo Motor
Architectural Patterns & Principles
• Event‐driven pipeline on the edge (GPIO events → script triggers)
• Separation of concerns:
– Edge processing vs. Cloud OCR vs. Web interface
• REST/WebSocket for real‐time communication
• Modular Python code (runner, OCR module, detection helper)
• Static server + dynamic API in Node.js