Expand description
§QR Code & Barcode Scanner for Rust
§Ask AI
Choose an AI assistant to explain this destination using its public sources. Gemini opens gemini.google.com. Gemini, Copilot, DeepSeek, Meta AI and Qwen require pasting the prompt below; the other links include it in their URL. Sign-in or a manual paste may still be required. Check the answer against the documentation.
Copy the plain-text prompt
Use the code block’s copy control, or select its complete text, then paste it into your assistant.
Help me understand QR Code & Barcode Scanner for Rust (crates/qrcode-ai-scanner/README.md) for QR Code & Barcode Scanner, the open-source scanner. Source documentation; publication is not implied. Provided README context (verify against the sources): Use the Rust library when your program needs to scan image bytes or RGBA frames in process and inspect the resulting detections. The report separates decoded content from its physical occurrences and keeps an unmeasured QR quality score distinct from a zero score. Start with the image example below, then choose profiles and input limits for your workload. Read the public documentation below. Explain what this destination does, its documented installation or access steps, a minimal example if supported, prerequisites, limitations and license. Distinguish published packages from working source and preparation. Cite your sources; if a page is unavailable or a fact cannot be checked, say so. Do not invent installation commands, benchmark results or comparisons. Answer in my language. Public sources: https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/main/crates/qrcode-ai-scanner/README.md https://qrcode-ai.com/en-US/qr-code-scanner https://qrcode-ai.com/en-US/barcode-scanner https://qrcode-ai.com/en-US/qr-code-scanner/sdk/rust https://qrcode-ai.com/en-US/barcode-scanner/sdk/rust https://qrcode-ai.com/en-US/qr-code-generator https://qrcode-ai.com/en-US/barcode-generatorUse the Rust library when your program needs to scan image bytes or RGBA frames in process and inspect the resulting detections. The report separates decoded content from its physical occurrences and keeps an unmeasured QR quality score distinct from a zero score. Start with the image example below, then choose profiles and input limits for your workload.
The QR code scanner and barcode scanner are QR Code AI’s browser scanning entry points. For the corresponding development route, the QR code scanner Rust guide and barcode scanner Rust guide connect this documentation to the two product journeys. If a product page is unavailable, the instructions and references in this README remain the starting point for this source directory.
To prepare a fixture with a known payload for a Rust application, use the QR code generator or the barcode generator. Keep the original payload with the exported image so that you can compare the scan result with the value you intended to encode.
Decode QR codes, linear barcodes and other 2D formats, including Data Matrix, from local images or raw RGBA frames. Read decoded content and measured symbol positions from one structured report. QR scannability diagnostics add stress-test results and suggestions for improving artistic or photo-captured codes.
qrcode-barcode-scanner is the Rust core of QR Code AI.
It runs locally, with no network requests.
API · Report contract · Scoring
For a one-off image check, the browser image example uses the same engine.
§How it works
The picture shows the three steps of the crate. They are the next three sections: add the crate to a project, pass the bytes of an image to the engine inside your program, then read the report it returns.
§Install
Use Rust 1.88 or later. Create a binary project and add the exact scanner version so that the dependency and the documentation can be reviewed together:
cargo new scan-label
cd scan-label
cargo add qrcode-barcode-scanner@=0.12.3
curl -fsSL -o label.png \
https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/v0.12.3/fixtures/symbology/mixed-code128-qr.pngFor working source, verify that the selected version exists on crates.io before installation. Source revisions and registry releases have separate availability and licenses.
§Scan an image
Save the following complete program as src/main.rs, then run
cargo run --release from the project directory. The sample contains QR
https://qrc-ai.com/76xMa and Code 128 STOCK-4827; compare the decoded
values, rather than assuming a detection’s array position.
use qrcode_barcode_scanner::{ImageInput, ScanProfile, Scanner};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let bytes = std::fs::read("label.png")?;
let scanner = Scanner::builder().profile(ScanProfile::Full).build();
let report = scanner.scan(ImageInput::encoded(&bytes))?;
for detection in &report.detections {
println!("{:?}: {}", detection.symbology, detection.content.text);
println!("Physical occurrences: {}", detection.occurrences.len());
}
Ok(())
}Encoded input accepts PNG, JPEG, WebP and GIF. Use ImageInput::rgba8 for raw
frames without an image-format roundtrip. Compiled format support depends on the
selected engine features; the capabilities API lists the readers included in the
build, not a guarantee that a particular image will decode.
§Read the report
The picture is a recorded scan of one image that holds a QR code and a Code 128 barcode. Both come back in the same report, each with its format and the place where the engine measured it.
| Field | Meaning |
|---|---|
detections | Distinct decoded contents, with their symbology and payload classification. |
detections[*].occurrences | Measured physical copies of each content. Two copies can belong to one detection. |
score | QR scannability assessment when available. None means no score, never zero. |
hints | Suggestions derived from the measurements the engine actually made. |
trace.budget_exhausted | Whether the deadline prevented planned scan work. |
Use the geometry that was measured: a linear barcode can have endpoints instead of four corners. Only the QR family carries QR metadata and correction-margin diagnostics. These software measurements do not certify a code with a hardware barcode verifier.
Exact payloads, errors and scan budgets
For the QR family, content.raw holds the original payload bytes. For other
symbologies it holds the decoding engine’s reading, encoded as ISO/IEC 8859-1
when every character fits, otherwise UTF-8. content.charset describes how
content.text reads those bytes; unknown is the only lossy value, so use
raw in that case. Content identity includes the symbology, raw bytes, FNC1
position and compatible ECI declarations, never display text alone.
When no code is detected, the scan returns Ok with an empty detections list.
Errors cover invalid input
(QRS-001..004), cancellation (QRS-005) and invalid options (QRS-006);
branch on err.code(). A zero Limits cap or ScanConfig side, a palette above
ScanConfig::MAX_ALPHA_PALETTE, or a budget above
ScanConfig::MAX_BUDGET_MS is refused before the image is read.
The full, fast and frame profiles select the scan workload and default
budget. A report is final when report.trace.budget_exhausted == Some(false).
Set the configuration’s budget_ms to None for an unbounded scan; a time-bounded
scan can stop before planned work finishes, which the trace records.
ScanConfig.formats restricts a scan to the symbologies it lists: no reader of
another symbology runs, and the report repeats them in trace.formats. Empty,
the default, reads every symbology.
The multi-engine ladder uses rxing and rqrr. QR quality diagnostics include survival-ramp stress tests and the synthetic unused-error-correction margin measured from the verified stream. See the scoring contract for the measurement limits and which results can be absent.
§What it reads
With its default features, the crate reads the formats below. Codes of different formats in the same image come back in one report.
| Family | Formats |
|---|---|
| QR | QR Code, Micro QR, rectangular Micro QR (rMQR) |
| Matrix and stacked | Data Matrix, Aztec, PDF417, MaxiCode |
| Retail | EAN-13, EAN-8, UPC-A, UPC-E |
| Other linear | Code 128, Code 39, Code 93, Codabar, ITF, GS1 DataBar, GS1 DataBar Expanded, Telepen |
The engine’s supported formats section states the known limits.
§The same engine in other runtimes
| Runtime | Package | How it scans |
|---|---|---|
qrcode-barcode-scanner on crates.io | In process | |
@qrcode-ai-com/qrcode-barcode-scanner on npm | In process, native | |
@qrcode-ai-com/qrcode-barcode-scanner-wasm on npm | In the page, WebAssembly | |
qrcode-barcode-scanner on PyPI | In process | |
qrcode-barcode-scanner-go | Through the installed qrscan | |
qrcode-barcode-scanner-php | Through the installed qrscan | |
qrscan | One command, one JSON report |
The Rust, Node.js, browser and Python packages hold the engine. The Go and PHP packages hold no decoder:
each one starts qrscan and hands you its report.
Language and platform names and logos belong to their owners. They identify a runtime or a destination and imply no endorsement.
§Documentation and licensing
Architecture · Error codes · Security · Report a bug
Releases up to 0.10.1 were published as qrcode-ai-scanner.
Source license: MIT. Published archives retain their own packaged license. Read the current licensing guide and the license packaged with the exact version you install. © SuperNovae Studio.
Maintained by Thibaut Mélen & Nicolas Cella for QR Code AI, a product of SuperNovae Studio. The license of each component is stated in its own license files.
§Source license
Project-authored scanner code and documentation in this checkout are available under the MIT License. You may use, modify and redistribute this source in open-source or proprietary applications, including commercial products, while preserving the copyright and permission notice. Thibaut Mélen & Nicolas Cella develop QR Code AI at SuperNovae Studio.
Retained third-party code, dependencies, artwork and test data keep their own licenses and notices. The licensing guide explains these component boundaries; the project license does not assign a license to an unrelated platform or service.
Published archives retain the license shipped with their version. A pinned engine, adapter or bundle may therefore have different terms from this working source. Read its packaged license and the license history before reuse. The source change does not replace an archive or publish a new version.
§Library contract
Decoding + scannability validation for artistic, AI-generated, and photo-captured QR codes — the codes that break standard scanners.
Contract (the normative wire format lives in the spec/ directory):
- No QR found is
Okwith empty detections —Erris reserved for real faults: an option outside its domain (QRS-006, checked before the input), invalid or oversized input (QRS-001..004) or cancellation (QRS-005). - Deterministic: same bytes + same config + same scanner build ⇒ the
same report, bit for bit on a given platform (wall clock aside) — no
RNG anywhere. Three caveats, all bounded:
- a wall-clock budget makes the CUT point machine-dependent. A cut
report says so (
trace.budget_exhausted: true), one that does not is the unbounded report, and a judgment the budget cannot complete is absent, never partial. Setbudget_ms: Nonefor strictly identical reports; a cancelled scan staysQRS-005; - CROSS-platform the libm transcendentals (warp kernels, gaussian blur) may differ in the last ulp — a stress cell sitting exactly on a knee can flip between platforms;
- rxing’s PDF417 decoder (0.9.1–0.9.3) breaks codeword-confidence ties
in randomized
HashMaporder, so a PDF417 symbol near a decode threshold can score, and a marginal one decode, differently between runs.
- a wall-clock budget makes the CUT point machine-dependent. A cut
report says so (
- Sync by design: async belongs to the bindings (napi/wasm), never here.
- Engine-isolated: third-party decoder panics are caught at the engine boundary and recorded in the trace; the ladder continues.
Modules§
- options
- Option admission for callers whose numbers are IEEE doubles — the WASM
and Node bindings. One mapping of a JavaScript
numberonto the core’s typed options, so both surfaces accept and refuse the same values (spec/02-profiles.md § Option domains). Integer surfaces (Rust, Python, Kotlin/Swift, the CLI) need none of this:crate::Scannervalidates the typed options themselves before reading the input.
Structs§
- Alpha
Envelope - The placement envelope — “over which backgrounds does this transparent design keep decoding”. Probes are quick decodes in the primary symbol’s own decode class (never the full ladder’s recovery power): the envelope measures COMFORTABLE placement, the primary verdict measures full margin on its declared background.
- Alpha
Palette Probe - One HOST-requested palette probe (
alpha_paletteconfig) — “does the design survive on this specific theme/brand color”. - Alpha
Probe - One neutral-background decode probe of the placement envelope.
- Alpha
Report - How transparency was handled for this scan. Present ONLY when the input
actually carried transparent pixels AND
alpha_backgroundwas notnone— opaque inputs stay byte-identical to pre-0.9 reports. - Axis
Score - Survival result on one stress axis.
- Cancel
Token - Cooperative cancellation handle. Cheap to clone;
Send + Sync. - Capabilities
- The readers compiled into this build. A listed symbology says a reader for it is included; it does not say that a given image decodes, nor how well that reader measures its geometry.
- Decoded
Content - The exact bytes, the declarations observed and the scanner’s ONE reading
of them (spec/01 § Content). Compare contents by identity (spec/01
§ Comparing contents), never by
text. - Detection
- One decoded symbol content.
- EciSegment
- One ECI designator observed in the symbol’s data (ISO/IEC 18004 §7.4.2).
It governs
raw[start..]up to the next entry’sstart, or the end; an empty span governs no byte. - Gs1Element
- One parsed
(AI, value)element string. - Iso15415
Report - ISO/IEC 15415-informed grade card — the software-measurable subset.
- IsoParameter
- One measured ISO 15415 parameter: the raw value + its grade band.
- Limits
- Anti-DoS bounds applied to every input before any pixel work.
- Occurrence
- One physical copy of a detection’s content.
- Occurrence
Geometry - What a reader measured of one symbol, in stored-pixel image coordinates — never completed, extended or reconstructed.
- Pipeline
Trace - Pipeline execution trace — why a scan succeeded or came back empty.
- Point
- A 2D point in image pixel coordinates.
- QrMeta
- QR symbol metadata.
- Saturation
- Capacities a scan reached: what it left out is unknown, not absent.
- Scan
Config - Stage-level scan configuration. Build from a profile preset, then adjust public fields as needed (the struct is non-exhaustive: presets are the only constructors). Clone-not-Copy: the axis-skip list is a collection.
- Scan
Report - The scan result — the versioned cross-boundary contract.
- Scanner
- Reusable QR scanner — configure once, scan many.
Send + Sync, no interior state: share one instance across threads freely. - Scanner
Builder - Builder for
Scanner. - Score
- Scannability score — survival ramps, structural caps and the UEC margin
cap (spec/04-score.md). Validation, NOT ISO verification (no calibrated
optics). A present score is a COMPLETE judgment: its calibration and
every planned stress cell ran, so no budget moves it — only a knee
bisection (
AxisScore::refined_failed_at) may be missing. - Stage
Trace - Per-stage pipeline trace entry.
- Structural
Report - Structural checks — computed when symbol geometry was measured.
- UecReport
- Synthetic Unused Error Correction — the real robustness margin
(
1 − 2t/d, worst RS block). Validation-grade, not ISO verification. Measured on the stream of the orientation the decode verified, only when every block error-corrects errors-only under the detection’s version, EC level and mask; a stream the S5 rescue recovered keeps its errors-only count. - Versions
- Contract version markers carried by every report.
Enums§
- Alpha
Background - Background applied under transparent pixels BEFORE luma conversion and
RGB extraction — the config side of the report’s
alphablock. A transparent asset has no one background: 0.8.x read the STORED RGB under the transparency, an exporter-dependent verdict (canvas exports store black under full transparency, image editors often white — the same visual design scored 100, 74 or “no detection” depending on which tool exported it). Config-only, never serialized; the report echoes the requested mode and the resolved background. - Alpha
Mode - The requested alpha-background handling (config echo on the wire).
- Alpha
Placement - Placement verdict spelled by the envelope’s decoded ranges.
- Charset
- How
DecodedContent::textrelates toDecodedContent::raw(spec/01 § Content). Every value exceptCharset::Unknownstates thattextis a complete decoding ofrawthat the scanner checked byte for byte; it states the encoder’s declared interpretation only whenDecodedContent::ecilists it.Unknownis the only lossy value, now and in every later version: test withCharset::is_lossy. Outside the QR familyrawis the engine’s reading, which under an ECI can omit a segment the engine could not decode; the label describesrawas published and is not downgraded for it (spec/01 § raw). - EcLevel
- QR error-correction level.
- Engine
Kind - Which decode engine produced a detection.
- Fnc1
Position - FNC1 position (ISO/IEC 18004 §7.4.8; AIM
]Q3–]Q6,]d2/]d3/]d5/]d6,]C1/]C2). - Geometry
Kind - The kind of an occurrence’s geometry (spec/01 § Occurrences).
- Grade
- Score grade bands — the published interpretation table.
- Hint
- Machine-actionable improvement hint — the generator/agent feedback loop.
- Image
Input - Borrowed image input for a scan.
- IsoGrade
- ISO 15415 letter grade (4=A … 0=F vocabulary, lowercase on the wire).
- Payload
- Classified payload of a decoded QR content string.
- Plate
Color - Recommended plate color for
Hint::AddBackgroundPlate. - Scan
Error - Errors for real faults only — “no QR found” is NOT an error.
- Scan
Profile - Named scan profiles — the public selector.
- Score
Check - A skippable score SECTION — the same integration seam as
crate::report::StressAxis-skipping, for report blocks instead of stress axes. A host that displays neither the correction margin nor the ISO parameters skips them at scan time: the wire carriesnullfor them and the section-driven hints never fire; the verdict never moves. Config-only (never serialized) — the report self-describes through the absent sections. - Score
Depth - Stress-scoring depth — how many cells each axis ramp runs.
- Score
Preset - Named axis-skip presets — the drift-proof spelling of the two canonical
integration postures, so N host surfaces cannot slowly diverge on their
hand-built skip lists. Pure sugar over
score_skip_axes(the bindings reject passing BOTH, loudly):design= a generated preview with no capture geometry (skips perspective + rotation · keeps lighting — the glare cell measures the DESIGN’s fragility, not the capture) ·capture= the full six-axis contract for photo/camera surfaces. - Stress
Axis - One stress dimension of the score contract.
- Symbology
- The barcode symbology of a detection. QR-family entries
(
QrCode·MicroQrCode·RectangularMicroQrCode) are the only ones that can carryQrMetageometry, the synthetic UEC, the ISO 15415 card and the rescue stage; every other symbology decodes content + payload classification only. - UecGrade
- ISO 15415 UEC grade bands.
Type Aliases§
- Result
- Crate-wide result alias.






