I am using pyzbar to decode barcodes on Raspberry Pi 3 using Pi Camera v1 (resolution 1296x972). Qr codes are decoded very well. When decoding two dimensional barcodes (CODABAR), the success rate is very low.

I have tried saving one frame from the video stream and decode it with pyzbar on the Raspberry and it fails. When i try to decode the same image on Ubuntu, and decodes it successfully.

from pyzbar import pyzbar
from PIL import Image
img = Image.open('sampleImage.png')
d = pyzbar.decode(img)

print (d)

Any thoughts what may be the problem?

The following image is my specific use case. eBarcode image Because I am using Pi Camera v1 to take images, I tried to do adjustment to image sharpness:

from picamera import PiCamera
self.camera = PiCamera()
self.camera.sharpness = 100

The following image is with sharpness 100. However, pyzbar still fails to decode it on the Raspberry Pi.

enter image description here

I have done thresholding with cv2 (threshold value 50). It still fails to decode on the Raspberry Pi. The resulting image is the following: enter image description here

  • looks like you may be using poor quality barcodes .... find a barcode that has better defined spaces between the bars – jsotola Jun 13 at 15:39
  • Yes, the barcodes are with poor quality, but it still successfully decodes on Ubuntu. I wonder if the problem is because of the processing power of the Raspberry, or processing timeout... – vg34 Jun 14 at 19:30
  • print a good quality barcode for testing .... there is a lot of online web pages where you can generate a barcode in the PNG format ... i think that your barcode is codabar .... when you get good barcode reads, then start to introduce less than optimal quality barcodes – jsotola Jun 14 at 21:40
  • Thank you for the answer @jsotola. I have generated the codabar online and it decodes. I will start adding artifacts to reduce its quality and see where exactly it starts failing. I have edited the question and added thresholded image example. – vg34 Jun 16 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.