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

Returning different results for same barcode? #436

Open
kunal3210 opened this issue Jun 1, 2020 · 4 comments
Open

Returning different results for same barcode? #436

kunal3210 opened this issue Jun 1, 2020 · 4 comments

Comments

@kunal3210
Copy link

kunal3210 commented Jun 1, 2020

Why is it returning different results for same barcode.I really don't understand the reason behind it.

Here is an image of different results i have only scanned one barcode and have got many different values.

barcode console

And here's my code

var jquery = document.createElement('script');
jquery.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js';
document.head.appendChild(jquery);
$.getScript("dist/quagga.js",function(){
$(document).ready(function(){
if (navigator.mediaDevices && typeof navigator.mediaDevices.getUserMedia === 'function') {
  Quagga.init({
    inputStream : {
      name : "Live",
      type : "LiveStream",
      target: document.querySelector('#barcode_scanner')    // Or '#yourElement' (optional)
    },
    decoder : {
      readers : ["ean_reader","ean_8_reader","code_39_reader","code_39_vin_reader","codabar_reader","upc_reader","upc_e_reader","i2of5_reader","2of5_reader","code_93_reader"]
    }, 
  },
     function(err) {
      if (err) {
          console.log(err);
          return
      }
      console.log("Initialization finished. Ready to start");
      Quagga.start();
  });

  /*
   Quagga.onProcessed(function(result) {
        var drawingCtx = Quagga.canvas.ctx.overlay,
            drawingCanvas = Quagga.canvas.dom.overlay;

        if (result) {
            if (result.boxes) {
                drawingCtx.clearRect(0, 0, parseInt(drawingCanvas.getAttribute("width")), parseInt(drawingCanvas.getAttribute("height")));
                result.boxes.filter(function (box) {
                    return box !== result.box;
                }).forEach(function (box) {
                    Quagga.ImageDebug.drawPath(box, {x: 0, y: 1}, drawingCtx, {color: "green", lineWidth: 2});
                });
            }

            if (result.box) {
                Quagga.ImageDebug.drawPath(result.box, {x: 0, y: 1}, drawingCtx, {color: "#00F", lineWidth: 2});
            }

            if (result.codeResult && result.codeResult.code) {
                Quagga.ImageDebug.drawPath(result.line, {x: 'x', y: 'y'}, drawingCtx, {color: 'red', lineWidth: 3});
            }
        }
    });
*/

  Quagga.onDetected(function(data){
  	var result = data.codeResult.code;
  	console.log(result);
  	  	$.ajax({
  		url : 'quagga.php',
  		type : 'post',
  		data :{result : result},
  	});
  });
 }
});
});

Please tell me what to do next.

@FFParf
Copy link

FFParf commented Jul 13, 2020

I have the same problem

@ericblade
Copy link
Collaborator

ericblade commented Jul 13, 2020

Check the errors result, and/or validate that the barcode scanned is valid, before passing it on. Especially from a LiveStream, your input image may have significant differences between scans, maybe your autofocus hardware/software is figuring it out at the same time the reader is scanning, the position is different, etc. It's going to be a lot more stable if you feed it the identical image repeatedly.

@kunal3210
Copy link
Author

@ericblade Thanks for your reply, i solved it by mentioning all the possible parameters for readers as

 decoder : {
      readers : ["code_128_reader","ean_reader","ean_8_reader","code_39_reader","code_39_vin_reader","codabar_reader","upc_reader","upc_e_reader","i2of5_reader","2of5_reader","code_93_reader"]
    }, 

@ericblade
Copy link
Collaborator

Probably not a good idea to have ALL of the barcode readers, but hey, if it works, go for it

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

3 participants