Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scan image fail #495

Open
leosteven2018 opened this issue Apr 21, 2023 · 5 comments
Open

scan image fail #495

leosteven2018 opened this issue Apr 21, 2023 · 5 comments

Comments

@leosteven2018
Copy link

Hi, I have research quagga for a few day, I try to use JsBarcode to create the barcode and use Quagga to scan it in image type and liveStream type. But sometime I cannot scan and find out the result code in image type.
For example, I created the barcode with the string "1234", I can get the code when I use liveStream, but fail with the base64 url maked from canvas.toDataURL(), also the downloaded image. I tried many code, "12345678", "201108040076", "201243219876", only some of those success.
In fact, when I change the fontsize/text margin/margin of the barcode, the accuracy rate could be imporved but it is still affected by many things such as space. Would you like to tell me what are the reasons affect the accuracy rate or how to improve it?

Thanks!

@github-actions
Copy link

Thank you for filing an issue! Please be patient. :-)

@ericblade
Copy link
Owner

If you're using locate: true (i believe that's the default) and not setting an area to scan in specifically, the biggest problem I've run into while scanning retail barcodes is the amount of space around the barcode. If there's other images or text, or other barcodes very close to the barcode trying to be located, location will often fail.

It would be helpful to get some of the images and their corresponding dataURL if possible, since it seems like one is failing?

@leosteven2018
Copy link
Author

leosteven2018 commented Apr 21, 2023

I used Quagga.decodeSingle() to scan the image file. Here is the code follow as:

// Function to create the BarCode
createCode() {
    JsBarcode("#barcode", this.inputValue, {
        format: "CODE128",
        fontSize: 40,
        // textMargin: 25,
        // margin: 50
    });
},

// Function to scan the BarCode
scanCode() {
    let target = document.getElementById('barcode');
    let url = target.toDataURL();
    Quagga.decodeSingle({
        decoder: {
            readers: ["code_128_reader"]
        },
        locate: true,
        src: url  // base64 png
        // src: './download.png' // download via <a></a>
    }, (res) => {
        if (!res) {
            return false;
        }
        if (res.codeResult) {
            console.log(res.codeResult)
        } else {
            console.log('Recognize fail')
        }
    })
}

download
code2
code2
code3

Those images is clear to be scanned, but I just only scan successful for the second and the fourth images, did I have something miss in the configuration?

By the way, I used margin: 50 in createCode() and download two images:
0421_1
0421_2
one is "1526 8594", and it is successful, the other one "15268594" is fail. How can I control it?

@ericblade
Copy link
Owner

I don't know how long it'll take me to pull these and check them out, but my guess is that having a larger margin on top and bottom from any other things would help. If these labels are printed along with any other text/images/something

Of course, image based scanning is inherently less reliable than laser scanning, and I've never made any claims that Quagga is problem free :-D BUT most of the problems that people have reported were usually able to be handled with some adjustments to settings or images...

anyway, i'll get back to you when i can :) if you find any further info, please add it

@leosteven2018
Copy link
Author

Thanks!
As you say, laser scanning is more reliable when I use the external camera, I can scan those images with the
suitable angle successful even thought they fail in decodeSingle().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants