Siddhant Kumar
Project A25 · Edge AI

Edge AI Smart Camera.

On-device person and vehicle analytics with no cloud round-trip — the camera does the AI itself, sending insights not video.

Advanced 14–20 hours 24 min read EdgeVisionPrivacy
Jump to source Bill of materials
Edge AI Smart Camera — reference build illustration MCU VCC · GND · SIG · NC
Difficulty
Advanced
Build time
14–20 hours
Indicative cost
₹8,000 – ₹15,000
Platform
Jetson / Raspberry Pi + camera (edge)
Category
Edge AI
Last updated
28 July 2026
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.

A wall-mounted CCTV surveillance camera
An edge AI smart camera runs person and vehicle analytics on-device and sends insights, not video. Photograph sourced from Wikimedia Commons — CCTV camera.jpg. Reused under the licence stated on that page; please check it before republishing.

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

SettingHow it is used
Retail / footfall analyticsOn-device people counting and flow.
Traffic / parkingVehicle counting and occupancy locally.
Smart buildings / securityPrivate, low-bandwidth analytics.
Edge-AI learningDeploying 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

AttributeValue
Difficulty levelAdvanced
Estimated completion time14–20 hours
Indicative build cost₹8,000 – ₹15,000
Primary disciplineEdge AI
Reference platformJetson / 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.

ComponentKey specificationQtyApprox. 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 FP161₹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 ribbon1₹2,600
Edge camera + compute
Runs AI on-device
Jetson / Pi + accelerator + camera (or smart-camera SoC)1₹8,000
Optimised detectorQuantised/accelerated person/vehicle model1
Analytics logicCounting/tracking/zone events on-device1
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

PartSpecificationSupplyInterfaceReference
NVIDIA Jetson Nano 4 GB128-core Maxwell GPU, quad Cortex-A57 @ 1.43 GHz, 4 GB LPDDR4, 472 GFLOPS FP165 V / 4 A barrelGPIO, I²C, SPI, CSI ×2, USB 3.0Datasheet
Raspberry Pi Camera Module 312 MP IMX708, autofocus, HDR, 1080p50, CSI-2 ribbon3.3 V via CSICSI-2Datasheet

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.

LoadSupply railTypical current (mA)Notes
NVIDIA Jetson Nano 4 GB5 V / 4 A barrel2000Set the 10 W power mode (`nvpmodel -m 0`) with the barrel jack for full GPU clocks.
Raspberry Pi Camera Module 33.3 V via CSI250Pi 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-wide pip install by 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

LibraryWhy it is neededInstall
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.

Edge AI Smart Camera — system block diagramFunctional block diagram of the Edge AI Smart Camera system. SeeCameravideo localDetectOn-device modelperson/vehicleOptimisedquantiseAnalyseCount/trackzones/dwellSendInsightsnot videoPrivate/offlineedgerightrightnone
Edge AI Smart Camera — system block diagram

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.

Edge AI Smart Camera — wiring schematicConnection schematic showing which controller pin drives each peripheral. Sensors / InputsControllerActuators / OutputsJetson / RaspberryPi + camera (edge)5 V / 4 A barrelCameraVideo (stays local)On-device detectorPeople/vehiclesAnalyticsInsightsUplinkCounts/events (notvideo)
Edge AI Smart Camera — wiring schematic
PeripheralPeripheral pinController pinSignal
CameraframesVideo (stays local)
On-device detectorinferPeople/vehicles
Analyticscount/trackInsights
UplinkinsightsCounts/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.
A schematic of a feed-forward artificial neural network
On-device detection plus tracking and zone analytics turn frames into counts and events locally. Photograph sourced from Wikimedia Commons — Artificial neural network.svg. Reused under the licence stated on that page; please check it before republishing.

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.

Edge AI Smart Camera — architecture stackLayered architecture from hardware to user interface. Hardware layerNVIDIA Jetson Nano 4 GB · Raspberry Pi Camera Module 3Driver layerpython · opencv · tf · ultralyticsApplication logicsampling loop · filtering · thresholds · state machinePresentation layerlocal display · serial console · logged output
Edge AI Smart Camera — architecture stack

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 optimisedquantised (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)

plainEdge 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

plainOn-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

plainEdge 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.

Edge AI Smart Camera — firmware flowchartControl flow through the main program loop. Capture frame (on-device)Detect people/vehicles(optimised model)Track + count + zone/dwellEvent(crossing/threshold)?Emit insight/alertUpdate countsEmit insight/alertUpdate countsSend insights only (not video)
Edge AI Smart Camera — firmware flowchart

Assembly Instructions

Build on a breadboard first and only commit to solder once the whole system has run for an hour without a fault.

  1. 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.

  2. Add on-device analytics

    Track, count, and detect zone/line crossings and dwell on the device, producing structured insights.

  3. 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.

  1. 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.py
    def 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 device
    dets = 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.
  2. 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.

pythonedge_smart_camera.py
#!/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.
self.detector = detector # optimised (quantised/accelerated) modelThe detector is optimised to run in real time on the edge device — the core engineering of on-device vision.
dets = self.detector.infer(frame) # ON-DEVICE inferenceInference happens on the camera, so video never needs to be streamed to the cloud to be understood.
tracks = self.tracker.update(dets) # count each object onceCross-frame tracking ensures accurate counts rather than counting the same object every frame.
self.uplink.send(insights) # INSIGHTS ONLY — never videoOnly insights are sent, which is what realises the privacy, bandwidth, latency and offline advantages of edge AI.
# Edge model < cloud GPU accuracy; send counts not identities; notice/minimise.The honest trade-off and residual privacy obligations are stated in the code.

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.

  1. Real-time on device

    Optimise the model to hit real-time FPS within the power budget; validate accuracy.

  2. Analytics

    Tune tracking/zones so counts and events are accurate on-site.

  3. 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.

