TireGuard is a handheld embedded device that uses traditional computer vision (OpenCV) to measure tire tread depth with high precision. Built on Raspberry Pi hardware, it provides real-time tread assessment for cars and motorcycles—without AI training datasets or cloud dependencies—fulfilling thesis requirements for objective, portable tire safety inspection.
⚠️ Important: Per thesis Scope & Delimitation (p.9), this system explicitly excludes machine learning training. It uses deterministic OpenCV algorithms (edge detection, contour analysis) for tread measurement—not neural networks or trained models.
| Requirement | Implementation | Status |
|---|---|---|
| Handheld Raspberry Pi device | Physical Pi 4/5 + camera + touchscreen enclosure | ✅ Compliant |
| Traditional CV (no AI training) | OpenCV edge detection + contour analysis | ✅ Compliant (per Scope p.9) |
| Numeric depth output (mm) | Reports actual tread depth (e.g., "2.8mm") | ✅ Compliant |
| Offline operation | All processing on-device; no internet required | ✅ Compliant |
| Validation protocol | Compare vs. manual gauge per Eq. 3.1 (Ch. 3) | ✅ Required for defense |
| Dual-interface architecture | Primary: touchscreen app • Secondary: local web viewer | ✅ Compliant |
tireguard/
├── app.py # Main entry point (desktop UI + optional web server)
├── requirements.txt # Python dependencies
├── data/ # Persistent storage (auto-created)
│ ├── tireguard.db # SQLite database for results
│ ├── captures/ # Raw captured images
│ ├── processed/ # Preprocessed analysis images
│ ├── roi.json # Saved Region of Interest coordinates
│ └── calibration.json # Scale calibration settings
└── tireguard/ # Core application modules
├── camera.py # Pi camera interface (picamera2/OpenCV)
├── preprocess.py # Image enhancement (CLAHE, noise reduction)
├── quality.py # Brightness/glare/sharpness checks
├── measure.py # Groove detection + depth calculation (mm)
├── storage.py # Database + CSV export operations
├── ui_qt.py # Touchscreen UI (PySide6)
└── api.py # Local web dashboard (FastAPI)
| Component | Specification | Purpose |
|---|---|---|
| Raspberry Pi | Pi 4B (4GB+) | Main processing unit |
| Camera | Microscope like Camera with integrated Flash and capture buttons | |
| Display | 5" Touch Display | Primary user interface |
| Housing | 3D-printed spacer enforcing 15cm distance | Fixes working distance for depth accuracy | | Power | Battery Pack (two li-ion battery)| 4+ hours continuous operation (theoretical but not tested) |
🔑 Critical note: Fixed 15cm working distance + ring lighting are non-negotiable for accuracy. Without these, monocular CV cannot achieve ≤0.5mm error vs. manual gauge.
# 1. Clone repository
git clone https://github.com/qsont/tireguard.git
cd tireguard
# 2. Create virtual environment
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt# 1. Prepare OS (on Raspberry Pi OS Lite/Desktop)
sudo apt update && sudo apt upgrade -y
sudo apt install -y python3 python3-venv python3-pip libgl1 libglib2.0-0 \
libatlas-base-dev libjasper-dev libqtgui4 libqt4-test
# 2. Transfer project files to Pi (via SCP/USB)
# Example: scp -r tireguard/ pi@raspberrypi.local:~/tireguard-app
# 3. Install dependencies on Pi
cd ~/tireguard-app
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# 4. Run primary touchscreen application (with optional web viewer)
python app.py --host 0.0.0.0 --port 8000Two helper scripts are included under scripts/ to speed up Pi deployment:
# 1) Make scripts executable (first time only)
chmod +x scripts/rpi_setup.sh scripts/rpi_run.sh scripts/rpi_run_800x480.sh scripts/rpi_reset_data.sh
# 2) Install system + Python dependencies
./scripts/rpi_setup.sh
# 3) Run TireGuard in compact touchscreen mode (800x480 friendly)
./scripts/rpi_run.sh
# 4) Run dedicated simple UI launcher for 800x480 screens
./scripts/rpi_run_800x480.sh
# 5) Optional: clear records/files for fresh dataset (keeps data/results.db)
./scripts/rpi_reset_data.shManual launch presets:
# New simplified UI for 800x480 touchscreens (separate from wizard UI)
python app.py --simple-ui --no-browser --host 0.0.0.0 --port 8000
# Dedicated Raspberry Pi UI profile (compact + fullscreen)
python app.py --rpi-ui --no-browser --host 0.0.0.0 --port 8000
# Compact mode only (windowed)
python app.py --compact-uiOptional environment overrides:
TIREGUARD_HOST=0.0.0.0 TIREGUARD_PORT=8000 ./scripts/rpi_run.shAdd kiosk-style autostart on Raspberry Pi Desktop login:
# Install autostart entry (~/.config/autostart/tireguard.desktop)
# Uses scripts/rpi_run_800x480.sh (dedicated 800x480 kiosk launcher)
./scripts/rpi_kiosk_autostart.sh install
# Remove autostart entry later (optional)
./scripts/rpi_kiosk_autostart.sh removeCreate a clickable desktop launcher icon (single-click run):
# Create ~/Desktop/TireGuard.desktop
# Uses scripts/rpi_run_800x480.sh
./scripts/rpi_desktop_launcher.sh install
# Remove launcher later (optional)
./scripts/rpi_desktop_launcher.sh removeAfter pushing updates to GitHub, update the Pi remotely:
# Example host/user: pi@192.168.1.50
ssh pi@<pi-ip-address> '
cd ~/tireguard-app &&
git pull origin development &&
./scripts/rpi_setup.sh
'If autostart is enabled, reboot to load the updated app at startup:
ssh pi@<pi-ip-address> 'sudo reboot'💡 Access web dashboard (data viewer/export only):
http://<pi-ip-address>:8000from any device on same LAN
(Note: Web interface is supplementary—core scanning happens via touchscreen app)
# Run web-only mode for remote operation
python app.py --web-only --host 0.0.0.0 --port 8000Use this section as a one-stop command guide for users/operators.
# Clone
git clone https://github.com/qsont/tireguard.git
cd tireguard
# Create/activate venv
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txtRaspberry Pi quick setup (automated):
chmod +x scripts/rpi_setup.sh scripts/rpi_run.sh scripts/rpi_run_800x480.sh
./scripts/rpi_setup.sh# Standard app: desktop UI + web server
python app.py
# Simplified touchscreen UI (separate 800x480-friendly UI)
python app.py --simple-ui --no-browser --host 0.0.0.0 --port 8000
# Compact wizard UI
python app.py --compact-ui
# Raspberry Pi preset (compact + fullscreen)
python app.py --rpi-ui --no-browser --host 0.0.0.0 --port 8000
# Desktop UI only (no background web process)
python app.py --desktop-only
# Web API only
python app.py --web-only --host 0.0.0.0 --port 8000# Preferred dedicated launcher for 800x480
./scripts/rpi_run_800x480.sh
# Backward-compatible alias (delegates to rpi_run_800x480.sh)
./scripts/rpi_run.sh
# Override host/port
TIREGUARD_HOST=0.0.0.0 TIREGUARD_PORT=9000 ./scripts/rpi_run_800x480.sh
# Pass extra app args through script
./scripts/rpi_run_800x480.sh --desktop-only
# Reset dataset (truncate DB rows + clear captures/processed exports, keep DB file)
./scripts/rpi_reset_data.sh# Install autostart entry
./scripts/rpi_kiosk_autostart.sh install
# Remove autostart entry
./scripts/rpi_kiosk_autostart.sh remove
# Create desktop launcher
./scripts/rpi_desktop_launcher.sh install
# Remove desktop launcher
./scripts/rpi_desktop_launcher.sh remove# Run thesis validation report from manual readings
python test_accuracy.py \
--manual-csv data/manual_readings.csv \
--out-csv data/test_results.csv \
--slope -6.0 \
--intercept 6.0# Open exported CSV generated by UI actions
ls -lh data/results_export.csv data/test_results.csv# Build standalone executable with PyInstaller
pyinstaller TireGuard.spec--web-only Run web API only
--desktop-only Run desktop UI only
--simple-ui Run simplified 800x480 touchscreen UI
--compact-ui Force compact UI layout
--rpi-ui Raspberry Pi preset (compact + fullscreen)
--no-browser Do not auto-open local dashboard
--host Web host bind address (default: 0.0.0.0)
--port Web port (default: 8000)
# Touchscreen scanner only (no browser popup)
python app.py --simple-ui --no-browser
# Scanner + LAN dashboard
python app.py --simple-ui --host 0.0.0.0 --port 8000
# Remote dashboard only (headless)
python app.py --web-only --host 0.0.0.0 --port 8000calib/ calibrate_scale.py and calib/ calibrate_laser_plane.py currently exist as empty placeholders. Add implementation before documenting runnable calibration commands there.
- Power on device with integrated ring LEDs
- Position spacer against tire surface (enforces 15cm distance)
- Select tire type on touchscreen (Car/Motorcycle)
- Press "Capture" → LEDs illuminate → camera triggers
- View results:
- Numeric tread depth (e.g.,
2.8 mm) - Verdict: ✅ PASS (>3.0mm) |
⚠️ WARNING (1.6–3.0mm) | ❌ REPLACE (<1.6mm)
- Numeric tread depth (e.g.,
- Save session with vehicle ID/tire position
- (Optional) View/export data via web dashboard at
http://<pi-ip>:8000
flowchart LR
A[Capture Image<br>with Ring Lighting] --> B[Preprocess<br>CLAHE + Noise Reduction]
B --> C[Quality Check<br>Brightness/Glare/Sharpness]
C --> D{Pass QC?}
D -- No --> E[“Retake: Poor Lighting”]
D -- Yes --> F[Edge Detection<br>Canny + Contour Analysis]
F --> G[Groove Measurement<br>Pixel-to-mm Conversion]
G --> H[Depth Calculation<br>Using Fixed Distance Calibration]
H --> I[Verdict<br>PASS/WARNING/REPLACE]
📌 No AI training required: Depth calculation uses geometric analysis with fixed 15cm working distance calibration—not neural networks.
To satisfy thesis requirements, conduct this validation:
# Required test procedure (populate Table 3.2 in thesis)
for each_tire in 20_sample_tires:
manual_depth = measure_with_physical_gauge(tire) # Ground truth
device_depth = tireguard.scan(tire) # Your device
# Calculate % difference per Eq. 3.1
percent_diff = abs(device_depth - manual_depth) / manual_depth * 100
# PASS CRITERIA (field-friendly defaults; configurable in app settings):
# - % difference ≤ 10%
# - Absolute error ≤ 0.5mm
# - Device tread class must match manual-depth class
# - Processing time ≤ 5 seconds end-to-end| Issue | Risk | Solution |
|---|---|---|
| No fixed distance | Depth estimation fails completely | 3D-print spacer enforcing 15±2cm distance |
| Ambient lighting | ±2mm error from shadows/highlights | Mandatory ring LED array (60+ LEDs) |
| Browser camera API | Low resolution → invalid measurements | Capture via picamera2/OpenCV not getUserMedia() |
| Binary output only | Fails precision requirement (Prob. Stmt #3) | Must output numeric mm depth (e.g., "2.8mm") |
| No manual validation | Incomplete methodology (Ch. 3) | Test 20+ tires vs. physical gauge |
| Symptom | Likely Cause | Fix |
|---|---|---|
| Inconsistent depth readings | Variable working distance | Verify spacer enforces 15cm distance |
| Dark/shadowed grooves | Insufficient lighting | Increase LED brightness; add diffuser |
| "Blurry image" warnings | Camera focus drift | Clean lens; verify focus at 15cm distance |
For each tire sample:
- Capture a scan.
- Enter manual depth in the Validation panel (Table 3.2 entry).
- Repeat until you have at least 2 entries (20+ recommended for thesis reliability).
Fit directly from validation_results:
.venv/bin/python scripts/fit_score_model.py --source validation --saveThis now auto-refreshes stored scan metrics (device_depth_mm, raw_score_verdict, tread_verdict, verdict) right after model save.
Additionally, each /api/validation/submit call attempts automatic model re-fit and derived-metric refresh once at least 2 validation pairs exist.
If you update calibration outside the fit script, refresh with:
curl -X POST "http://127.0.0.1:8000/api/calibration/refresh-derived"Notes:
- Initial scan
verdictis tread-only by policy. PSI and capture quality are stored separately for diagnostics and Table 3.2 analysis. - API endpoints read calibration on request, and refresh endpoint updates historical rows for consistency.
| Symptom | Likely Cause | Fix |
|---|---|---|
| Web dashboard unreachable | Firewall/network config | sudo ufw allow 8000 on Pi |
| Slow processing (>5 sec) | Unoptimized OpenCV | Enable NEON: pip uninstall opencv-python && pip install opencv-python-headless |
This project is developed for academic purposes under Bulacan State University thesis requirements. Hardware designs and software are for educational use only.
Disclaimer: TireGuard is a proof-of-concept prototype. Always verify critical tire safety decisions with certified manual gauges before vehicle operation. And also this readme file is subject to change so bear in mind some stuff will change as the full release it expected