Artifact Content
Not logged in

Artifact c0171b9a8fc5e0af6f5b88734ebd87650c002612:

Wiki page [zbar command] by chw 2019-04-26 06:26:15.
D 2019-04-26T06:26:15.924
L zbar\scommand
P 5eaf8e62292439d29176d51e243848f6cbeb77a0
U chw
W 2942
<h2>zbar command</h2>

<h3>Name</h3>

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

<h3>Synopsis</h3>

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

<h3>Description</h3>

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 7a40e07bf5389d8ee7f861929f1646a1