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.
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.
- Create a Firebase project.
- Create a Realtime Database.
- Copy your database URL. It will look like:
https://YOUR-PROJECT-default-rtdb.firebaseio.com- Open Project Settings → Service Accounts → Generate new private key.
- Save it beside
worker.pyas:
serviceAccountKey.json- In Firebase Realtime Database rules, use
firebase.rules.jsonas a starting point. The Python Admin SDK can still write even when public writes are disabled.
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.jsCreate a virtual environment:
python -m venv .venvActivate it on Windows:
.venv\Scripts\activateActivate it on macOS/Linux:
source .venv/bin/activateInstall dependencies:
pip install -r requirements.txtCreate your URL file:
copy urls.txt.example urls.txtThen add your camera/image URLs to urls.txt.
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-windowRun 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.jsonThe website will automatically show all active devices.
{
"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
}
}
}
}- 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.jsonprivate. Do not upload it to GitHub.
