Implementing quagga scan barcodes

I am making an online crawl application with HTML5 and javascript only using Quagga.js.

I need the webcam to work for searching barcodes and imported quagga.js:

On the quagga web page, you will find the Quagga.init method. to initialize the webcam view. I entered this code in the script tag:

Quagga.init({
    inputStream : {
      name : "Live",
      type : "LiveStream"
    },
    decoder : {
      readers : ["code_128_reader"]
    }
  }, function() {
      console.log("Initialization finished. Ready to start");
      Quagga.start();
  });

But nothing happened. What do I need to do to get this webcam working? Any other opinions on creating a barcode scanning web application?

Thanks for answering!

+4
source share
4 answers

Include <div id="interactive" class="viewport"></div>in your markup.

+3
source

, . , QuaggaJS, :

<div id="interactive" class="viewport">
    <video autoplay="true" preload="auto"></video>
</div>
+2

?

"Livestream" ( ) SSL-.
"s" https://

: https://support.google.com/adwords/answer/2580401?hl=sv

, SSL, . .

+1

div:

: target: document.querySelector('# barcode_canvas')

          Quagga.init({
              inputStream : {
                name : 'Live',
                type : 'LiveStream',
                target: document.querySelector('#barcode_canvas')
              },
              decoder : {
                readers : ['ean_reader']
              }
            }, function(err) {
                if (err) {
                    console.log(err);
                    return
                }
                console.log('Initialization finished. Ready to start');
                Quagga.start();                     
            }); 
0

All Articles