Installing and using ZBar in Linux to scan bar codes with your Webcam
October 5, 2012 3 Comments
ZBar is an application that can scan and decode several bar code symbologies (including QR Code) from sources such as a Webcam or an image file. I had been wanting to install it for some time and was finally spurred on to do it by a request for help to get it working in the Sabayon Linux forums. Here are the steps I used.
1. I installed the package
Note for Gentoo users: I merged the package with the
v4l USE flags set, so that both
zbarcam would be installed. If you only want to use ZBar with a Webcam then turn off the
imagemagick flag and
zbarimg will not be installed.
Note for Sabayon Linux users: The Entropy package was built with both the above-mentioned USE flags set, so
zbarcam will be installed.
2. Then I checked the status of the installed package by using the Portage
Sabayon Linux users could instead use the following command:
3. Then I checked which video device my laptop’s inbuilt Webcam is:
4. As it is
/dev/video0, I launched
zbarcam as follows:
zbarcam was not recognising the Webcam.
5. As I had installed the package with the Video4Linux USE flag set, I then launched
zbarcam with the following prefix:
The ZBar GUI window popped up and I could see myself in the window. So far, so good.
6. I held a QR Code 2D bar code in front of the Webcam, then held a 1D Interleaved 2 of 5 bar code in front of the Webcam. The following was displayed:
Both the QR Code and the I2of5 bar code were read correctly. If the
--raw parameter is omitted then
zbarcam displays the symbology of the bar code too:
7. Then I tried using ZBar to read a bar code which I had previously saved as a
To find out the other parameters available, use the commands:
ZBar is a nice tool.