zxing-js / library

Multi-format 1D/2D barcode image processing library, usable in JavaScript ecosystem.
https://zxing-js.github.io/library/
Apache License 2.0
2.46k stars 546 forks source link

repeat decode report "Readers were able to detect the code" #575

Open RelicOfTesla opened 1 year ago

RelicOfTesla commented 1 year ago

Describe the bug repeat decode report error.

To Reproduce Steps to reproduce the behavior:

  1. select a qrcode image file, like a url qrcode-image
  2. open chrome developer console, and click xx button
  3. See error or See good qrcode result
  4. repeat click xx button again and again .

Screenshots

N: No MultiFormat Readers were able to detect the code.
    at cr.decodeInternal (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:258268)
    at cr.decodeWithState (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:257320)
    at t.BrowserMultiFormatReader.decodeBitmap (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:331917)
    at t.BrowserMultiFormatReader.decode (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:35508)
    at n (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:34933)
    at /unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:35104
    at new Promise (<anonymous>)
    at t.BrowserMultiFormatReader.decodeOnce (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:35084)
    at HTMLImageElement.imageLoadedListener (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:33775)
Promise.catch (async)
(anonymous) @ err.html:26
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
err.html:21 blob:null/906896c9-a98d-4257-980e-b0d6e8e46de7
v {text: 'a', rawBytes: Uint8Array(9), numBits: 72, resultPoints: Array(3), format: 11, …}
err.html:21 blob:null/906896c9-a98d-4257-980e-b0d6e8e46de7
N: No MultiFormat Readers were able to detect the code.
    at cr.decodeInternal (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:258268)
    at cr.decodeWithState (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:257320)
    at t.BrowserMultiFormatReader.decodeBitmap (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:331917)
    at t.BrowserMultiFormatReader.decode (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:35508)
    at n (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:34933)
    at /unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:35104
    at new Promise (<anonymous>)
    at t.BrowserMultiFormatReader.decodeOnce (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:35084)
    at HTMLImageElement.imageLoadedListener (/unpkg.com_@zxing_library@0.20.0_umd_index.min.js:1:33775)

Desktop (please complete the following information):

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script src="unpkg.com_@zxing_library@0.20.0_umd_index.min.js"></script>

<input type="file" class='fp'>
<img class="img1"  />
<button type="button" class='btn'>xx</button>

<script>

    $('.fp').change(function(){
        var fp = $('.fp');
        var f=fp[0].files[0];
        let blobURL = URL.createObjectURL(f);
        console.log(blobURL);
        $('.img1').attr('src', blobURL).data('src', blobURL);
    });

    $('.btn').click(function(){
        let blobURL = $('.img1').attr('src');
        console.log(blobURL);
        let reader = new ZXing.BrowserMultiFormatReader();
        // reader.setHints(null);
        let r = reader.decodeFromImageUrl(blobURL);
        // let r = reader.decodeFromImage($('.img1')[0]);
        r.then(console.log).catch(console.error);
    })

</script>

<style>
    .img1{
        max-width: 400px;
    }
</style>
RelicOfTesla commented 1 year ago

example qrcode, the value is "a" qrcode5

RelicOfTesla commented 1 year ago

it's work on v0.18.6, exception >= v.0.19

teckel12 commented 1 year ago

@RelicOfTesla Could this just be how you implemented the library? As I don't get have any issues with repeated scanning of the above QR code here:

https://barcode.leethost.com/

RelicOfTesla commented 1 year ago

@teckel12, Decode from static image file, don't scan from camera.

dolin-tan commented 1 year ago

@teckel12 I am also encountering the above issues now. Some IMG QR codes can be scanned, and some also report this error. IMG only has different width and height, is it due to the IMG ratio issue?

github-actions[bot] commented 5 months ago

Stale issue message