EddieLa / JOB

A Barcode scanner capapable of reading Code128, Code93, Code39, Standard/Industrial 2 of 5, Interleaved 2 of 5, Codabar and EAN-13 barcodes in javascript.
http://eddiela.github.io/JOB
600 stars 204 forks source link

Not working when barcode is part of image #16

Closed leirn closed 9 years ago

leirn commented 10 years ago

With the three samples below, BarcodeReader only works with the first one. The two others failed. While I was expected that for the third one, I am surprised for the second one.

Note that the three are detected correctly by this online decoder : http://online-barcode-reader.inliteresearch.com/

Can it evolve to work with the three cases ?

pic3 pic2 pic

leirn commented 10 years ago

After several tests, it works for the second image using EAN13Speed: false.

It still fails for the third image above. I am using the code : DecodeWorker.postMessage({ImageData: ctx.getImageData(0,0,Canvas.width,Canvas.height).data, Width: Canvas.width, Height: Canvas.height, cmd: "normal", DecodeNr:1, Decode: ["EAN-13"], Ean13Speed:false});

Canvas has the size of the image.

It even works for image below. pic4

EddieLa commented 10 years ago

Yeah with Ean13Speed on it's less accurate so that's no surprise as for why it doesn't work for the third image I actually know the reason.

It's because of a little defect in the search algorithm I haven't been able to correct, the defect makes it impossible to detect barcodes in the lowest 10 or 5% of the image. So since the third image has a great height and the barcode is at the bottom it won't work.

leirn commented 10 years ago

Thank your for this rapid answer.

I am trying to find a way to make it work anyway. If it is because the barcode is to close to the bottom of the image, why not increase the canva size with something like that :

Canvas.width=Math.floor($("#picture").width() * 1.2); Canvas.height=Math.floor($("#picture").height() * 1.2); // to avoid the issue where it cant find bar in 10% bottom of image ctx.fillStyle="#FFFFFF"; ctx.fillRect(0,0,Canvas.width,Canvas.height); ctx.drawImage(showPicture,0,0,$("#picture").width(),$("#picture").height());

Unfortunatly it's worst. It still works with the 2 smaller one, break the fourth one and still not works with the third one.

Should we make it work, it could be worth including the hack directly in your file ?

BobbyJay commented 9 years ago

Hi,

I also experienced problems with "real world" mobile device photos of barcodes (EAN-13).

foto 14 08 14 11 36 16

The problems seems to be, that the print on this battery is the same color/contrast as the barcode. If I place the barcode on the edge, so the print on the right is not visible anymore, the decoding works.

EddieLa commented 9 years ago

Yep, it's because of the search algorithm. Tested it with a new algorithm I've been working on and it was no problem. The current one isn't that great, can't find barcodes around the lower 1/8 or 1/10 of the picture for example.

BobbyJay commented 9 years ago

@EddieLa I already took a deeper look into your algorithm and tried to understand it in detail. Is there a communication channel (E-Mail, etc.) where I can ask you some questions about it? For my master's thesis I am analyzing some algorithms. A little help would be awesome :)

EddieLa commented 9 years ago

Sure I can try to answer some questions depending on available time, just send an email to eddie.larsson245@gmail.com and I'll try to answer as fast as possible.

tedde commented 9 years ago

@EddieLa when do you plan to release the library with the new search algorithm? I'm experiencing the issue with failing to find barcode in real world images as posted by @BobbyJay

EddieLa commented 9 years ago

Hard to say, it all depends on if I actually can make it faster without sacrificing too much accuracy. Right now it's intolerably slow.

tedde commented 9 years ago

I see @EddieLa . Could you please describe how the library works at the moment, and the new search algorithm? Conceptually that is! (I'm having a hard time understanding the source code)