Tuesday 29 May 2012

Ubuntu Libdmtx installation Guide

To install libdmtx first of all we have to configured the machine compatible to libdmtx library:
for that you have to install some python packages.

The required packages are :

(1) python-dev
    This will include the all header file of the c which is requierd for libdmtx library e.g python.h
    sudo apt-get install python-dev

(2) git
    This will install the git which is repository
    sudo apt-get install git

(3) libdmtx-utils
    libdmtx-utils is required for the libdmtx library which includes c file and all header file
    sudo apt-get install libdmtx-utils

(4)  libdmtx-dev
    libdmtx-dev is required for the libdmtx python wrapper.
    sudo apt-get install libdmtx-dev


Now we have to setup the libdmtx library,

(1) first change the directory to
    cd /usr/share/doc/libdmtx-dev/examples/python

(2)unzip pydmtx.py.gz
    sudo gunzip pydmtx.py.gz

(3)unzip pydmtxmodule.c.gz
    sudo gunzip pydmtxmodule.c.gz

(4) installing the setup of libdmtx
    sudo python setup.py install

(5) Thats it!!

now test if the installation

run this python code in your python interpreter:

        from pydmtx import DataMatrix
        from PIL import Image


        # Write a Data Matrix barcode
        dm_write = DataMatrix()
        dm_write.encode("Hello, world!")
        dm_write.save("/home/hello.png", "png")


        # Read a Data Matrix barcode
        dm_read = DataMatrix()
        img = Image.open("/home/hello.png")


        print dm_read.decode(img.size[0], img.size[1], buffer(img.tostring()))
        print dm_read.count()
        print dm_read.message(1)
        print dm_read.stats(1)

2 comments: