dmtx command
Not logged in

Name

dmtx::* - interface to the libdmtx.org Data Matrix Code scanner library.

Synopsis

package require dmtx
dmtx::decode ?options?
dmtx::async_decode ?options?

Description

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

dmtx::decode photoEtc ?scale timeout?

Scans the photo image photoEtc for Data Matrix Code information. Alternatively, photoEtc 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 scale downsamples the image before the scan takes place. The optional timeout 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.

dmtx::async_decode photoEtc callback ?scale timeout?

Similar to dmtx::decode but the decoder is run as a background thread and the result is presented to a callback 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 callback: 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 scale and timeout have the same meaning as in the dmtx::decode 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.

dmtx::async_decode abort

Aborts a running asynchronous decode process.

dmtx::async_decode status

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

dmtx::async_decode stop

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