DatasetSizeLicenceUse here
Person/vehicle detector (pretrained)LargeModel termsOn-device detection
Optimised (quantised) modelSmallReal-time edge inference
Site frames (tuning)SomeOn-siteZones/thresholds tuning
Insight logsSmallOn-siteAnalytics (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.
Edge AI Smart Camera — ML pipelineFrom raw data through training to deployed inference. 1Frameon-device2Detectperson/vehicle3Track+countanalytics4Zone/dwellevents5Insightsnot video
Edge AI Smart Camera — ML pipeline
Layer / stageShape or configurationPurpose
Detectoroptimised person/vehicle modelReal-time on-device detection
Optimisationquantise/prune/accelerateFit compute/power budget
Trackercross-frame associationCount without duplicates
Analyticszones/lines/dwellStructured insights
Uplinkinsights onlyPrivacy + low bandwidth

Hyperparameters

HyperparameterValueWhy
Model size/precisionquantisedAccuracy vs edge budget
Input resolutionedge-fitDetail vs speed
Confidence/track paramstunedCount accuracy
Zones/thresholdssite-specificMeaningful 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.

MetricValueWhat it tells you
On-device FPSreal-timeWithin power budget
Counting accuracyedge-model-dependentAnalytics quality
Bandwidthtiny (insights)vs video streaming
Privacyvideo stays localOnly insights leave

Figures from the reference training run described above — reproduce them before trusting your own changes.

Edge vs cloud trade-offEdge trades some model accuracy for large gains in privacy, bandwidth, latency and offline capability — the edge-AI bargain (illustrative). Privacy (edge)95Bandwidth (edge)92Latency (edge)90Model accuracy (edge)72
Edge vs cloud trade-off

Inference example

pythonedge_camera.py
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.

TestWhat you should see
Detect/count peopleAccurate on-device counts
Detect/count vehiclesAccurate on-device counts
Cross a zone/lineEvent emitted
Check egressOnly insights sent; no video
Disconnect the networkStill analyses (offline) — buffers insights
Compare to a cloud modelSlightly 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.

jsonedge-insights.json
{
  "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.

An ESP32 development board with the ESP-WROOM-32 module and USB connector
Edge trades some accuracy for privacy, bandwidth, latency and offline operation — the edge-AI bargain. Photograph sourced from Wikimedia Commons — ESP32 Espressif ESP-WROOM-32 Dev Board.jpg. Reused under the licence stated on that page; please check it before republishing.

Troubleshooting: Common Errors & Fixes

Too slow on device

Likely cause. Model too big

Fix. Quantise/prune; accelerate; lower resolution

Inaccurate counts

Likely cause. Tracking/zones

Fix. Tune tracking; define zones; adjust confidence

Lower accuracy than cloud

Likely cause. Edge trade-off

Fix. Expected; optimise; accept the bargain

Sends video

Likely cause. Egress not restricted

Fix. Insights-only egress; keep video local

Fails offline

Likely cause. Cloud dependency

Fix. Run analytics on-device; buffer insights

Privacy concern

Likely cause. Analytics obligations

Fix. Notice; minimise (counts not identities); lawful use

The Python script crashes with "externally-managed-environment" on pip install

Likely cause. Raspberry Pi OS Bookworm marks the system Python as managed by apt, and refuses global pip installs.

Fix. Create and activate a virtual environment — python3 -m venv ~/venv && source ~/venv/bin/activate — and install there. Use --system-site-packages if you also need apt-installed modules such as picamera2.

The Pi reboots or shows a lightning-bolt icon under load

Likely cause. Under-voltage. The supply sags below 4.63 V when the CPU and peripherals ramp up.

Fix. Use the official supply for your model (5 V 3 A for Pi 4, 5 V 5 A for Pi 5) and a short, thick USB-C cable. Check with vcgencmd get_throttled — anything other than 0x0 means power problems.

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 taskset and 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 systemd with Restart=always so 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

What makes it "edge" AI?

It runs the AI on the camera itself rather than streaming video to the cloud to be analysed. It processes frames locally and sends only insights — counts and events — not video.

Why is that better than cloud?

Four concrete benefits: privacy (video never leaves the device), bandwidth (an insight is tiny versus a video stream), latency (instant local decisions, no round-trip), and offline operation (it keeps working without connectivity). A camera is the poster child for all of them.

What is the trade-off?

Edge hardware limits how big and accurate a model you can run compared to a cloud GPU, so an edge camera generally accepts some accuracy compromise for its locality benefits — and getting a model to run real-time on-device takes genuine optimisation (quantisation, pruning, acceleration).

Does running on-device solve privacy entirely?

It helps enormously — video stays local and only insights leave — but person and vehicle analytics still carries obligations: notice, purpose limitation, data minimisation (send counts, not identities), and lawful use. Edge is a powerful privacy enabler, not an automatic exemption.

How does it count accurately?

By tracking detected objects across frames and associating them, so each person or vehicle is counted once rather than every frame, and by defining zones/lines for meaningful crossing and dwell events.

References & Learning Resources

These are the primary sources worth reading in full. Manufacturer datasheets always outrank forum posts when the two disagree.

  1. Edge computing / edge AIReference
  2. Smart cameraReference
  3. Model quantizationReference
  4. Object detectionReference
  5. Privacy by designReference