pub struct FinderRegion {
pub x: u32,
pub y: u32,
pub width: u32,
pub height: u32,
}Expand description
A region where QR finder patterns were detected but decoding failed.
The bounding box describes the area in the original image where finder pattern lines were found. To attempt decoding, crop the image to this region (with padding for the quiet zone) and upscale before re-scanning.
§Example
let result = scanner.scan(&mut image);
if let Some(region) = result.finder_region() {
let pad = region.width.max(region.height) / 2;
let x = region.x.saturating_sub(pad);
let y = region.y.saturating_sub(pad);
let w = (region.width + 2 * pad).min(image.width() - x);
let h = (region.height + 2 * pad).min(image.height() - y);
if let Some(cropped) = image.crop(x, y, w, h) {
if let Some(mut upscaled) = cropped.upscale(4) {
let retry = scanner.scan(&mut upscaled);
for symbol in retry.symbols() {
println!("Recovered: {}", symbol.data_string().unwrap_or(""));
}
}
}
}Fields§
§x: u32X coordinate of the top-left corner (pixels).
y: u32Y coordinate of the top-left corner (pixels).
width: u32Width of the bounding box (pixels).
height: u32Height of the bounding box (pixels).
Trait Implementations§
Source§impl Clone for FinderRegion
impl Clone for FinderRegion
Source§fn clone(&self) -> FinderRegion
fn clone(&self) -> FinderRegion
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FinderRegion
impl Debug for FinderRegion
Source§impl PartialEq for FinderRegion
impl PartialEq for FinderRegion
impl Copy for FinderRegion
impl Eq for FinderRegion
impl StructuralPartialEq for FinderRegion
Auto Trait Implementations§
impl Freeze for FinderRegion
impl RefUnwindSafe for FinderRegion
impl Send for FinderRegion
impl Sync for FinderRegion
impl Unpin for FinderRegion
impl UnsafeUnpin for FinderRegion
impl UnwindSafe for FinderRegion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more