piderman314 / bardecoder

Detect and decode QR Codes, written in 100% Rust.
MIT License
275 stars 34 forks source link

Could not decode QR generate from fast_qr example #53

Open harrystb opened 1 year ago

harrystb commented 1 year ago

Used the example code:

this is bin/decode.rs

fn main() {
    let img = image::open("in.png").unwrap();
    let decoder = bardecoder::default_decoder();
    let results = decoder.decode(&img);
    for result in results {
        println!("{}", result.unwrap());
    }
}

It should decode to https://example.com

I get the error:

thread 'main' panicked at src\bin\decode.rs:6:31:
called `Result::unwrap()` on an `Err` value: Error decoding QR Code: Could not calculate error distances

Here is the QR code. in

QR code was generated using fast_qr library with the following code:

use fast_qr::convert::ConvertError;
use fast_qr::convert::{svg::SvgBuilder, Builder, Shape};
use fast_qr::qr::QRBuilder;

fn main() -> Result<(), ConvertError> {
    let qrcode = QRBuilder::new("https://example.com/").build().unwrap();

    let _svg = SvgBuilder::default()
        .shape(Shape::Square)
        .to_file(&qrcode, "out.svg");

    Ok(())
}

Then I took a screenshot of the SVG as my method to make it into a PNG file.