Artifact [578601101c]
Not logged in

Artifact 578601101c191045f0c5380b9c82b80eaccc590c:

Wiki page [dmtx command] by chw 2017-01-15 12:03:08.
D 2017-01-15T12:03:08.343
L dmtx\scommand
P 38c5c0ea9df5c1c91cb9174e8416b5e5fad70145
U chw
W 2686
<h2>Name</h2>

<b>dmtx::*</b> - interface to the libdmtx.org Data Matrix Code scanner library.

<h2>Synopsis</h2>

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

<h2>Description</h2>

These commands are used to scan Data Matrix Codes off pixel image data.

<tt>dmtx::decode <i>photoEtc</i> ?<i>scale timeout</i>?</tt>

    Scans the photo image <tt><i>photoEtc</i></tt> for Data Matrix Code information. Alternatively, <tt><i>photoEtc</i></tt> can be a four element list describing a greyscale or RGB image as a byte array. The elements must be width, height, depth and byte array of the image in this order. The optional integer parameter <tt><i>scale</i></tt> downsamples the image before the scan takes place. The optional <tt><i>timeout</i></tt> limits the scan process to that many milliseconds. The command returns a three element list made up of a flag indicating success (=1) or failure (=0) of the scan process, the amount of milliseconds spent on decoding, and the scan result as a byte array.

<tt>dmtx::async_decode <i>photoEtc callback</i> ?<i>scale timeout</i>?</tt>

    Similar to <tt>dmtx::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>: a flag indicating success (=1) or failure (=0) of the scan process, the number of milliseconds for decoding, and the scan result as a byte array. The optional parameters <tt><i>scale</i></tt> and <tt><i>timeout</i></tt> have the same meaning as in the <tt>dmtx::decode</tt> command. The default timeout value is 1000 milliseconds. 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>dmtx::async_decode abort</tt>

    Aborts a running asynchronous decode process.

<tt>dmtx::async_decode status</tt>

    Returns the current state of the asynchronous decode 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>dmtx::async_decode stop</tt>

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

Z 0e0c317c745208166c8d858a7fb282e0