Ceci est une ancienne révision du document !
QR “Quick Response” codes are fast becoming a popular means of communicating snippets of information from a printed medium or other physical surface towards computers and mobile devices. They were originally developed as a replacement for the single-dimension bar code by a team from the automotive equipment design and manufacturing company Nippon Denso Co. Ltd.. The increase in the amount of different car parts handled gave rise to a desire to augment correspondingly the amount of data that could be stored on the printed labels that were used to identify the boxes in storage and during transport. Since 2006, the working principles have become the ISO/IEC standard 18004:2006, and so can be seen as a recognized industry technique. The team behind this design (Masahiro Hara, Motoaki Watabe, Tadao Nojiri, Takayuki Nagaya, and Yuji Uchiyama ) won the European Patent Office 2014 Popular Prize for their efforts (http://www.epo.org/learning-events/european-inventor/finalists/2014/hara.html). Nowadays, QR codes are widely used in situations in which it is desirable to present printed matter containing links to electronic information, in a way that is easy for a computer to read in. Examples include applications such as a bus-stop transportation map that includes a QR-encoded link to the company’s web page to get up-to-date information on scheduling, a poster for a music festival with a QR-enabled link to the online ticketing service, or train or aircraft tickets with QR codes that are read at the entrance stile to enable access to boarding.
Les codes QR « Quick response » (réaction rapide) deviennent rapidement un moyen populaire de communiquer des fragments d'information depuis un support imprimé ou une autre surface physique vers des ordinateurs ou des appareils mobiles. Ils ont été développé au départ pour remplacer le code-barre linéaire par une équipe de la société Denso Co Ltd, qui développe et fabrique des équipements automobiles. L'augmentation du nombre des différentes pièces de voiture manipulées fit naître le désir d'augmenter en parallèle la quantité de données qui pouvait être stockée sur les étiquettes imprimées qui étaient utilisées pour identifier les boîtes dans le stock et pendant le transport.
Depuis 2006, les principes utilisés sont devenus la norme ISO/IEC n° 18004:2006, et sont ainsi vus comme une technique industrielle reconnue. L'équipe en charge de cette conception ((Masahiro Hara, Motoaki Watabe, Tadao Nojiri, Takayuki Nagaya, and Yuji Uchiyama ) gagna la Prix de la Popularité 2014 de l'Office Européen des Brevets pour leur démarche (http://www.epo.org/learning-events/european-inventor/finalists/2014/hara_fr.html). pour Bab : changer l'URL
De nos jours, les codes QR sont largement utilisés dans des situations où il est souhaité d'offrir des imprimés contenant des liens vers de l'information électronique, d'une façon facile à interpréter pour un ordinateur. Parmi les exemples, la carte des stations du réseaux de bus qui inclut un lien en code QR vers la page Internet de la compagnie pour obtenir les dernières informations sur les horaires, une affiche pour un festival de musique avec un lien en code QR relié au service de billetterie en ligne, ou des billets de train ou d'avion avec des codes QR qui sont lus à la porte d'embarquement pour autoriser la montée à bord.
At the same time, the folks in graphics design have been making use of the fact that data is actually redundant inside the code; the image can be modified in various ways and still convey useful information to the reader. A recent example from 2014 is the “Guinness QR cup” by BBDO New York that has won a Caples award (http://www.caples.org/guinness-qr-cup-0). The idea refers to a Guinness beer glass with a printed QR code, that is readable only when the glass is still full of the black stuff: only the white dots are actually printed, while the black dots are the beer itself showing through from behind. In this article, we will see how to read and create QR codes in an Ubuntu system using various programs. Before continuing, it should be noted that several other similar systems can be found, such as Data Matrix barcodes (https://en.wikipedia.org/wiki/Data_Matrix) and Aztec codes (https://en.wikipedia.org/wiki/Aztec_Code). Though each of these systems is popular in places, QR codes seem, for the time being, to be the best supported, both by Ubuntu and applications on mobile devices.
THE ANATOMY OF A QR CODE Let us consider a specific example: As can be seen, a QR code is in fact a two-dimensional square matrix of dots (pixels), that, in essence, are binary zeros and ones. This is in fact about the only time a modern user of computing equipment will have the chance to get intimate with binary code since it is often obscured by the various layers of software in between. When a QR code reader is placed before this image, the first parts that are detected are the three positioning marks emphasised in gold. These give the camera a basic idea of the position of the the QR code, as well as its orientation. The small mark in red also helps understand alignment; there is only one of these on small QR codes, but larger codes use a repeating pattern to ensure coherence across the width and height of the image. QR codes may be of varying widths, expressed in the number of dots used. However, this has nothing to do with the actual physical size of the image, nor to the resolution of the photograph the reader has taken of it. So the second stage in code interpretation is to figure out how many dots are being used in this particular code. To do this, a simple repeating pattern of black and white dots is placed between the orientation marks (shown in green). This “timing” pattern is easy for the reader to interpret, and so figure out the number of lines and columns in the mesh.
The rest of the dots correspond to a mix of QR code version information, format information, the actual data, and error correction codes. Error correction is necessary, since cameras do not always give a clear image of the code area (due to the presence of dust, scratches on the lens, etc.), interpretation may also get some dots wrong (if colors are not correctly detected), and motion blur if the camera is not held perfectly still at the time. Error correction in QR codes uses a branch of Reed-Solomon error-correcting codes. With a bit of (perhaps over-) simplification, these codes can be seen as basically repeating all information more than once. Redundancy is calculated in such a way that not only can errors be detected, but also corrected upon reading. With sufficient extra bits added to each data word, more than one single error can be detected - unlike more simple schemes in which two errors in the same word could go undetected. Nowadays, the details of how the error detection and correction are handled go quite under the radar of the human user. Software (on most consumer-grade devices) or hardware (in industrial applications) take care of this part and simply give us the decoded information in readable form. In fact, the addition of superimposed colors to the QR code above has not made it unreadable - if you have a QR reader or application available, go ahead and see what it says!
SOME SOFTWARE There is in fact a selection of software available in the Ubuntu repositories to create QR codes. One of the most basic is qrencode from the apt package with the same name. This is a console-only program. For example, to encode the web page address of our favorite magazine, simply issue: qrencode -o qr-example1.png http://fullcirclemagazine.org This creates the image qr-example1.png in the current directory: The same program can also create QR codes in a variety of formats. One of particular interest is SVG. The corresponding command would be: qrencode -o qr-example1.svg -t SVG http://fullcirclemagazine.org In the other direction, the zbar-tools package contains programs to handle converting a QR code read in from the camera (zbarcam) or from an image file (zbarimg). For instance: zbarimg qr-example1.png QR-Code:http://fullcirclemagazine.org/ scanned 1 barcode symbols from 1 images in 0.02 seconds
On the graphical side of things, perhaps the best known application for Ubuntu is QtQr. Using the Qt library on which the KDE desktop is based, this program also works quite well under other desktop managers, being sufficiently integrated to include dragging files to and fro. The software contains a complete QR code generator, where the user can not only specify the type of information to be encoded (URLs, but also other structured information such as personal contact information, georeference or even WiFi network details), but also the dot size in pixels, margin width and level of data redundancy to be used. QtQr reads in QR codes either from image files, or by accessing the computer’s webcam if available. This is handy to read in data from a mobile phone, without needing to set up wireless communication (Bluetooth or similar).
EDITING QR CODES Once a QR code has been created, some editing can take place without altering the information contained within. To take an example, I will take the “http://fullcirclemagazine.org” QR above, in SVG form. As line-art, it can then be imported into a vector editing program such as Inkscape and modified to suit our needs. Opening it with Inkscape, the first thing we notice is that the white background has been grouped together with the black markings. We can select the complete assembly and hit Ctrl-Shift-G to ungroup them. The black markings themselves are also individual rectangles that have been grouped together. If we wish to alter individual pieces, they will also need to be ungrouped first. For our examples, however, we will keep them together in one piece. The first thing we can do with the black markings is to change their color. Select the markings, then choose Object > Fill and Stroke in the menu. We can play around with the fill color, and add blur for artistic effect. QR codes are sufficiently robust that even relatively light colors can be used, and still function as a code. However, one should not try to go too far - ‘too far’ being colors with little contrast to the background, or a combination of light and dark colors. These do not work well with most QR readers. If we do stay within these parameters, some effects such as gradients are possible. To apply these, select the markings, and in the Fill dialog choose Gradient fill. You will need to edit the gradient end-points to make sure that both of the colors used to build the gradient are sufficiently contrasted with the background. Some experimentation may be needed for good results.
In Inkscape, photographs may be used as patterns to fill in areas. The image (JPG, PNG or similar) is imported, then converted into a pattern using menu option Object > Pattern > Objects to Pattern. The black markings in the QR code are then selected, and filled with the new pattern. As before, it is best to use images with similar and rather dark colors - and no very light-colored spots in them (if using a white background). On the other hand, very light images can be used to color the markings, on top of a dark background. Alternatively, a single color can be used for the markings, which are then placed on top of the image. As long as there is enough contrast for the QR reader to detect the markings correctly, just about any combination can be tried out. This is about as far as one can go with this low-redundancy level QR code. However, if a high level of redundancy has been specified when creating the code, large areas of dots can be covered up with other graphical information. Although this will give some errors on reading, the error-correction codes used will still enable the reader to establish the original message. There are some areas of the code that must not be touched. As described in the previous section, positioning, alignment and timing marks are necessary for good operation. Altering version information is probably not a good idea either. But if we stick to the central part of the code, we can take some liberties without going too much into the danger zone: For further ideas on how to use Inkscape, Mark Crutch’s ongoing series in FCM is probably the place to start - try the Special Edition Volume 1 (http://fullcirclemagazine.org/inkscape-special-edition-volume-one/), specifically Part 5 for details on how to fill regions.
COLOPHON I would like to end with a couple of practical use-cases that go a bit further than adding dynamic content to commercial posters. In my day job as a teacher, I often give students pointers on where to obtain further information, if necessary, on the topic being studied. For some time now, I have been projecting slides with the relevant URLs. However, even when using shortened URLs (“tiny” URLs), copying mistakes are made all too often. Including the relevant URLs in QR form makes it possible for students to come up to the screen and “shoot” the codes with their mobile phones - thus acquiring the link without any human error. They always carry the darn things around with them, so we might as well make good use of them, right? A second use of QR codes is to pass along short quotations from texts. QR codes are well able to hold several paragraphs of text, about what would be useful for a single study period. So, for example, Cicero’s classical discourse against Catalina could be studied in extract form. The original text goes:
“Quo usque tandem abutere, Catilina, patientia nostra? Quam diu etiam furor iste tuus nos eludet? Quem ad finem sese effrenata iactabit audacia? Nihilne te nocturnum praesidium Palati, nihil urbis vigiliae, nihil timor populi, nihil concursus bonorum omnium, nihil hic munitissimus habendi senatus locus, nihil horum ora voltusque moverunt? Patere tua consilia non sentis, constrictam iam horum omnium scientia teneri coniurationem tuam non vides? Quid proxima, quid superiore nocte egeris, ubi fueris, quos convocaveris, quid consilii ceperis, quem nostrum ignorare arbitraris? O tempora, o mores!”
Transformed into a slide for presentation to the class, once scanned, the QR code would then appear as shown (on the student’s tablet): The text can then be sent off to Google Drive or a note-taking application, and -one hopes- also be worked on.
As a side note, we can see through this example that QR codes are system-agnostic, and thus a good way of passing information between operating systems - even though some of them may be rather less open than Ubuntu.**