mebjas / html5-qrcode

A cross platform HTML5 QR code reader. See end to end implementation at: https://scanapp.org
https://qrcode.minhazav.dev
Apache License 2.0
4.71k stars 938 forks source link

PDF417 codes does not work #499

Open omerbhutta opened 2 years ago

omerbhutta commented 2 years ago

I am trying to integrate HTML bar code version and you mention in the documentation that the script has functionality to scan PDF417 but it didn't.

===================== Code that i am using

function docReady(fn) { if (document.readyState === "complete" || document.readyState === "interactive") { setTimeout(fn, 1); } else { document.addEventListener("DOMContentLoaded", fn); } }

    docReady(function () {
        var resultContainer = document.getElementById('qr-reader-results');
        var lastResult, countResults = 0;
        function onScanSuccess(decodedText, decodedResult) {
            if (decodedText !== lastResult) {
                ++countResults;
                lastResult = decodedText;
                console.log(`Scan result ${decodedText}`, decodedResult);
            }
        }

        const formatsToSupport = [Html5QrcodeSupportedFormats.PDF_417];

        const html5QrcodeScanner = new Html5QrcodeScanner(
                "qr-reader",
                {
                    fps: 10,
                    qrbox: {width: 250, height: 250},
                    formatsToSupport: formatsToSupport
                },
                /* verbose= */ false);
        html5QrcodeScanner.render(onScanSuccess);
    });

    function onScanSuccess(decodedText, decodedResult) {
        console.log(`Code matched = ${decodedText}`, decodedResult);
    }

====================

ROBERT-MCDOWELL commented 2 years ago

OS and browser version, error message if any

omerbhutta commented 2 years ago

It only shows that QR code format is not supported.

rlyle commented 1 year ago

Same issue here too.. unable to scan PDF_417 in chrome Version 103.0.5060.114 (Official Build) (64-bit)

My code...

import React from 'react';
import { Html5Qrcode, Html5QrcodeSupportedFormats } from 'html5-qrcode';

export class BarCodeScanner extends React.Component {
    componentDidMount() {
        Html5Qrcode.getCameras().then((devices) => {
            console.log("Found devices:", devices );
            if ( devices.length > 0 ) {
                this.cameraId = devices[0].id;
                this.scanner = new Html5Qrcode('scanner',{ 
                    verbose: true, 
                    formatsToSupport: [ Html5QrcodeSupportedFormats.PDF_417 ], 
                    experimentalFeatures: { useBarCodeDetectorIfSupported: false } 
                });
                this.scanner.start( this.cameraId, { fps: 10 },
                    (decodedText, decodedResult) => {
                        console.log('decodedText:', decodedText );
                        console.log('decodedResult:', decodedResult );
                    },
                    (err) => {
                        console.error("decode error:", err );
                    }
                ).catch((err) => {
                    console.error("Failed to start decoder:", err );
                })
            } else {
                console.error("Failed to find any camera devices!");
            }
        })
    }

    componentWillUnmount() {
        if ( this.scanner ) {
            this.scanner.stop();
        }
    }

    render() {
        return <div id='scanner' style={{width: '100%'}}>
        </div>
    }
}

export default BarCodeScanner;
ROBERT-MCDOWELL commented 1 year ago

change to experimentalFeatures: { useBarCodeDetectorIfSupported: true}

rlyle commented 1 year ago

I had already tried it both true and false, no difference. Matter of fact, when I posted my code sample originally it was true, then I thought you guys would tell me to set it to false, so tried that as well, no difference.

ROBERT-MCDOWELL commented 1 year ago

useBarCodeDetectorIfSupported to true means the standard javascript API engine is taking the relay. if this is not working, so it surely comes from the barcode you are scanning. is the same barcode you are using for test works with other online scanner?

rlyle commented 1 year ago

Yes, just testing with my own DL. The BlinkID PDF_417 scanner worked, but their pricing for a license was through the roof. I noticed this project uses the ZXing library, which I've also tested and it didn't work either. In fact, their own online demo doesn't even manage to scan their test images for PDF_417 either. (see https://zxing-js.github.io/library/examples/pdf417-image/)

So this might be a bug in the underlying ZXing library.

1898182 commented 1 year ago

I have the same issue with PDF_417. I am not able to scan with Chrome Version 109.0.5414.75 and Edge Version 109.0.1518.52 on Windows 11

gabrielsolomon commented 1 year ago

I have noticed that for PDF417 orientation matters. It seems to detect them only in certain orientation (horizontal)

chupetoide commented 1 year ago

same issue here testing with Chrome Version 110.0.5481.177 (Official Build) (x86_64) on MacOS.

pkasidit commented 6 months ago

I have the same issue with Chrome Version 120.0.6099.129 (Official Build) (arm64) on MacOS.