[−][src]Function rqrr::find_and_decode_from_func
pub fn find_and_decode_from_func<F>(
width: usize,
height: usize,
fill: F
) -> Vec<Code> where
F: FnMut(usize, usize) -> u8,
Find QR-Codes and decode them
This method expects to be given an image of dimension width
* height
. The data is supplied
via the fill
function. The fill function will be called width coordinates x, y
, where x
ranges from 0 to width
and y
from 0 to height
. The return value is expected to correspond
with the greyscale value of the image to decode, 0 being black, 255 being white.
Returns
Returns a collection of all QR-Codes that have been found. They are already decoded and contain some extra metadata like position in the image as well as information about the used QR code itself
Panics
Panics if width * height
would overflow.
Examples
use image; use rqrr; let img = image::open("tests/data/github.gif").unwrap().to_luma(); let w = img.width() as usize; let h = img.height() as usize; let codes = rqrr::find_and_decode_from_func(w, h, |x, y| img.get_pixel(x as u32, y as u32).data[0]); assert_eq!(codes.len(), 1); assert_eq!(codes[0].val, "https://github.com/WanzenBug/rqrr");