7

I'm Trying to decode barcodes using Raspberry Camera-board and zbar tools. So far it has not worked since the image captured by the Camera is fuzzy: the barcode is either too close or too far to get decoded.

Does anybody have succeed to to a similar thing? Do you have any recommendation? Should I use a webcam instead?

Some pictures I have tried to decode with zbar (with no success):

enter image description here

enter image description here

5
  • can you provide one of these images? why you are using zbar? you tried alternatives?
    – Alex Tape
    Feb 6, 2014 at 9:18
  • 1
    Done. Whenever I try to get the barcode closer to the camera-board it gets fuzzy. What are the alternatives to zbar?
    – user12597
    Feb 6, 2014 at 12:44
  • It may be possible to simply hold the items further away where they are in focus and use a sub-section of the image.
    – Fred
    Mar 4, 2014 at 23:01
  • Hi. Thank you everybody, I have finally purchased and plugged the "cheap usb scanner" recommended by Alex. It works perfectly, very fast and precise. This solution is also much cheaper than using the board camera. Thanks anyway for all your comments and suggestions. Cheers.
    – user12597
    Mar 5, 2014 at 8:58
  • I used an external webcam for better quality scans and auto focus capability. Together with Zbar is worked well, but only in well lighted conditions. Additionally giving more RAM to the GPU helps increase the speed. I wrote a quick article on it too at techblog.saurabhkumar.com/2015/09/… Sep 22, 2015 at 20:12

2 Answers 2

7

The problem is the RaspiCam. The camera does not have auto-focus! I had the same issue at another topic...

Your options are:

  1. Try another device e.g. any webcam with auto-focus
  2. Scan your barcodes with a cheap usb scanner

For the first option I think zbar is a good way to go. I don´t know your exact use case but you can automate this process with nearly any script/programming language... (perl, python, java, c++,.. whatever) If you take the second option, the barcodes will appear over STDIN..

So, to answer your question: there is no way to solve that issue without using another cam!

1
  • 1
    Actually, I achieved amazing success with the RPi Camera module by manually adjusting it's lens focus. The images you posted above would be no problem for it. I'm scanning barcodes and QRCodes in realtime with very good detail. Here's how to adjust the lens: raspi.today/how-to-focus-the-raspberry-pi-camera-lens
    – ghstcode
    Sep 11, 2015 at 13:07
3

You could place à cheap lens in front of your raspicam that has à focal length of about 15 ~ 20cm.

2
  • 1
    An A5 or A4 Frensel reading lens may be good. Essentially it's a giant magnifying glass. They're quite cheap as they're plastic, but the image quality should be good enough for something like this.
    – Fred
    Mar 4, 2014 at 23:09
  • This Fresnel lens suggestion worked perfectly for me. Thank you Oct 19, 2022 at 15:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.