Code readingExplainer

Running custom object detection models on embedded smart cameras

Running custom object detection on an embedded smart camera: how model size, 8-bit quantisation and input resolution set what fits and how fast it runs.

LumaSpec Vision10 min read Share on LinkedIn

On this page 10 sections
  1. 01What an embedded smart camera asks of a model
  2. 02The size arithmetic: parameters × bytes
  3. 03The frame-rate arithmetic: MACs against the clock
  4. 04Worked example: a 300 kB detector on a small vision sensor
  5. 05Quantisation: how the model gets to int8
  6. 06Set the input resolution before you train
  7. 07Where the sensor class stops, and what to step up to
  8. 08Checks before you commit
  9. 09The decision, per case
  10. 10Questions

You have trained a detector on your own parts and want it to run where the image is taken — on the camera, not on a PC. That works, but only for a model sized to the device, and the sizing is arithmetic you can do before you train. This page gives the two numbers that decide it: the int8 model size in kilobytes and the frame rate your compute allows. You get the 4× size saving of 8-bit quantisation, the way input resolution moves compute, a worked example of a 300 kB detector on a small vision sensor with every step shown, and the point at which the right answer stops being the sensor and becomes an x86 smart camera or a vision controller.

What an embedded smart camera asks of a model

Three constraints decide whether your trained network runs on the camera itself. The weights must fit in flash alongside the firmware and your application code. The activations — the intermediate feature maps — must fit in RAM while each layer runs. And one inference, plus image capture and communication, must finish inside the inspection cycle.

Device classes set those budgets. A small vision sensor carries an MCU- or DSP-class processor: plan for weights of a few hundred kilobytes of flash and peak activation memory under about 1 MB. An x86 smart camera runs the same PC-class inference runtimes your training machine does, so capacity stops being the constraint. A vision controller hosts inference for one or several cameras next to the line PLC. Start from the smallest class that clears the checks on this page; it keeps the decision on the device and the wiring short.

The size arithmetic: parameters × bytes

A network's file size is close to its parameter count times the bytes per parameter. A float32 training checkpoint stores each weight in 4 bytes; an int8 quantised model stores each weight in 1 byte.

flash for weights = parameters × bytes per weight (float32: 4 B, int8: 1 B) int8 shrink factor = 32 bits ÷ 8 bits = 4×

Quantisation to 8-bit integers is what turns a bench model into one that fits a sensor. A network of 300,000 parameters holds 1.2 MB as float32 and 300 kB as int8 — the 4× cut that brings compact detectors inside a small vision sensor's flash margin. Activations add working memory on top: the input tensor alone, at 96×96 with one grayscale channel, is 96 × 96 × 1 B = 9,216 B ≈ 9 kB, and each layer's output adds more, with the peak set by the widest layer.

The frame-rate arithmetic: MACs against the clock

Detection cost is counted in multiply-accumulate operations (MACs), and MACs scale roughly with the square of the input side, because every output value of every layer is computed from an input neighbourhood. Halving the input side cuts compute about 4×. Going from 160×160 down to 96×96 divides it by (160 ÷ 96)² ≈ 2.8.

compute ceiling = sustained MAC rate ÷ MACs per inference MACs per inference ≈ MACs at reference size × (target side ÷ reference side)²

Take 100 million MAC/s as the planning number for an MCU-class core in the 300-600 MHz range with single-cycle MAC and DSP instructions. Delivered frame rate lands near half the ceiling once sensor readout, preprocessing and communication take their share. Sustained rates move with memory speed and compiler work, so measure the rate once on your actual device and reuse that number for every later model decision.

Worked example: a 300 kB detector on a small vision sensor

Take a compact one-stage detector: a MobileNet-class backbone with a small SSD-style head, trained at 96×96 on grayscale images. Models of this class carry on the order of 300,000 parameters and about 12 million MACs per inference at that input size.

Size:

  • int8 weights: 300,000 × 1 B = 300 kB. The float32 checkpoint would need 300,000 × 4 B = 1,200,000 B = 1.2 MB.
  • Input tensor: 96 × 96 × 1 B = 9,216 B ≈ 9 kB.
  • Budget check: 300 kB of weights sits inside the few-hundred-kilobyte flash margin of this device class, and peak activation memory for a narrow backbone at this size stays under about 1 MB.

