Skip to content

Repository files navigation

SuperComputer Red Car Counter Banner

SuperComputer Red Car Counter

This project simulates a small distributed/supercomputer-style system:

  • Worker devices run worker.py.
  • Each worker uses YOLO + OpenCV to count red cars from camera/image URLs.
  • Each worker sends live data to Firebase Realtime Database.
  • The website reads all devices and collates the totals into a live control panel.

Files

  • worker.py — Python worker node script.
  • index.html — dashboard page.
  • style.css — dashboard styling.
  • app.js — Firebase dashboard logic.
  • requirements.txt — Python dependencies.
  • urls.txt.example — example camera URL file.
  • firebase.rules.json — safe starting rules for public read/private write.

Firebase setup

  1. Create a Firebase project.
  2. Create a Realtime Database.
  3. Copy your database URL. It will look like:
https://YOUR-PROJECT-default-rtdb.firebaseio.com
  1. Open Project Settings → Service Accounts → Generate new private key.
  2. Save it beside worker.py as:
serviceAccountKey.json
  1. In Firebase Realtime Database rules, use firebase.rules.json as a starting point. The Python Admin SDK can still write even when public writes are disabled.

Website setup

Open app.js and replace this section with your Firebase Web App config:

const firebaseConfig = {
  apiKey: "...",
  authDomain: "...",
  databaseURL: "...",
  projectId: "...",
  storageBucket: "...",
  messagingSenderId: "...",
  appId: "..."
};

Then host these files on GitHub Pages:

index.html
style.css
app.js

Python setup

Create a virtual environment:

python -m venv .venv

Activate it on Windows:

.venv\Scripts\activate

Activate it on macOS/Linux:

source .venv/bin/activate

Install dependencies:

pip install -r requirements.txt

Create your URL file:

copy urls.txt.example urls.txt

Then add your camera/image URLs to urls.txt.

Run one worker

python worker.py --device-name Laptop-1 --urls-file urls.txt --firebase-db-url https://YOUR-PROJECT-default-rtdb.firebaseio.com --service-account serviceAccountKey.json --show-window

Run many workers

Run the same command on different devices, changing the device name:

python worker.py --device-name Laptop-2 --urls-file urls.txt --firebase-db-url https://YOUR-PROJECT-default-rtdb.firebaseio.com --service-account serviceAccountKey.json
python worker.py --device-name Desktop-1 --urls-file urls.txt --firebase-db-url https://YOUR-PROJECT-default-rtdb.firebaseio.com --service-account serviceAccountKey.json
python worker.py --device-name MiniPC-1 --urls-file urls.txt --firebase-db-url https://YOUR-PROJECT-default-rtdb.firebaseio.com --service-account serviceAccountKey.json

The website will automatically show all active devices.

Database shape

{
  "devices": {
    "Laptop-1": {
      "deviceName": "Laptop-1",
      "status": "online",
      "lastSeen": 1720000000000,
      "cycle": 5,
      "cycleRedCars": 2,
      "totalRedCars": 9,
      "vehiclesSeenThisCycle": 12,
      "sourcesConfigured": 4,
      "sourcesOnline": 4,
      "sourcesFailed": 0,
      "refreshSeconds": 5
    }
  },
  "events": {
    "Laptop-1": {
      "autoId": {
        "timestamp": 1720000000000,
        "cycleRedCars": 2,
        "totalRedCars": 9
      }
    }
  }
}

Notes

  • This is a distributed dashboard, not a true HPC scheduler. It demonstrates the idea of many devices contributing live results to one control panel.
  • Use different camera URLs or device groups if you want each device to process different work.
  • Keep serviceAccountKey.json private. Do not upload it to GitHub.

Releases

Packages

Contributors

Languages