Zbarcam-Raspberry Pi

3.8k views Asked by At

I am trying to get my webcam (connected to a Pi) to read qr codes. I was using zbar-tools for this but am currently getting the following error:

ERROR: zbar processor in zbar_processor_init():
system error : spawning input thread : invalid argument (22)

Any ideas on what might be causing this error and how I can fix it?

4

There are 4 answers

0
Shomari On

Had the same problem. The issue was that I was connecting via SSH. I would recommend that you first start the Raspberry Pi GUI using startx, then run your command from the Terminal editor. You can also opt to disable the display using the zbarcam --nodisplay flag.

If that still doesn't work, as it didn't for me, I started receiving a new error message:

unsupported request: no compatible image format

I discovered, from this article, that you can use a prefix to launch zbar, which I had to slightly modify to:

LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libv4l/v4l1compat.so zbarcam --raw /dev/video0

This is the command that finally worked for me.

1
NoThanks On

This one worked on Arch

LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so zbarcam --raw /dev/video0

from: https://fitzcarraldoblog.wordpress.com/2012/10/05/installing-and-using-zbar-in-linux-to-scan-bar-codes-with-your-webcam/

0
saronet On

For me, while connecting remotely, adding the flag --nodisplay helped me: pi@raspberrypi:~ $ zbarcam /dev/video0 --nodisplay

(the device might be different for you, try pi@raspberrypi:~ $ ls /dev/video? for discovering what your connected devices are)

0
Armin On

Got the same error message from within python when I was using python-zbar. I knew I needed something like the --nodisplay flag, however this is only available at the zbarcam command line. My solution was to look into the python-zbar sources where I found a second undocumented argument for proc.int():

import zbar
proc = zbar.Processor()
device = '/dev/video0'
proc.init(device,False)