Contents — 27 sections
Project Overview
On-device person and vehicle analytics with no cloud round-trip — the camera does the AI itself, sending insights not video.
A conventional smart camera streams video to the cloud, where AI analyses it — which costs bandwidth, adds latency, and sends everyone's footage off-device. An edge AI smart camera flips this: it runs the AI on the camera itself, analysing what it sees locally and sending only the results (counts, events, alerts) — not the video. This project builds one that does on-device person and vehicle analytics: detecting and counting people and vehicles in its view, with no cloud round-trip. It is the culmination of the vision and edge-AI ideas in this series, made practical.
The core is running capable vision on constrained hardware. A detection model (as in the object-detection project) runs on an edge computer (a Jetson, a Raspberry Pi with an accelerator, or a smart-camera SoC), detecting people and vehicles in each frame; on top sits the analytics — counting, tracking across frames, zone/line crossing, dwell time — producing structured insights. The whole point is that this happens locally: the model is optimised (quantised, pruned, hardware-accelerated) to run in real time within the camera's compute and power budget.
The advantages of edge over cloud are concrete and compelling: privacy (video never leaves the device — a huge deal for cameras in public and private spaces), bandwidth (send a number, not a video stream — essential at scale or on poor connections), latency (instant local decisions, no round-trip), and offline operation (works without connectivity). It is honest about the trade-offs: edge hardware limits model size and accuracy versus a cloud GPU (the capability-vs-constraints tension of all edge AI), optimisation takes real work, and — as with any analytics camera — privacy must be designed for responsibly (edge processing helps enormously, but person/vehicle analytics still carries obligations). Built as a real-time, on-device analytics camera that sends insights not video, it is both a genuinely useful, privacy-respecting product pattern and the definitive lesson in deploying vision AI at the edge.
What this project does
- Runs person/vehicle analytics on the camera itself
- Detects and counts people and vehicles on-device
- Sends insights (counts/events), not video
- Tracks across frames; zone/line crossing; dwell
- Works with no cloud round-trip (offline-capable)
- Optimises models to run in real time on edge hardware
- Preserves privacy by processing locally
Real-World Applications
| Setting | How it is used |
|---|---|
| Retail / footfall analytics | On-device people counting and flow. |
| Traffic / parking | Vehicle counting and occupancy locally. |
| Smart buildings / security | Private, low-bandwidth analytics. |
| Edge-AI learning | Deploying vision on constrained hardware. |
Deployment contexts where a build of this kind earns its keep.
Features & Capabilities
- On-device detection + analytics
- Person/vehicle counting and tracking
- Zone/line-crossing and dwell events
- Insights-not-video output
- Model optimisation (quantise/prune/accelerate)
- Privacy, bandwidth, latency, offline benefits
- Honest about capability-vs-constraints and privacy
Difficulty, Time & Required Skills
| Attribute | Value |
|---|---|
| Difficulty level | Advanced |
| Estimated completion time | 14–20 hours |
| Indicative build cost | ₹8,000 – ₹15,000 |
| Primary discipline | Edge AI |
| Reference platform | Jetson / Raspberry Pi + camera (edge) |
Skills you should have (or will pick up)
- On-device object detection and analytics
- Model optimisation (quantisation/pruning/acceleration)
- Tracking, counting, zone/line events
- Edge deployment (compute/power budget)
- Privacy-respecting analytics design
Bill of Materials
Every part below is commonly available from Indian and international hobby-electronics suppliers. Prices are indicative 2026 retail figures in Indian rupees and will drift — treat them as a budgeting guide, not a quotation.
| Component | Key specification | Qty | Approx. cost |
|---|---|---|---|
| NVIDIA Jetson Nano 4 GB Set the 10 W power mode (`nvpmodel -m 0`) with the barrel jack for full GPU clocks. | 128-core Maxwell GPU, quad Cortex-A57 @ 1.43 GHz, 4 GB LPDDR4, 472 GFLOPS FP16 | 1 | ₹15,000 |
| Raspberry Pi Camera Module 3 Pi 5 uses a narrower 22-pin CSI cable — the old 15-pin ribbon will not fit. | 12 MP IMX708, autofocus, HDR, 1080p50, CSI-2 ribbon | 1 | ₹2,600 |
| Edge camera + compute Runs AI on-device | Jetson / Pi + accelerator + camera (or smart-camera SoC) | 1 | ₹8,000 |
| Optimised detector | Quantised/accelerated person/vehicle model | 1 | — |
| Analytics logic | Counting/tracking/zone events on-device | 1 | — |
| Insight uplink Low bandwidth | Send counts/events (not video) | 1 | — |
Estimated total: ₹25,600, excluding tools, shipping and consumables.
Tools and consumables
- Soldering iron (temperature controlled, 350 °C) with 0.8 mm 60/40 or lead-free solder
- Digital multimeter — continuity, DC volts and current ranges
- Wire strippers, flush cutters and a small set of precision screwdrivers
- Heat-shrink tubing and a heat gun (or a lighter, carefully)
- A laptop with a USB port and the toolchain listed above
Hardware Specifications
| Part | Specification | Supply | Interface | Reference |
|---|---|---|---|---|
| NVIDIA Jetson Nano 4 GB | 128-core Maxwell GPU, quad Cortex-A57 @ 1.43 GHz, 4 GB LPDDR4, 472 GFLOPS FP16 | 5 V / 4 A barrel | GPIO, I²C, SPI, CSI ×2, USB 3.0 | Datasheet |
| Raspberry Pi Camera Module 3 | 12 MP IMX708, autofocus, HDR, 1080p50, CSI-2 ribbon | 3.3 V via CSI | CSI-2 | Datasheet |
Consolidated electrical and interface specifications for every active part in the build.
Power Budget & Supply Sizing
Add up the typical active current of every part, then size the supply with at least 50 % headroom so transmit bursts and motor inrush never brown out the controller.
| Load | Supply rail | Typical current (mA) | Notes |
|---|---|---|---|
| NVIDIA Jetson Nano 4 GB | 5 V / 4 A barrel | 2000 | Set the 10 W power mode (`nvpmodel -m 0`) with the barrel jack for full GPU clocks. |
| Raspberry Pi Camera Module 3 | 3.3 V via CSI | 250 | Pi 5 uses a narrower 22-pin CSI cable — the old 15-pin ribbon will not fit. |
Summed typical draw is 2250 mA. With a 1.5× design margin the supply should deliver at least 3400 mA continuously at the stated rail voltage.
Software Requirements & Development Environment
Reference toolchain: Python 3.11 + edge AI / vision. Anything newer normally works; anything older may lack the board definitions used here.
- Flash Raspberry Pi OS (64-bit) with Raspberry Pi Imager; pre-configure Wi-Fi, hostname and SSH in the Imager settings so the board comes up headless.
- Update first:
sudo apt update && sudo apt full-upgrade -y, then reboot. - Work inside a virtual environment —
python3 -m venv ~/venv && source ~/venv/bin/activate. Bookworm blocks system-widepip installby design. - Enable the buses you need with
sudo raspi-config→ Interface Options (I²C, SPI, Serial, Camera). - Develop over VS Code Remote-SSH so you edit on your laptop but run on the Pi.
Required libraries
| Library | Why it is needed | Install |
|---|---|---|
| Python 3.11+ | Runtime for the analysis, training and service code. | sudo apt install python3 python3-venv python3-pip |
| OpenCV 4.10+ | Frame capture, colour conversion, drawing and classical CV operators. | pip install opencv-python |
| TensorFlow / Keras 2.17+ | High-level model building and the TFLite converter. | pip install tensorflow |
| Ultralytics YOLO 8.3+ | Training and inference API for YOLOv8/v11 detectors. | pip install ultralytics |
| ONNX Runtime 1.19+ | Portable, quantised inference across CPU, GPU and NPUs. | pip install onnxruntime |
Block Diagram
The block diagram shows the functional decomposition of the system — what senses, what decides, what acts, and where the data ends up.
Circuit Diagram & Wiring
The "wiring" combines a camera and on-device AI — frames are analysed locally by an optimised detector plus analytics, and only the resulting insights (counts/events) leave the device.
| Peripheral | Peripheral pin | Controller pin | Signal |
|---|---|---|---|
| Camera | frames | — | Video (stays local) |
| On-device detector | infer | — | People/vehicles |
| Analytics | count/track | — | Insights |
| Uplink | insights | — | Counts/events (not video) |
Wire one row at a time and tick it off — most "it does not work" reports trace back to a single swapped pair.
Wiring explanation
- The camera feeds frames to on-device inference (video stays local).
- An optimised detector finds people and vehicles in real time.
- Analytics (count/track/zone/dwell) run on-device.
- Only insights (counts/events/alerts) are sent — not video.
- Balance model size/accuracy against the edge compute/power budget.
System Architecture
Read the stack from the bottom up: physical hardware, the firmware that drives it, the transport that moves data off the device, and the software a human actually looks at.
Working Principle
The edge AI smart camera is defined by a single architectural choice with large consequences: run the AI where the camera is, not in the cloud. A conventional smart camera is really a dumb camera plus a cloud brain — it streams video away to be analysed. The edge camera is the brain: it analyses what it sees on-device and emits only the conclusions. That inversion — process locally, send insights not video — is the whole idea, and everything valuable about the design flows from it.
The engineering core is running capable vision on constrained hardware. On top of an on-device object detector (people and vehicles, as in the detection project) sits the analytics that turns detections into insight: tracking objects across frames to avoid double-counting, counting, detecting zone or line crossings (someone entered an area, a vehicle passed a point), and dwell time. The catch is that all of this must run in real time within the camera's compute and power budget, which is a fraction of a cloud GPU's. So the model is optimised — quantised (lower-precision arithmetic), pruned, and hardware-accelerated (using the edge device's NPU/GPU) — to fit. This optimisation work is central to edge AI and is where much of the real effort goes.
The advantages of edge over cloud are concrete, and together they explain why this pattern is so compelling for cameras specifically. Privacy: because the video is analysed on-device and never leaves it, an edge camera sidesteps the enormous privacy exposure of streaming everyone's footage to a cloud — a decisive benefit for cameras in shops, streets, workplaces and homes. Bandwidth: sending a count or an event is trivially small compared to a continuous video stream, which makes large deployments and poor-connectivity sites feasible. Latency: local analysis gives instant decisions with no cloud round-trip, essential for real-time triggers. Offline operation: it keeps working without connectivity, since it does not depend on the cloud to think. These four — privacy, bandwidth, latency, resilience — are the canonical case for edge AI, and a camera is the poster child for all of them.
The honesty is the capability-versus-constraints trade-off that governs all edge AI, plus the privacy responsibilities that remain. Edge hardware limits how big and accurate a model you can run compared to a cloud GPU, so an edge camera generally makes an accuracy compromise for its locality benefits — and getting a useful model to run in real time on the device takes genuine optimisation work. It is honest, too, that while edge processing enormously reduces privacy risk (video stays local, only insights leave), person and vehicle analytics still carries obligations — you are still observing people and their movements, so notice, purpose limitation, data minimisation (send counts, not identities) and lawful use remain necessary; edge is a powerful privacy enabler, not an automatic exemption. Framed correctly, though, the edge AI smart camera is the practical synthesis of this whole series' ideas — real-time detection, analytics, and resource-constrained on-device deployment — into a genuinely useful, privacy-respecting product pattern, and the definitive lesson in why, and how, to run vision AI at the edge.
The maths behind it
Edge vs cloud (the choice)
cloud camera: device → stream VIDEO → cloud AI → result
edge camera: device → ON-DEVICE AI → send INSIGHTS only
Process locally; send counts/events, not video.
On-device analytics
detect(frame) → people/vehicles
track across frames → avoid double-count
count / zone-crossing / dwell → insights
All in real time within the edge COMPUTE/POWER budget.
Edge benefits + the trade-off
benefits: PRIVACY (video stays), BANDWIDTH (insight ≪ video),
LATENCY (no round-trip), OFFLINE (no cloud needed)
trade-off: edge HW limits model size/accuracy vs cloud GPU
→ optimise (quantise/prune/accelerate). Analytics still needs
privacy care.
Program Flowchart
The firmware is a single cooperative loop. Nothing blocks for long, so networking, sensing and the user interface all stay responsive.
Assembly Instructions
Build on a breadboard first and only commit to solder once the whole system has run for an hour without a fault.
Run an optimised detector on-device
Deploy a person/vehicle detector on the edge computer, optimised (quantised/accelerated) to run in real time within the compute/power budget.
Add on-device analytics
Track, count, and detect zone/line crossings and dwell on the device, producing structured insights.
Send insights, not video
Emit only counts/events/alerts, keeping video local — realising the privacy, bandwidth, latency and offline benefits.
Step-by-Step Implementation Guide
Work through these in order. Each step ends in something you can observe, so a failure is always localised to the step you just finished.
Detect and analyse on-device, send insights
Run the optimised detector and analytics locally, and send only the resulting counts/events — never the video.
pythonanalyse.pydef analyse(frame, detector, tracker, zones): dets = detector.infer(frame) # ON-DEVICE optimised inference tracks = tracker.update(dets) # associate across frames (count once) insights = { "people": sum(t.cls == "person" for t in tracks), "vehicles": sum(t.cls == "vehicle" for t in tracks), "events": zone_and_line_events(tracks, zones), # crossings / dwell } send_insights(insights) # send INSIGHTS, not video return insights # video never leaves the devicedets = detector.infer(frame) # ON-DEVICE optimised inferenceDetection runs on the camera itself with an optimised model — the essence of edge AI, no cloud round-trip.tracks = tracker.update(dets) # associate across frames (count once)Tracking associates detections across frames so each person/vehicle is counted once, not per frame."events": zone_and_line_events(tracks, zones), # crossings / dwellAnalytics turns tracks into structured events — zone/line crossings and dwell — the useful insight.send_insights(insights) # send INSIGHTS, not videoOnly the insights leave the device; the video stays local — delivering privacy, low bandwidth, low latency and offline operation.Optimise and tune for the device
Optimise the model to hit real-time FPS within the power budget, and tune zones/tracking on-site for accurate insights.
Complete Source Code
The listing below is complete and compiles as written — there are no elided sections. Read the annotations under each block before you upload it.
#!/usr/bin/env python3
"""
Edge AI Smart Camera
Runs person/vehicle analytics ON THE CAMERA ITSELF (no cloud round-trip)
and sends INSIGHTS, not video. An optimised detector + tracking/counting
+ zone/dwell analytics run in real time within the edge compute/power
budget. Benefits: PRIVACY, BANDWIDTH, LATENCY, OFFLINE. Trade-off: edge
HW limits model size/accuracy; analytics still needs privacy care.
"""
class EdgeSmartCamera:
def __init__(self, detector, tracker, zones, uplink):
self.detector = detector # optimised (quantised/accelerated) model
self.tracker = tracker; self.zones = zones; self.uplink = uplink
def analyse(self, frame):
dets = self.detector.infer(frame) # ON-DEVICE inference
tracks = self.tracker.update(dets) # count each object once
return {
"people": sum(t.cls == "person" for t in tracks),
"vehicles": sum(t.cls == "vehicle" for t in tracks),
"events": zone_and_line_events(tracks, self.zones), # crossings/dwell
}
def run(self, camera):
for frame in camera.frames(): # frames stay on-device
insights = self.analyse(frame)
self.uplink.send(insights) # INSIGHTS ONLY — never video
# -> privacy (video local), low bandwidth, low latency, offline.
if __name__ == "__main__":
cam = EdgeSmartCamera(OptimisedDetector(), Tracker(), ZONES, InsightUplink())
cam.run(Camera())
# Edge model < cloud GPU accuracy; send counts not identities; notice/minimise.
Configuration & Calibration
Configuration steps
- Configure the optimised on-device detector and accelerator.
- Configure tracking/counting and zones/lines/dwell.
- Configure insights-only uplink (no video egress).
- Configure privacy: notice, minimisation (counts not identities).
Calibration procedure
An uncalibrated sensor produces confident, precise, wrong numbers. Do this once per physical unit and record the constants.
Real-time on device
Optimise the model to hit real-time FPS within the power budget; validate accuracy.
Analytics
Tune tracking/zones so counts and events are accurate on-site.
Privacy
Confirm only insights leave; keep video local; minimise data.
Dataset, Model & Training
Dataset
A person/vehicle detection model (pretrained, then optimised for the edge). The value is on-device analytics, not new data.
Optimisation (quantisation) can slightly reduce accuracy — validated against the deployment need.
| Dataset | Size | Licence | Use here |
|---|---|---|---|
| Person/vehicle detector (pretrained) | Large | Model terms | On-device detection |
| Optimised (quantised) model | Small | — | Real-time edge inference |
| Site frames (tuning) | Some | On-site | Zones/thresholds tuning |
| Insight logs | Small | On-site | Analytics (counts, not identities) |
Data preprocessing
- Resize/normalise frames for the on-device model.
- Optimise the model (quantise/prune) and target the device accelerator.
- Define zones/lines and analytics parameters on-device.
| Layer / stage | Shape or configuration | Purpose |
|---|---|---|
| Detector | optimised person/vehicle model | Real-time on-device detection |
| Optimisation | quantise/prune/accelerate | Fit compute/power budget |
| Tracker | cross-frame association | Count without duplicates |
| Analytics | zones/lines/dwell | Structured insights |
| Uplink | insights only | Privacy + low bandwidth |
Hyperparameters
| Hyperparameter | Value | Why |
|---|---|---|
| Model size/precision | quantised | Accuracy vs edge budget |
| Input resolution | edge-fit | Detail vs speed |
| Confidence/track params | tuned | Count accuracy |
| Zones/thresholds | site-specific | Meaningful events |
Training process
- Use a pretrained detector; optimise (quantise/prune) and accelerate for the device.
- Validate that the optimised model runs real-time and stays accurate enough.
- Tune analytics (zones/tracking) on-site; keep only insights.
Evaluation, Metrics & Deployment
The metrics are real-time on-device performance (FPS within power budget), analytics accuracy (counts), and the privacy/bandwidth benefits of insights-not-video.
| Metric | Value | What it tells you |
|---|---|---|
| On-device FPS | real-time | Within power budget |
| Counting accuracy | edge-model-dependent | Analytics quality |
| Bandwidth | tiny (insights) | vs video streaming |
| Privacy | video stays local | Only insights leave |
Figures from the reference training run described above — reproduce them before trusting your own changes.
Inference example
def analyse(frame, detector, tracker, zones):
dets = detector.infer(frame) # ON-DEVICE (optimised model)
tracks = tracker.update(dets) # track to avoid double-counting
insights = {
"people": sum(t.cls == "person" for t in tracks),
"vehicles": sum(t.cls == "vehicle" for t in tracks),
"events": zone_and_line_events(tracks, zones), # crossings/dwell
}
send_insights(insights) # send COUNTS/EVENTS, not video
# Video never leaves the device: privacy, bandwidth, latency, offline.
# Edge HW limits model size/accuracy; analytics still needs privacy care.
Testing Procedure & Expected Output
Test from the bottom up. Confirm power, then each sensor in isolation, then the integrated loop — the first failing step tells you exactly where to look.
| Test | What you should see |
|---|---|
| Detect/count people | Accurate on-device counts |
| Detect/count vehicles | Accurate on-device counts |
| Cross a zone/line | Event emitted |
| Check egress | Only insights sent; no video |
| Disconnect the network | Still analyses (offline) — buffers insights |
| Compare to a cloud model | Slightly lower accuracy (edge trade-off) |
Bench-test checklist. If a row fails, stop and fix it before moving on.
Expected output
On-device person/vehicle counts and events, sent as insights (not video), working privately and offline.
{
"people": 7,
"vehicles": 2,
"events": [{ "type": "line_crossing", "class": "person", "dir": "in" }],
"video_sent": false,
"note": "insights not video: private, low-bandwidth, low-latency, offline"
}
On-device analytics — people and vehicle counts and a line-crossing event — sent as a tiny insight payload with no video leaving the device: the edge-AI advantages made concrete.
Troubleshooting: Common Errors & Fixes
Performance Optimisation
- Optimise (quantise/prune/accelerate) for real-time on-device inference.
- Track across frames for accurate counts.
- Send insights only — never video.
- Accept the edge accuracy trade-off for the locality benefits.
- Pin the hot loop to one core with
tasksetand leave the others free for the OS. - Prefer MJPEG over raw YUY2 when capturing from USB cameras — the decode cost is far lower than the USB bandwidth cost.
- Log to a tmpfs RAM disk and flush to the SD card once a minute; per-sample SD writes are what kills cards.
- Run the service under
systemdwithRestart=alwaysso a crash never means a dead deployment. - Profile before optimising — print
micros()deltas around each stage and fix the slowest one first.
Safety Precautions
- Person/vehicle analytics carries privacy obligations even on-device — notice, purpose limitation and data minimisation (send counts, not identities).
- Edge processing reduces but does not remove responsibility for observing people.
- Keep video local; restrict egress to insights.
- Comply with applicable surveillance/privacy law.
- Wear eye protection when soldering or cutting, and solder in a ventilated space — rosin flux fumes are a respiratory irritant.
- Power the circuit through a bench supply with a current limit while you are testing. A 300 mA limit turns a wiring mistake into a beep instead of a dead board.
- Disconnect power before changing any wiring. Hot-plugging a sensor onto a live bus is the fastest way to lose a controller.
Maintenance
- Re-optimise/update models as hardware and needs change.
- Re-tune analytics/zones after camera or layout changes.
- Monitor on-device performance and accuracy.
- Audit egress and privacy practices.
- Re-check every screw terminal and header after the first week — thermal cycling loosens connections that felt tight on day one.
- Recalibrate at the interval given in the calibration section, and keep the constants in a text file next to the firmware — not only in flash.
- Keep a short logbook of firmware versions and what changed. Six months later you will not remember why that constant is 1.083.
Future Improvements & Upgrades
A working v1 is a platform, not a finish line. These are the upgrades that add the most capability for the least rework.
- Add more analytics (flow, occupancy, heatmaps).
- Add federated/on-device model updates.
- Add stronger accelerators for bigger models.
- Add privacy-preserving aggregation across cameras.
- Design a proper PCB. Once the breadboard version has run for a month, moving to a two-layer board removes the intermittent-contact failures that dominate prototype faults.
- Add connectivity — an ESP32 and an MQTT publish turn a local gadget into something you can graph, alert on and analyse over months.
- Add persistent local storage (microSD or the on-chip flash) so a network outage does not create a hole in your data.
- Move configuration out of the source: a captive-portal setup page or a JSON config file makes the build reusable without a recompile.
- Add a battery and solar option so the unit survives a power cut and can be sited away from a socket.
- Write a small test harness that feeds synthetic sensor values through the decision logic, so you can validate thresholds without physically triggering the event.
Frequently Asked Questions
References & Learning Resources
These are the primary sources worth reading in full. Manufacturer datasheets always outrank forum posts when the two disagree.
- Edge computing / edge AIReference
- Smart cameraReference
- Model quantizationReference
- Object detectionReference
- Privacy by designReference