Skip to main content

Module detect

Module detect 

Source
Expand description

Fast, symbology-agnostic frame-level code locator.

This is the cheap first half of the two-stage live pipeline (see crate::pipeline and crate::traits::Detect). Given a camera frame it answers one question as fast as possible: where are the barcodes, and roughly what kind is each? — a bounding quad plus a coarse family guess per code. It never decodes; the heavier Analyze pass does that, and only for the regions found here.

§How it works

locate makes a single reduced-resolution pass:

  1. Downscale + binarize (grid): box-average the frame down by LocateOptions::downscale and Otsu-threshold the result once. Everything after this works on the small image, which is what makes the locator fast enough to run on every frame.
  2. Concentric finders (finder): a run-length row scan with a vertical cross-check flags QR/Aztec 1:1:3:1:1 fiducials. These give a high-confidence matrix classification and a module-size estimate.
  3. Texture tiles (tiles): tiles dense with dark/light edges are clustered into regions; the horizontal-vs-vertical edge balance separates 1D barcode regions from 2D matrix regions, catching every finder-less symbology.
  4. Merge + map back: finder hits upgrade the region they fall in to a matrix guess with a real module size; region boxes are scaled back to full resolution and returned as Candidates, ordered strongest-first and capped at LocateOptions::max_candidates.

The locator favours recall and speed over precision: it would rather hand Analyze a few extra boxes than miss a code. It is fully deterministic; the only randomness available (via a seeded Prng) is unused by the default path and reserved for future sampling heuristics.

§Family guess

Candidate::symbology carries a representative symbology for the guessed family, not a decode claim: a finder-backed matrix reports Symbology::QrCode, a finder-less matrix Symbology::DataMatrix, and a linear region Symbology::Code128. Recover just the family with Symbology::dimension.

Structs§

Families
Which layout families the locator should report.
FrameDetector
A ready-to-use Detect wrapping locate with fixed options, reusing prior-frame Hints to short-circuit re-analysis: any candidate whose fingerprint matches a known symbol from a previous frame is returned with that symbol attached.
LocateOptions
Tuning knobs for locate. Default gives sensible live-camera values.

Functions§

locate
Locate candidate code regions in frame without decoding them.