pub struct Scanner { /* private fields */ }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
impl Scanner
Sourcepub fn max_scan_lines(self, lines: u32) -> Self
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.
Sourcepub fn scan(&self, image: &GrayImage) -> Result<Scan>
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.
Sourcepub fn scan_with<D: Decoder + ?Sized>(
&self,
decoder: &D,
image: &GrayImage,
) -> Result<Scan>
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.