Git Product home page Git Product logo

Comments (2)

hschimke avatar hschimke commented on August 16, 2024 1

I think you have two options:

  1. The detect_multiple_in_luma function. In order to use that you will need to convert the RGB data to luminosity. An example of how this is done from an array of RGB data is available in the rxing-wasm crate, but keep in mind that this example is specifically designed to work with JavaScript RGBA values, and may not apply to what you are using. This might not be exactly what you want, though, since you already seem to be using the Image create to pull the image out of the memory buffer. That leads us to the second option.
  2. Skip using the helper functions and create your barcode decoder yourself. The helper functions are just a wrapper around the library’s core structs and traits. You can look at the code for the helper functions to see how they are doing it.
    let img = image::open(file_name)
        .map_err(|e| Exceptions::runtime_with(format!("couldn't read {file_name}: {e}")))?;
    let multi_format_reader = MultiUseMultiFormatReader::default();
    let mut scanner = GenericMultipleBarcodeReader::new(multi_format_reader);

    hints
        .entry(DecodeHintType::TRY_HARDER)
        .or_insert(DecodeHintValue::TryHarder(true));

    scanner.decode_multiple_with_hints(
        &mut BinaryBitmap::new(HybridBinarizer::new(BufferedImageLuminanceSource::new(img))),
        hints,
    )

So in this case you can see that you have an image already, so you should be able to skip the helper functions and access the library directly. This would be my preferred solution in your case, as it gives you more options on how you work with the library.
Another point, above you can see that we create a MultiUseMultiFormatReader which is the type of reader used when you intend to use the reader over and over again, so you would create that reader outside of your frame handling loop, and then call the decode_multiple_with_hints function of it inside the loop to decode the barcodes. Also note that the you had picked the “detect multiple” option, which is why I used the code for that, if you only think there is one barcode per image then you would use slightly different (and faster) code.

Feel free to reach out again if you have more questions.

from rxing.

hschimke avatar hschimke commented on August 16, 2024

Closing for now, please re-open if you need additional help.

from rxing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.