Skip to main content

Scanner

Struct Scanner 

Source
pub struct Scanner { /* private fields */ }
Available on crate feature scan only.
Expand description

Reads barcodes out of images.

§Examples

use smart_package_tracker::scan::{GrayImage, Scanner};

let image = GrayImage::from_luma(width, 40, luma)?;
let found = Scanner::new().scan(&image)?;

assert_eq!(found.payload(), "PKG-9ED9285C");

Implementations§

Source§

impl Scanner

Source

pub fn new() -> Self

A scanner with default settings.

Source

pub fn max_scan_lines(self, lines: u32) -> Self

How many scan lines to try along each axis.

Raising this helps when the barcode occupies a small part of a large image; lowering it bounds the work done before giving up. Zero is treated as one.

Source

pub fn scan(&self, image: &GrayImage) -> Result<Scan>

Read any barcode this crate can decode out of image.

Code 128 is currently the only symbology this crate can decode, so this is a shorthand for scan_with. It stays a separate method because it is where any future symbology gets tried without callers changing.

§Errors

Returns Error::NoSymbolFound if no scan line yields a valid symbol. A barcode that is present but unreadable is indistinguishable from one that is absent, so there is only the one error.

Source

pub fn scan_with<D: Decoder + ?Sized>( &self, decoder: &D, image: &GrayImage, ) -> Result<Scan>

Read a barcode of one specific symbology out of image.

§Errors

Returns Error::NoSymbolFound if no scan line yields a valid symbol, or Error::Decode if the symbology has no scan-line structure — matrix symbologies such as QR cannot be read this way.

Trait Implementations§

Source§

impl Clone for Scanner

Source§

fn clone(&self) -> Scanner

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Scanner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Scanner

Source§

fn default() -> Self

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

impl Eq for Scanner

Source§

impl PartialEq for Scanner

Source§

fn eq(&self, other: &Scanner) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Scanner

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.