PyDMTX

1. Introduction

The project and the resultant .sis/.sisx files comprise a data matrix encoding and decoding module for the Symbian environment. The module is a Symbian C/C++ extension in Python for the libdmtx library that has been created by Mike Laughton of Dragonfly Logic Inc.

This webpage aims to give a brief introduction to the module.

The best way to get familiar with the library is to use it in the "Interactive Console" of Python. There are various resources (such as this and this) that will explain how to get started and reach the "Interactive Console". Once you have reached the console, you will need to import the module -
     >>> import pydmtx

Impatient? Want the code??
You will find all the files in here. Please ensure that you download the latest version of the project file (.zip) or the installation files (.sis/.sisx) for best performance. I have used Python 1.4.5 (available here) and the S60 3rd Edition Maintenance Release SDK. Please note that you might have to rebuild the project if you are using a phone with a later version of Symbian.

2. License

You can find information about the license under which the module has been distributed by calling the function license. A copy of the license can be found in the license directory of the project. On the phone, it can be found at c:\data\license\ folder.
     >>> err, err_num, msg = pydmtx.license()

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
If you need to contact me, you can find my contact details in the usage file

3. Encode

This function encodes some text into a data matrix. Presently, the encoder can write to 'jpg' images only.

The arguments given to the encoder function are the message and the name of the file. The function itself will return a 3-tuple, of the form :
     >>> err, err_num, msg = pydmtx.encode(message,filename)

The following table explains the output -
err err_num What the error means
0 0 The pydatamatrix module is missing
0 1 No message has been given
0 2 No filename has been given
0 3 Cannot find name of image in 'filename'
0 4 Module can only handle jpeg images
0 5 Path (of file) doesn't exist
1 x Success!

Some example usage -
     >>> err, err_num, msg = pydmtx.encode("Hello world","c:\\data\\hello_world.jpg")
     >>> err, err_num, msg = pydmtx.encode("PyDMTX","d:\\pydmtx.jpg")
     >>> err, err_num, msg = pydmtx.encode("Peace","c:\\data\\images\\peace.jpg")

4. Decode

This function decodes a datamatrix. Presently, the module can read jpg files only.

The arguments given to the decoder are the the name of the file. The function returns a 3-tuple of the form:
     >>> err, err_num, msg = pydmtx.decode(filename)

The following table explains the output -
err err_num What the error means
0 0 The pydatamatrix module is missing
0 1 The filename has not been passed on to the function
0 2 The image file seems to have an error
1 -2 Image has an incorrect format, could not decode
1 -1 Successfully read - But couldn't find a datamatrix
1 0 Found a datamatrix, but couldn't decode
1 x Success! - msg is the decoded datamatrix

Some example usage -
     >>> err, err_num, msg = pydmtx.decode("c:\\data\\hello_world.jpg")
     >>> err, err_num, msg = pydmtx.decode("d:\\pydmtx.jpg")
     >>> err, err_num, msg = pydmtx.decode("c:\\data\\images\\peace.jpg")

5. Other functions

Version : This function tells you the version of the module.At the time of writing, the latest version was Version 2.1.0.
     >>> print pydmtx.version()

About: Tells you a little information about the module.
     >>> print pydmtx.about()

6. Acknowledgements

Before proceeding with this document, I'd like to thank the following, without whose help, this library not be possible
1) Mike Laughton and Dragonfly Logic for giving us the wonderful libdmtx resource.
2) Davide Carboni and Alberto Serra of Lab GeoWeb who made the first python extension
3) J Santhosh Kumar and M Vikramaditya: who patiently explained how libraries work, and a whole lot of other things that took me from a "Hello World" to pydmtx
4) Bogdan Galiceanu, Gargi Das, Wizard_Hu_, Pankaj Nathani and all the others who helped out on the Forum Nokia Developer Community Discussion Boards.
5) Fahmi Priadi for all the help swatting bugs..