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

My image is not detected #336

Open
YeisonVelez11 opened this issue Oct 12, 2018 · 8 comments
Open

My image is not detected #336

YeisonVelez11 opened this issue Oct 12, 2018 · 8 comments

Comments

@YeisonVelez11
Copy link

Hi friends, I congratulate you on this amazing plugin. In my case it does not work with any of the 2 images I have. What can I do to detect them?

`
var Quagga = require('quagga').default;

    Quagga.decodeSingle({
        src: "20181010_084927.jpg",
        numOfWorkers: 0,  // Needs to be 0 when used within node

        decoder: {
            readers: ["code_128_reader"] // List of active readers
        },
    }, function(result) {
        console.log(result)
        if(result.codeResult) {
            console.log("result", result.codeResult.code);
        } else {
            console.log("not detected");
        }
    });

`

baaaaar
code128

@hcrufio88
Copy link

have you ever fix this problem?

@ericblade
Copy link
Collaborator

I can say without a doubt that the second one in this sample is due to lack of whitespace -- adding a 25px whitespace around it should fix it.

That said, I'm not good enough to be able to determine what format a barcode is in by just looking at it, but it's my assumption that the first one is either failing due to the same reason -- needs more whitespace, or failing because it's not code128 format.

@hcrufio88 probably could use more information about your configuration and samples to determine what's failing for you

@hcrufio88
Copy link

Thanks I really appreciate your work. I fix the previous issue and the function works fine.
Now I have another problem.
WHY this code ends always with the same code?!?
if I scan only a code it works, but in a for or forEach loop it gives me always one code for all.

const Quagga = require('quagga').default;

const idPratiche = [];


const filedir = [
  './temp/crop-0.jpg',
  './temp/crop-1.jpg',
  './temp/crop-2.jpg',
  './temp/crop-3.jpg'
]

filedir.forEach(function(file){
  Quagga.decodeSingle({
      src: file,
      numOfWorkers: 0,
      locate:true,
      locator:{patchSize:"large",halfSample:true},  // Needs to be 0 when used within node
      inputStream: {
          size: 800  // restrict input-size to be 800px in width (long-side)
      },
      decoder: {
          readers: ["ean_reader"] // List of active readers
      },
  }, function(result) {
   if(result.codeResult) {
  console.log(result.codeResult.code);
        let res = +(result.codeResult.code.substring(6, 12));
        let id = {fileName:file,id:res}
          idPratiche.push(id);
          console.log(idPratiche);
      } else {
        let id = {fileName:file,id:"not detected"}
          idPratiche.push(id);
      }
  });
});

Schermata 2020-04-20 alle 14 18 22

@ericblade
Copy link
Collaborator

Decoding in parallel does not work here. I am trying to fix that here ericblade/quagga2#171

I could definitely use some additional eyes and tests on how well that works, if it works correctly.

@hcrufio88
Copy link

I try to use quagga 2 but I can't make it work.

const Quagga = require('@ericblade/quagga2').default;

let path= "./crop-0.jpg"

Quagga.decodeSingle({
    src: path,
    numOfWorkers: 0,
    locate:true,
    locator:{patchSize:"large",halfSample:true},  // Needs to be 0 when used within node
    inputStream: {
        size: 800  // restrict input-size to be 800px in width (long-side)
    },
    decoder: {
        readers: ["ean_reader"] // List of active readers
    },
}, function(result) {
    if(result.codeResult) {
      var res = +(result.codeResult.code.substring(6, 12));
      var id = {fileName:path,id:res}
        console.log(id);
    } else {
        console.log("not detected");
    }
});

the result of that in node 12.16.1 is:
Schermata 2020-04-21 alle 20 54 00

I only install the nom package with

npm install --save @ericblade/quagga2

@ericblade
Copy link
Collaborator

it seems i have somehow 'fixed' it so that it should be just require('@ericblade/quagga2') rather than require(...).default .. that wasn't intentional, but i'm not sure what change did it, right off..

@ericblade
Copy link
Collaborator

you'd also have to use a custom built one with that pull request, until i'm comfortable releasing that patch, which might take a little while, because it makes a lot of internal changes that need to be run out in real use for a while i think

@hcrufio88
Copy link

  1. in the previous post i just wanted to try quagga2 from npm and it don't work with the .default require, now I try another time without .default and it worked! I suggest to change the readme on npmjs because it says to use the .default require and it's wrong.
  2. I builded the dev branch and try to do the parallel decode and it worked!! thanks man really nice work with that!!

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