|
13 years ago 8 |
Some time ago I faced the problem that a fellow colleague gave me a business card on a conference and it contained only his name and a QR-code image. At first I did not even know that this image was called a “QR-code”. It was not mentioned on the card what standard it would be. While seeking I found that there is a huge amount of different standards for 1D-codes (bar codes) and 2D-codes (matrix code). A matrix code, also termed a 2D barcode or simply a 2D code, is a two-dimensional way to represent information. It is similar to a linear (1-dimensional) barcode, but can represent more data per unit area.
In the following the QR-code will be introduced and then an introduction will be given on 'how to install applications on your Linux Mint computer' in order to read and create QR-codes.
A QR code (abbreviated from Quick Response code) is a type of matrix barcode (or two-dimensional code) first designed for the automotive industry. More recently, the system has become popular outside of industry due to its fast readability and comparatively large storage capacity. The code consists of black modules arranged in a square pattern on a white background. The information encoded can be made up of any kind of data (e.g. binary, alphanumeric, or Kanji symbols). Created by Toyota subsidiary Denso Wave in 1994, the QR code is one of the most popular types of two-dimensional barcodes. The QR code was designed to allow its contents to be decoded at high speed. QR code for the URL of the English Wikipedia The technology has seen frequent use in Japan and South Korea; the Mobile main page United Kingdom is the seventh-largest national consumer of QR codes.
A QR-code is structured in a standarted manner, which is briefly sketched on the figure below:
Structure of a QR code, highlighting functional elements
(image source: http://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/QR_Code_Structure_Example_2.svg/300px-QR_Code_Structure_Example_2.svg.png)
This tutorial is not meant to repeat the informations on QR-code provided already by Wikipedia. If you are interested on more general background informations to QR-code or bar code please follow the link to Wikipedia: http://en.wikipedia.org/wiki/QR_code
Install libdecodeqr-examples from the repositories:
sudo apt-get install libdecodeqr-examples
Then you install the QR-code generator with the following command:
sudo apt-get install qrencode
For later use we are going to install here already DATAMATRIX!
Install libdmtx-utils from the repository and try using the tools it provides.
Libdmtx is a library for reading and writing Data Matrix 2D barcodes, two-dimensional symbols that hold a dense pattern of data with built-in error correction.
One can use from the previously installed libdecodeqr library a simple test program, called libdecodeqr-webcam to read simple QR-code images via your webcam. It can recognize the image file of the QR code of JIS X 0510 and ISO/IEC18004. The webcamera corresponding to Video4Linux or Video4Linux2 is necessary to operate this program.
Now you may simply start this application to decode QR-codes, which are scanned by your computers webcam. You may start this application via the shell command:
libdecodeqr-webcam
The following text will appear on the shell window and simultaniously a graphical window opens (some times above the shell window):
libdecodeqr version 0.9.3 ($Rev: 42 $)
Hit [SPACE] key to grab, or any key to end.
It is very important that you hold the QR-code in front of your webcam that it fills at least 50% of the area of your graphical window. After hitting the SPACE bar the program will provide the coded details on your shell window or in case it was read faulty an error message. In case of an error message just repeat the reading process once again. It may take some tries ...
For more details on the program do RTFM (consult the man-pages).
Below you find an example of a self made QR-code. You can print it and hold in front of your webcam and try if you succeed to go to the web address hidden within the image
BTW: If you wish to try this QR-code on your cell/smart phone you might want to find some apps for your phone at the following URL: http://www.upc.fi/en/upcode/instructions/download/
or download the code onto your computer and transfer it to your phone via whatever means (Bluetooth, WiFi, MiniSD card, etc...) from the following URL: http://www.upcode.fi/mobile/pc_download.asp?language=1
Being able to read QR-codes is only on part of the story. Shortly after you are able to read them you will want to make your own QR-codes. Really, they are very useful, once you tell the people whom you provide them that they are QR-codes. You may add them on your science posters and people can later on download the posters from the net and would not need anymore to stand there and take photographs with their smart phones or you are giving away small Xerox copies of the poster, which nobody can read ... They may also become a need addition to your business card or even your vcard.
Here we are going to make use of the Libqrencode, which is a library for encoding data in a QR Code symbol. It is a kind of 2D symbology that can be scanned by handy terminals such as a mobile phone with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has high robustness.
The generation of your own QR-code can be done and tuned in various ways and you may control them by setting different paramters. The entire list of paramters, which the qrencode program offers you can obtain by RTFM:
man qrencode
Following only a slim describtion is given to give you a nice start up into the world of QR-code generation.
The first most important detail is that the information you are going to code must be rather short. So an URL as one line (in this example) is the input we are going to use here. Certainly you may also add more lines but the image will become much more complex and the source of errors are rapidly increasing. The other important details is that all the graphical outputs are provided in PNG format.
The synopsis can be given as: qrencode [OPTION]... [STRING]
Now we aim to add a single line of informations [STRING]. In the present example it is a web address ('http://www.danielides.de/com/aurora.html'). If the there is no specification for the input it will be taken from standart input. Then we wish to specifiy the size of dots (pixel) as 10. In the default settings for -s a value of 3 is given. With the option -o the output filename is set (which is in every case a PNG file). If '-' is specified, the result will be output to standard output. In this example the output filename is called 'aurora_QR.png'.
qrencode -s 10 -o aurora_QR.png http://www.danielides.de/com/aurora.html
it is also possible to store the [STRING] for regular use in a text file. This can become handy once it is automatically extracted by a shell script from a data base. Then the following shell command could be used:
cat textfile.txt | qrencode -s 10 -o output.png
Other simple EXAMPLES are:
1) Encode into a symbol version 1, level L:
qrencode -l L -v 1 -o output.png 'Hello, world!'
2) Read standard input and encode it into a structured-appended symbols in case-insensitive mode:
qrencode -iSv 1 --output=output.png
Finally you may want to test your qr-code image (produced as a PNG file) using the following command:
libdecodeqr-simpletest filename.png
A second way to read and write your QR-codes is provided by DATAMATRIX.
dmtxwrite - create Data Matrix barcodes, simple example;
dmtxwrite -o image.png input.txt
This will encode text contained in input.txt in current directory to an image, image.png in current directory.
dmtxread - scan Data Matrix barcodes, simple example;
dmtxread image.png
Reads the encoded image.png and writes the decoded messages to standard output.
The source for DATAMATRIX was found at the AskUbuntu site: http://askubuntu.com/questions/22871/software-to-read-a-qr-code
cool
Never thought that I would one day need it; the tutorial is clear and easy to follow. Thanks.
Thanks to you, now I know what a QR-code is.
P.S. Very good tutorial with nice presentation.
Well, there you go, showing off again. Nice job. Mr @clem should know about this.
@blueXrider: Sure it would be sooooo cool to have a QR-code for LM community site. And you know what? Here it is:
http://images.danielides.eu/images/LM_QR.png
You can do similar code yourself by using the following command:
qrencode -s 10 -o LM_QR.png http://community.linuxmint.com
and check your product with the following command:
libdecodeqr-simpletest LM_QR.png
Also you may just download the QR-code from my link and try to check it. BTW: Feel free to use the link for the LM community front site if that is wanted (-;
OH! BTW might want to consider creating a QR Code image for LinuxMint. It would be soooooooooo cool.
Wow, I didn't even know what a QR code was. Don't expect to use it however the information is good.
Nice job on your tutorial. Very impressive utilizing the WYSIWYG format. I like the images and descriptions of each, very good format and layout.
The community should thank you for such information.
GOOD JOB!
@remoulder: Thank you for the positive comment. You are absolutely correct that there is not much demand to read QR-code on a desktop OS. Then again LM is not only a desktop OS. I run LM on a netbook and I could imagine that LM will be a nice option in the near future for tablet PCs. An other aspect is the need to produce your own QR-code. Sure you can use your cell/smart-phone to read the QR-code on the fly and save it. But once you aim to create your own QR-coded image, e.g. for a conference paper or just as an owner of, e.g., any hardware company then you may very well use a desktop PC (incl. desktop OS) to do so. For me QR-codes are mainly fun stuff and I am curios sometimes if my cell phone app works and if there is any interesting stuff coded on a commercial somewhere on the road.
Nice tutorial though I don't see much demand for this on a desktop OS.