pub struct Scanner { /* private fields */ }Expand description
Image scanner that can find barcodes in 2D images
§Example
use zedbar::config::*;
use zedbar::{Scanner, DecoderConfig, Image};
// Create scanner with type-safe configuration
let config = DecoderConfig::new()
.enable(Ean13)
.enable(QrCode)
.position_tracking(true)
.scan_density(1, 1);
let mut scanner = Scanner::with_config(config);
// Scan an image
let data = vec![0u8; 640 * 480];
let mut image = Image::from_gray(&data, 640, 480).unwrap();
let result = scanner.scan(&mut image);Implementations§
Source§impl Scanner
impl Scanner
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new image scanner with every supported symbology enabled.
Equivalent to Scanner::with_config(DecoderConfig::all()). Convenient
for exploratory use; for production use, prefer
Scanner::with_config() with a
DecoderConfig::new() that opts into only the
symbologies you actually need.
Sourcepub fn with_config(config: DecoderConfig) -> Self
pub fn with_config(config: DecoderConfig) -> Self
Create a new image scanner with custom configuration
This is the recommended way to create a scanner with specific settings.
§Example
use zedbar::config::*;
use zedbar::{Scanner, DecoderConfig};
let config = DecoderConfig::new()
.enable(Ean13)
.enable(Code39)
.set_length_limits(Code39, 4, 20)
.position_tracking(true);
let scanner = Scanner::with_config(config);Sourcepub fn scan(&mut self, image: &mut Image) -> ScanResult
pub fn scan(&mut self, image: &mut Image) -> ScanResult
Scan an image for barcodes
Returns a ScanResult containing decoded symbols and any
undecoded QR finder regions. Check ScanResult::finder_regions()
to find areas that may contain QR codes too small to decode at
the current resolution.
When DecoderConfig::retry_undecoded_regions is enabled, each
undecoded finder region is automatically cropped, upscaled, and
re-scanned. Only QR and SQ codes are taken from those re-scans — the
regions come from QR finder patterns, and a linear symbology gains
nothing from upscaling a fragment it already saw at full resolution.
Recovered symbols have their coordinates mapped back to the original
image frame.