Skip to main content

Scanner

Struct Scanner 

Source
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

Source

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.

Source

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);
Source

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.

Trait Implementations§

Source§

impl Default for Scanner

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V