Speed, with the core sustaining 100 million MAC/s:

  • Compute ceiling: 100,000,000 ÷ 12,000,000 ≈ 8.3 fps.
  • Delivered rate at about half the ceiling: 3-4 fps.

Resolution sensitivity: the same backbone at 160×160 costs 12,000,000 × 2.8 ≈ 34 million MACs per inference, so the ceiling falls to 100,000,000 ÷ 34,000,000 ≈ 3 fps and the delivered rate to 1-2 fps.

Decision for this example: if the line presents at most one or two parts per second per camera and each object spans at least 10-15 pixels in the 96×96 input, the sensor runs the model. If the rate is 5 parts/s or the part detail needs the larger input, move up one device class.

Quantisation: how the model gets to int8

Post-training quantisation converts an existing float checkpoint. You give the converter the model plus a calibration set of a few hundred images, and it fixes a scale and zero point per tensor so that int8 arithmetic reproduces the float network closely. No retraining is involved and the conversion takes minutes.

The accuracy cost is usually small for compact detectors. When the drop exceeds your tolerance, quantisation-aware training inserts the int8 behaviour into training itself and recovers most of the gap while keeping the int8 file size. Calibrate with frames from the camera and lighting you will deploy, and score the quantised model on held-out images before rollout — the float checkpoint's score does not carry over.

Set the input resolution before you train

Input size is a design decision, not a detail to fix after training. The rule: the smallest feature you must detect needs 10-15 pixels across in the network input, which keeps it above the coarse output grid of the detection head.

Work it through the optics. If the smallest defect is 2 mm wide and the field of view at the working distance is 60 mm, the sensor delivers 96 ÷ 60 = 1.6 pixels per mm, so the defect spans 2 × 1.6 = 3.2 pixels — too small for the head. Narrow the field of view to 18 mm and the same defect spans 96 ÷ 18 × 2 ≈ 10.7 pixels, inside the rule. If the field cannot shrink, raise the network input and pay the extra compute from the frame-rate arithmetic above.

Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

The runtime then fits your frame to the network input by resizing and padding; how those dimensions behave is covered in the guide on object detector input dimensions and padding.

Where the sensor class stops, and what to step up to

Four limits end the on-sensor path: more than a handful of classes widens the output head; defects that need pixel-level detail demand input sizes the flash and compute budget cannot afford; a layer your device's converter does not accept; and a cycle faster than 2-3 inspections per second. Any one of them moves the model up the ladder.

Device class int8 weight budget Delivered rate, 96×96-class model Deploy here when
Small vision sensor (MCU-class) a few hundred kB about 3-4 fps 1-2 inspections/s, few classes, small parts
x86 smart camera hundreds of MB tens of fps for compact models heavier models, decision taken on the device
Vision controller or AI inference terminal PC-class storage and RAM scales with the processor several cameras, largest models, line logging

For the middle rung, the LS-SMC-0017 smart camera is an x86-platform unit with 8.8 MP resolution, a 1" sensor format, C-mount lens mount and global shutter. Your model exports into a standard runtime format and runs under the camera's PC-class environment, exactly as it does on a bench PC.

Smart cameras & vision sensorsSC / SC smart camera (X86 platform), 8.8 MP, USB3, Color/Mono, global shutter (LS-SMC-0017)LS-SMC-0017
Interface
USB 2.0
Resolution
6-10 MP
Sensor format
1"
Shutter
Global
$1,359.00View part

When several cameras share one model, a controller hosts the inference next to the line. The MV-VC2140-128G40-1T vision controller pairs an Intel N-series N97 processor with 8 GB of memory, 3-4 LAN ports, 2 USB 3 ports and 4 built-in light channels, which covers a compact multi-camera cell. What a CPU-only deployment delivers is covered in the guide on object detection without a GPU.

Vision controllersHikrobot MV-VC2140-128G40-1T VC2100 Vision Controller, N97, 8GB+128G SSD+ 1THDDMV-VC2140-128G40-1T
LAN ports
3-4 LAN ports
USB 3 ports
2 USB 3 ports
Light outputs
4 built-in channels
Memory
8 GB
$1,679.00View partBuild a system with it

