mmalecki / zbar

zbar, fixed up a bit.
GNU Lesser General Public License v2.1
15 stars 11 forks source link

PDF417 decoding doesn't work? #2

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?

mmalecki commented 5 years ago

Hm, oh man, wish I could help you out here - I haven't used zbar for a couple years now.

I have managed to find a similar issue that could be of help tho - https://github.com/NaturalHistoryMuseum/pyzbar/issues/29. Let me know if that works for you!

Naahuel commented 5 years ago

Thank you for answering! Unfortunately no, that issue is of no help because that person wants to disable PDF417, quite the opposite of what I want!

Oh well. I wish I was smart enough to complete the implementation haha. I guess I'll settle with what I have working now.

Thanks!

AhmadShaik commented 5 years ago

@Naahuel Can you share code and steps to read pdf417 using zbar

Naahuel commented 5 years ago

@AhmadShaik I followed the guide I linked in my original post above. Notice I had to enable pdf417 decoding.

brdamico commented 5 years ago

Hi @Naahuel , I'm facing the same issue. I tried to find how to enable PDF417 in the guide that you posted but I couldn't. Can you please share out with us the solution?

Naahuel commented 5 years ago

Sure @brdamico. You need to pass --enable-codes=pdf417 to configure.

Look at the step where he creates the build:

emconfigure ./configure --without-x --without-jpeg ...

Just add it to that line. Keep in mind that --enable-codes will only enable the ones you specify and disable the rest.

theD1360 commented 4 years ago

@Naahuel where you ever able to get PD417 scanning working for your WebAssembly project? I'm trying to do something similar and seem to have hit a wall. Even after enabling the decoder it still fails to detect PD417 barcodes.

Naahuel commented 4 years ago

@theD1360 take a look at these projects: https://github.com/Naahuel/poc-dni-pdf417 https://github.com/Naahuel/poc-dni-pdf417-WA (this one uses webassemly, but with ZXing for C++)

They're pretty old and hacked together just to test, but they might give you an idea, maybe?

Didn't manage to get ZBar working :(

theD1360 commented 4 years ago

Hey @Naahuel thanks for the reply. Unfortunately, I wasn't able to get zbar working with PDF_417 either. I was successful using zxing-cpp though.

brdamico commented 4 years ago

Hi everybody, I was able to read PDF417 using Python with zXing library only too. I've added an example here: https://github.com/brdamico/PDF417BarcodeReader I'm brand new on GitHub then feel free to comment or advice me if needed.