Quagga doesn't locate or decode barcodes
Asked Answered
A

1

6

I'm trying to make a barcode scanner with Quagga. But I can only see the live version of the webcam, but it doesn't recognize any (code 128) barcode. (The snippet doesn't show the webcam on stackoverflow.)

I think that I'm missing a step, but hope someone here can push me in the right direction.

Quagga.init({
		inputStream : {
		  name : "Live",
		  type : "LiveStream",
		  target: document.querySelector('#scanblock')
		},
		decoder : {
		  readers : ["code_128_reader"]
		}
	  }, function(err) {
		  if (err) {
			  console.log(err);
			  return
		  }
		  console.log("Initialization finished. Ready to start");
		  Quagga.start();
	  });
<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://serratus.github.io/quaggaJS/examples/js/quagga.min.js" type="text/javascript"></script>
  </head>
  <body>
    <header style="text-align: center; margin-top:3%;">
      <h3>Barcode Scanner</h3>
      <hr/>
    </header>
    <div style="text-align: center; margin-top: 6%;">
      <div id="scanblock"></div>
    </div>
  </body>
</html>
Autodidact answered 2/6, 2017 at 12:41 Comment(5)
I did a fairly large barcode implementation and used both QuaggaJS and ZXing. Have you tried the other possible barcode values (ean_reader, upc_reader, etc.) to ensure that it's not just an issue with the code_128 you're trying to scan? If that's not it, is it actually outlining the barcode on the screen?Countenance
Thanks for your reply, other barcodes won't work aswell. And no, it does'nt outline the barcode. It does only show the live webcam.Autodidact
Are there any errors in your console?Countenance
Nope, the only thing displayed in the console is the "Initialization finished. Ready to start". I think that I'm missing a part of the code, but not sure about what part.Autodidact
you need to implement Quagga.onProcessed and Quagga.onDetectedAstronomy
A
0

Jymbo is correct. You must also implement .onProcessed() and .onDetected(). I recommend executing.stop() when onDetected returns a result. Otherwise it will continue to process and detect -- forever.

In case you hadn't figured it out, it only detects instances of the reader defined on decoder.

Allowed answered 22/8, 2019 at 22:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.