LinuxCommandLibrary

zbarcam

Scan and decode barcodes from a camera

TLDR

Continuously read barcodes and print them to stdout

$ zbarcam
copy

Disable output video window while scanning
$ zbarcam --nodisplay
copy

Print barcodes without type information
$ zbarcam --raw
copy

Define capture device
$ zbarcam [/dev/video_device]
copy

SYNOPSIS

zbarcam [options] [device]

PARAMETERS

-h, --help
    Displays a concise help message with available command-line options and usage information.

-V, --version
    Prints the version information of the zbarcam utility and the underlying ZBar library.

-v, --verbose
    Enables verbose output, providing more detailed information about the scanning process, detected symbols, and any errors encountered.

-q, --quiet
    Suppresses all verbose messages, ensuring only decoded barcode data is printed to standard output.

-s<config>, --set <config>
    Configures specific options for a barcode symbology. The <config> format is [symbology.]config[=value], where symbology can be EAN13, QR-Code, Code128, etc., and config specifies options like enable, disable, min-len, max-len, position.

--raw
    Outputs only the raw symbol data (the decoded barcode content) to standard output, without the symbol type prefix.

--xml
    Outputs the decoded barcode information in XML format, providing structured data including symbol type, data, and optional position information.

--
    Marks the end of command-line options, allowing the specification of a video device path that might start with a hyphen (e.g., -- -mydevice).

[device]
    Specifies the video input device to use. If omitted, zbarcam defaults to /dev/video0. Other common devices include /dev/video1, etc.

DESCRIPTION

The zbarcam command is a powerful utility from the ZBar barcode reader library, designed to capture and decode barcodes directly from a video input device, such as a webcam. It provides real-time barcode scanning capabilities, making it ideal for applications requiring immediate data extraction from physical barcodes.

Utilizing the Video4Linux (V4L) API, zbarcam can access and process video frames from `/dev/video` devices. It supports a wide range of popular 1D and 2D barcode symbologies, including EAN, UPC, Code128, and QR codes. Once a barcode is detected and decoded, zbarcam outputs the symbol type and its decoded data to standard output, making it easily scriptable or integratable into other systems. It's a command-line tool, providing a lean and efficient way to perform live barcode recognition without a graphical interface.

CAVEATS

zbarcam requires a compatible video input device (e.g., webcam) that is supported by the Linux V4L (Video4Linux) subsystem. Performance and accuracy are highly dependent on the camera's resolution, lighting conditions, and the clarity of the barcode. It does not provide a graphical user interface, operating purely on the command line. Users may need to install additional kernel modules or packages (like `v4l-utils`) for full camera functionality.

DEFAULT OUTPUT FORMAT

By default, zbarcam outputs each decoded barcode on a new line, prefixed by its symbology type. For example: EAN13:1234567890123 or QR-Code:Hello World.

SUPPORTED SYMBOLOGIES

zbarcam supports a wide array of barcode types, including but not limited to: EAN-13, EAN-8, UPC-A, UPC-E, ISBN-10, ISBN-13, Interleaved 2 of 5 (I2/5), Code 39, Code 93, Code 128, Codabar, and QR Code. Specific symbologies can be enabled or disabled using the --set option.

SELECTING VIDEO DEVICE

The target video device can be explicitly specified as the last argument, e.g., zbarcam /dev/video1. If no device is specified, zbarcam defaults to /dev/video0. Ensure the user running zbarcam has read access to the specified device file.

HISTORY

zbarcam is an integral part of the ZBar Barcode Reader project, an open-source software suite developed to read barcodes from various sources, including image files and video streams. The project was initiated to provide a robust and flexible barcode scanning solution for a wide range of 1D and 2D symbologies. Since its inception, ZBar and its utilities like zbarcam have been adopted by developers for applications requiring efficient, real-time barcode decoding in Linux and other Unix-like environments, leveraging the system's video capabilities.

SEE ALSO

zbarimg(1), v4l2-ctl(1)

Copied to clipboard