For the heaviest models, use hardware built for the job: the MV-VAC3504X-128G01 AI inference terminal carries 5+ LAN ports, 3-4 USB 3 ports and 4 built-in light channels, and its series exists to run neural inference at the line.

Vision controllersHikrobot MV-VAC3504X-128G01 AI inference terminal 3504X single cardMV-VAC3504X-128G01
LAN ports
5+ LAN ports
USB 3 ports
3-4 USB 3 ports
Light outputs
4 built-in channels
$3,929.00 · quotedView and quoteBuild a system with it

Plan which part of the pipeline sits on the camera and which sits on the host with the guide on planning edge vision inference deployment. Once the line runs, model updates become routine; the guide on swapping a neural network model on edge vision hardware shows how to change the model without stopping the cell.

Checks before you commit

  • Parameter count × 1 B against spare flash, leaving headroom for the runtime and your application code.
  • Peak activation memory against spare RAM, measured with the largest frame you will trigger.
  • MACs per inference ÷ sustained MAC rate against the cycle time, with a 2× margin.
  • Smallest feature at 10-15 pixels or more in the network input, checked at the real working distance.
  • Architecture chosen from what the device's converter accepts, decided before training starts.
  • Quantised model scored on held-out images, within the tolerance your defect criteria set.
  • Trigger-to-result latency measured end to end, since readout and communication sit on top of inference.

The decision, per case

Work in this order. Set the input size from the smallest feature and your optics. Pick the smallest architecture that clears it and read parameter count and MACs from the export summary. Multiply parameters by 1 byte for int8 and divide MACs by the sustained rate of your device class: if the weights land within a few hundred kilobytes and the delivered rate clears the cycle with a 2× margin, the sensor runs your model, as in the worked example above.

If any check fails once, stop shrinking the network. An x86 smart camera or a vision controller costs less than weeks of forcing an oversized model into a device that was never going to hold it; the smart camera finder filters the x86 rung by resolution, sensor format and mount, and the system configurator walks the camera-light-controller chain end to end. If you are weighing a learned model against classical tools for a new inspection, read the comparison of AI and rule-based smart camera inspection first.

Questions

How many training images does a small custom detector need?

Start with 200-400 images per class, captured across the variation the camera will really see: part position in the field of view, lighting drift, and every acceptable version of the part. Managed training platforms advertise usable models from as few as 50 images; factory lighting and part mix argue for more. Hold out 10-20 percent of the images and score the quantised model, not just the float checkpoint, on that validation set.

Does int8 quantisation ruin detection accuracy?

Usually not, for a compact detector. Post-training int8 conversion moves the metric you track by around a point or less, and the largest misses land on the smallest objects, because their few pixels sit exactly where scale rounding hurts. A calibration set of a few hundred frames from the deployed camera keeps the per-layer scales matched to real pixel statistics. If accuracy still misses your tolerance, quantisation-aware training recovers most of the loss.

What frame rate can an embedded vision sensor deliver for a neural network?

For a 96×96-class compact model, plan on 3-4 delivered frames per second on a small vision sensor: an 8 fps compute ceiling at 100 million MAC/s, halved by sensor readout, preprocessing and communication. Check the figure against your part rate before committing — one inspection per second clears with margin, ten per second on one sensor does not. Benchmark on the target hardware early, because published desktop benchmarks rarely predict an embedded runtime.

Can any trained model be converted to run on a smart camera?

No. Each device runtime converts a fixed set of operations. Standard convolutions, depthwise convolutions and common one-stage detection heads convert cleanly; exotic layers, dynamic shapes and very large dense matrices often do not. Choose an architecture your camera's conversion path supports before you train — the reverse order ends with a model that never loads. A model that will not convert belongs on an x86 smart camera or a vision controller instead.

Why does my model fit in flash but fail to allocate memory at runtime?

Weights live in flash, but activations live in RAM, and the peak is set by the widest layer, not the average one. A 300 kB model can still demand more working memory than a small sensor has left after its firmware and image pipeline. Shrink the input resolution, pick a narrower backbone, or use a runtime that streams intermediate feature maps at a speed cost. For compact convolutional designs, budget peak activation memory in the same order as the weights.