serratus / quaggaJS

An advanced barcode-scanner written in JavaScript
https://serratus.github.io/quaggaJS/
MIT License
5.02k stars 977 forks source link

"Not Detected" result on Quagga.decodeSingle #331

Open MongiSlimen opened 5 years ago

MongiSlimen commented 5 years ago

when i execute Quagga.decodeSingle() on angular 6 project the image is never detected , did i miss something ? barcode

angular json component consolereturn

JoeKahl commented 5 years ago

Try to fill out the config more. Maybe it helps.

{ size: 800, }, locator: { patchSize: 'medium', halfSample: false, }, numOfWorkers: 1, decoder: { // readers: ['ean_reader', 'code_128_reader', 'ean_8_reader', 'code_39_reader', 'code_39_vin_reader', // 'codabar_reader', 'upc_reader', 'upc_e_reader', 'i2of5_reader'], readers: ['code_39_reader'], // To have a better performance, let's just pass only one type of barcode }, locate: true, // src: '/test/fixtures/code_128/image-001.jpg' // or 'data:image/jpg;base64,' + data src: null, }

jkga commented 5 years ago

@MongiSlimen Have you already found a solution for your problem? I'm also encountering this issue on vanilla js.

 Quagga.decodeSingle({
    src: "assets/img/barcode.png",
    numOfWorkers: 1,  // Needs to be 0 when used within node
    decoder: {
        readers: ["code_128_reader","ean_reader"] // List of active readers

      },
      inputStream: {
        size: 800  // restrict input-size to be 800px in width (long-side)
    },
      locate: true,
      patchSize: 'medium',
      halfSample: false,
  }, function(result) { 
      if(result.codeResult) {
          console.log("result", result.codeResult.code);
      } else {
          console.log("not detected");
      }
  });

I used this sample barcode image in ean format. barcode2

JoeKahl commented 5 years ago

We found no solution. We dropped our plans to read bar codes. In my opinion, asking web apps to do so much is choosing the wrong platform. The desktop platform has many solid solutions for reading bar codes and image manipulation. You are the first person to contact me since I posted the issue in the fall. We also posted the issue in the spring. It has been a year and there seems to be no chance of this issue being addressed.

RobertDickey commented 5 years ago

I ended up switching to a dedicated barcode reader and taping it to the tablet. You can program them very nicely and they work well with web based apps. As Joe said, there gets to be a point where you ask too much realistically of a web app...At least at the current time. If your still needing a solution please use a dedicated scanner to decode and send to browser. Arkscan has many very affordable and easily programmable solutions.

jkga commented 5 years ago

Thanks @JoeKahl and @RobertDickey . Unfortunately, I'm working on a PWA and an external device is not an option. The good thing is I only needed to read a Code-128 in the project and got it working using streams with proper calibration. For the projects that really need a boost in performance, I agree, I should better use a dedicated scanner. Thank you for the advice

ericblade commented 5 years ago

I don't think anyone's asking too much realistically of a web app, but i think you may be asking for more realistically than you should expect from a camera barcode scanning solution in general.

Camera barcode scanning is not as reliable as a laser scanner. It's not ever going to be. A laser scanner doesn't have to do nearly as much work to get an accurate read, and it has been implemented with technology going all the way back to the 1970's, we've been doing that for 40 years. Sure there's been improvements, but it's mostly miniaturization of a technique that was pretty well perfected 30-40 years ago. Camera scanning is never going to match it. That's not what the hardware is built for, and it's almost entirely a software problem that will not likely ever match the speed or accuracy of a laser. That said, can it be good enough? It depends on your purpose. If you need to scan tons of barcodes, fast and accurately, then use a laser. If speed is not nearly as much of an issue, then optical scanning can be an acceptable solution. I don't think that it has anything to do with if it's a web app or not -- though that's not to say that Quagga or Google's incoming experimental barcode recognition system, can't be improved upon. Just saying that they'll never be as fast and accurate as the systems designed specifically for that purpose.

ezos86 commented 5 years ago

I have same issue, the entire Quagga module to me is useless in my opinion, if it can't even read a simple barcode such as this. I tried for hours and hours messing with configurations and etc. Not sure why it has so many people try to use it.

ezos86 commented 5 years ago

If there is any solution out there, be good to have. all I need is to get the number of the barcode.

ericblade commented 5 years ago

What are you trying to read? This works fine for many people.

JoeKahl commented 5 years ago

What I found is that it can only work for a small image that is almost only the bar code. Our use case is multipage documents with a bar code on one of the pages. It failed completely for our documents. I made a small image file with just a snip of our bar code and it read it successfully. We looked at quagga a year ago and then again six months later and even now other people are complaining. I think sometimes a generous person shares a library as open source, but that does not mean it gets support or improvements.

We have completely abandoned our use case. We could not find any java script library doing what we want. At least we cannot find anything for free.

{ "name": "Joe Kahl", "phone": "727-567-5780", "address": { "city": "St Pete", "state": "FL", "location": "14.BL.64" } }

From: Eric Cavazos [mailto:notifications@github.com] Sent: Wednesday, February 13, 2019 7:01 PM To: serratus/quaggaJS quaggaJS@noreply.github.com Cc: Joe Kahl Joe.Kahl@RaymondJames.com; Mention mention@noreply.github.com Subject: Re: [serratus/quaggaJS] "Not Detected" result on Quagga.decodeSingle (#331)

If there is any solution out there, be good to have. all I need is to get the number of the barcode.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_serratus_quaggaJS_issues_331-23issuecomment-2D463426607&d=DwMCaQ&c=dqndFQAGz2cg7ln6ll1EqkpBLZllP_GH8-2iqGbTww0&r=8niwtjwUzesMc_pbIuGRHX_fspGg-G1eTIXE268uPtU&m=V-ZMHFHzUOIBzFtSO5_KWCneDDeY8wR5DyluQsou-1U&s=s7rZY09rkk40IJzuc6dLXb99M2rEM8TfFjfczHu5gPs&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AAvDWz-5F-2D3NliWC2cTllnKZveJTLPIhL3ks5vNKcvgaJpZM4XH7vN&d=DwMCaQ&c=dqndFQAGz2cg7ln6ll1EqkpBLZllP_GH8-2iqGbTww0&r=8niwtjwUzesMc_pbIuGRHX_fspGg-G1eTIXE268uPtU&m=V-ZMHFHzUOIBzFtSO5_KWCneDDeY8wR5DyluQsou-1U&s=IWGNrpPvK8UjSN8kwU2InJshAg0KIL6RayjjJdmuO48&e=.

ericblade commented 5 years ago

hey @JoeKahl not sure if you intended to blast your phone number out into public, but you did :-)

I've always used the auto-locate to fairly decent success, but i'm also trying it now with auto locate off, and that seems to be working well for use of camera-based live scanning.

Thanks for the link to the other lib, that's cool . . sadly, doesn't seem like either of these libs are getting much in the way of updates.

siddharthsingh22 commented 3 years ago

I don't have much knowledge about the types of bar codes so I added all the available readers in Quagga. It worked. The config looks like this { src: "imageName.jpg", numOfWorkers: 0, inputStream: { type : "ImageStream", size: 800 }, locate : true, 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 commented 3 years ago

@siddharthsingh22 you might want to note the type of barcode returned from the decoder, and then limit your readers to just that, for better efficiency

Thepaiarr commented 2 years ago

i have same problem but actually you can add area to you barcode like this i think quagga can't read barcode image is it justify border Sorry for my broken English I Hope tis help you somebody

128bar-900

ericblade commented 2 years ago

are you adding area around it programatically? care to share sample code?

Thepaiarr commented 2 years ago

are you adding area around it programatically? care to share sample code?

You can used Canvas toadd space around image and get picture from canvas Before use Quagga This my Code draw

i use Reactjs

JS const canvas = document.getElementById("tools_sketch"); // document.getElementById("tools_sketch").src = 'data:image/jpg;base64,' + list[0].image; const img = document.getElementById("img1"); const ctx = canvas.getContext("2d") const image = new Image(); // // console.log(img.width + ' ' + img.height) // // console.log(width + ' ' + height) canvas.width = img.width + 40; canvas.height = img.height + 40; image.onload = function () { ctx.imageSmoothingEnabled = true; // ctx.drawImage(image, 0, 0, 312, 100, 20, 20, img.width, img.height); ctx.beginPath(); ctx.rect(0, 0, img.width+40, img.height+40); ctx.fillStyle = 'white'; ctx.fill(); ctx.drawImage(image, 20, 20, img.width, img.height);//, 10, 10, width, height); // ctx.drawImage(image, 0, 0, widthResize, heightResize, 10, 10, width, height); // ctx.drawImage(image, 0, 0, width, height, 10, 10, width, height); // ctx.font = "40px Courier" // ctx.fillText(this.props.text, 210, 75) // ctx.imageSmoothingEnabled = false; } image.src = 'data:image/jpg;base64,' + list[0].image canvas.toDataURL();

BODY

<canvas id="tools_sketch" style={{ width: "500", height: "500", border: "1px solid #000000", position: 'relative' ,backgroundColor:"White"}}

Sorry, your browser doesn't support the <canvas> element.

ericblade commented 2 years ago

ah, i was under the impression that you were figuring out the area from the quagga box detection, then adding around that. It's an interesting idea that I've been wanting to try, but I just don't have time to mess with that stuff these days.