mchehab / zbar

ZBar is an open source software suite for reading bar codes from various sources, including webcams. As its development stopped in 2012, I took the task of keeping it updated with the V4L2 API. This is the main repository for it. There's a clone at at LinuxTV.org, and another one at gitlab.
https://linuxtv.org/downloads/zbar/
GNU Lesser General Public License v2.1
1.01k stars 205 forks source link

PDF417 decoding is incomplete #3

Open Naahuel opened 5 years ago

Naahuel commented 5 years ago

Hello!

I am attempting to make a PDF417 barcode reader for the web using Web Assembly (there's a few out there but the only reliable one is licenced). The idea is simple, just build a binary file with C code that can be called via JavaScript.

I followed this guide which got me almost there! I had to add --enable-codes=pdf417 as a parameter to configure to enable PDF417 symbols and disable all the others I'm not interested in.

The code actually works amazingly well for any other type of symbol (see demo) but if I compile ZBar to accept PDF417, it detects it but throws a warning:

WARNING: zbar/decoder/pdf417.c:73: pdf417_decode8: Assertion "clst >= 0 && clst < 9" failed.
dir=0 sig=5a44 k=9 buf[0000]=

WARNING: zbar/decoder/pdf417.c:89: pdf417_decode8: Assertion "g[0] >= 0 && g[1] >= 0 && g[2] >= 0" failed.
dir=1 sig=ca03 k=6 g0=ffffffff g1=e71 g2=585 buf[0000]=

And of course, no decoding is done. Those assertions are on lines 71 and 86 of ZBar.

You can see all the code I'm using in the guide I mentioned earlier (the only difference is that I enabled PDF417 before compiling)

For any other type of barcode it works amazingly! Is PDF417 not fully implemented? Is there anything I can do to make it work?

jasp00 commented 5 years ago

It looks like PDF417 support is incomplete. So someone should have access to the standard and finish the implementation.

Naahuel commented 5 years ago

Thanks for answering. That's what I thought, yes. Unfortunately I'm not skilled enough to do that and it looks awfully complex. So I guess I'll just keep looking for some other c library that has that

mchehab commented 5 years ago

I double-checked at the code with some debug bits enabled. It seems that the pdf417 code already parses the image correctly. However, it misses the part of the code with would be producing the actual image decoding, as commented on its source: / FIXME TBD infer dimensions, save codewords / I don't have the specs myself. This is an ISO standard (ISO/IEC 15438, probably implemented based at its second version from 2006). No idea how complex would be to finish the implementation, or if it would be possible to finish it by looking at some other open source file from other projects. I opted to add a warning at the configure.ac, in order to warn about that when building it.

Naahuel commented 5 years ago

Thank you @mchehab Hopefully it'll be implemented soon!

I ended up using a cpp port of ZXing which can compile to wasm and be used with WebAssembly. It works Ok, but not better than the pure JavaScript implementation. The output wasm file is also quite large.

mchehab commented 5 years ago

I ended up using a cpp port of ZXing

Unfortunately, ZXing is Apache licensed. For us, the better would be either if someone with time could finish the implementation from scratch or if we could use some code from another LGPL 2.1 compatible project.

I did a quick search for other ZBar patches that might be floating around, but didn't see anything finishing the PDF417 implementation.

I probably won't have any time myself to do such coding.

So, volunteers for this task are wanted!

cb49747 commented 4 years ago

Is there any update on getting pdf417 support for zbar? I would help but way above my skill set. I'm looking a writing a perl solution to reading these barcodes.

dearsina commented 3 years ago

Any update to PDF417 support? It's becoming an important barcode format. Thanks.

haimat commented 2 years ago

Same here - any update on this PDF417 support in zbar?

jameshilliard commented 2 years ago

Unfortunately, ZXing is Apache licensed. For us, the better would be either if someone with time could finish the implementation from scratch or if we could use some code from another LGPL 2.1 compatible project.

The zint implementation is in c an should be LGPL2.1 comaptible AFAIU(BSD-3-Clause), although I think it's encode only.

vishaljangid1729 commented 1 year ago

I am attempting to use the ZBar library to decode PDF417 barcodes on the web using Web Assembly. I need help with detecting PDF417.

I have tested the ZBar library with other types of barcodes, and it works perfectly, so the issue is specific to PDF417 decoding.

Could someone from the community or the ZBar development team help me troubleshoot this issue? Is there a workaround or a fix that I can apply to resolve this problem?

jameshilliard commented 1 year ago

Is there a workaround or a fix that I can apply to resolve this problem?

From my understanding pdf417 support is effectively completely broken in zbar and would need significant development work to make functional.

vishaljangid1729 commented 1 year ago

Is there a workaround or a fix that I can apply to resolve this problem?

From my understanding pdf417 support is effectively completely broken in zbar and would need significant development work to make functional.

I am facing this issue in production. I need urgent help on this. Can anyone help me on this please.

haimat commented 1 year ago

I am facing this issue in production. I need urgent help on this. Can anyone help me on this please.

I had the same issue, but was not able to solve it via zbar. Thus I ended up with pdf417decoder. If you are using Python you could give that library a try. Good luck!

jameshilliard commented 1 year ago

I am facing this issue in production. I need urgent help on this. Can anyone help me on this please.

You probably need to look into using something like ZXing for pdf417 decoding at the moment.

I am attempting to use the ZBar library to decode PDF417 barcodes on the web using Web Assembly.

The ZXing library supports webassembly.