Artifact [5eaf8e6229]
Not logged in

Artifact 5eaf8e62292439d29176d51e243848f6cbeb77a0:

Wiki page [zbar command] by chw 2017-01-15 12:04:21.
D 2017-01-15T12:04:21.402
L zbar\scommand
P f9d572d3780aed9e8818ffa2e807a4fe0280b259
U chw
W 2917
<h2>Name</h2>

<b>zbar::*</b> - interface to the ZBar barcode scanner library.

<h2>Synopsis</h2>

<tt>package require zbar</tt><br>
<tt>zbar::decode ?options?</tt><br>
<tt>zbar::async_decode ?options?</tt><br>
<tt>zbar::symbol_types</tt>

<h2>Description</h2>

These commands are used to scan barcodes off pixel image data.

<tt>zbar::decode <i>photoEtc</i> ?<i>syms</i>?</tt>

    Scans the photo image <tt><i>photoEtc</i></tt> for barcode information. Alternatively, <tt><i>photoEtc</i></tt> can be a four element list describing a greyscale or RGB image as a byte array with 8 bits per color component. The elements must be width, height, number of color components and byte array of the image's pixels in this order. The optional parameter <tt><i>syms</i></tt> must be a list of barcode symbologies to be scanned for. If omitted, all known symbologies are tried. The command returns a three element list with the first element being the number of milliseconds spent on decoding. The second element is the decoded symbology on success or an empty string on failure, and the last element is the scan result as a byte array.

<tt>zbar::async_decode <i>photoEtc callback</i> ?<i>syms</i>?</tt>

    Similar to <tt>zbar::decode</tt> but the decoder is run as a background thread and the result is presented to a <tt><i>callback</i></tt> procedure. It requires the Tcl core being built with thread support, and a running event loop since the callback is invoked as an event or do-when-idle handler. Three additional arguments are passed to <tt><i>callback</i></tt>: the number of milliseconds for decoding, the decoded symbology on success or an empty string on failure, and the scan result as a byte array. The optional parameter <tt><i>syms</i></tt> has the same meaning as in the <tt>zbar::decode</tt> command. Caution: only a single thread instance is supported per Tcl interpreter, i.e. another asynchronous decode process can only be started when a previous decode process has finished.

<tt>zbar::async_decode status</tt>

    Returns the current state of the asynchronous decode thread as a string: <tt><i>stopped</i></tt> when no asynchronous decode thread has been started, <tt><i>running</i></tt> when a asynchronous decode is in progress, and <tt><i>ready</i></tt> when the next asynchronous decode can be started.

<tt>zbar::async_decode stop</tt>

    Stops the background thread for asynchronous decoding if it has been implicitely started by a prior <tt>zbar::async_decode</tt>. This can be useful to conserve memory resources.

<tt>zbar::symbol_types</tt>

    Returns a list of supported symbologies of the scanner, currently <tt>EAN8</tt>, <tt>UPCE</tt>, <tt>ISBN10</tt>, <tt>UPCA</tt>, <tt>EAN13</tt>, <tt>ISBN13</tt>, <tt>DATABAR</tt>, <tt>DATABAR_EXP</tt>, <tt>I25</tt>, <tt>CODABAR</tt>, <tt>CODE39</tt>, <tt>QRCODE</tt>, <tt>CODE93</tt>, and <tt>CODE128</tt>.

Z 6835ccd577be3d4c9e6767ab8a8315da