Family Best Time >> Electronics

The Anatomy of a QR Code:How QR Codes Work

QR codes, like the barcodes they enhance, convey information through a graphic code of black and white pixels. Where a barcode is one-dimensional, a QR code is two-dimensional. In this content, this means that information is transmitted by reading both horizontal and vertical pixel locations, rather than just horizontal position.

As such, humans can decode parts of a QR code and translate the content manually, although this is usually cumbersome and time-consuming. There is usually much more information included in a QR code than the short numerical strings contained in a UPC barcode, which means that human decoding is not necessarily useful or expedient.

QR codes can be decoded by any smartphone and dedicated QR scanners and can contain any text string. This allows web addresses to be encoded into QR codes, which can automatically send the scanning device to the specified URL in the default browser. Unlike barcodes, QR codes also include an error checking component. This means that the QR code can still be successfully decoded even if some parts of the code are unreadable.

Common uses of QR codes

The Anatomy of a QR Code:How QR Codes Work

The most visually distinct element of the QR code is the square blocks used to orient the code when scanned by the reader. This allows the code to be scanned in any orientation, including upside down, and convey the correct message. These four blocks (three in the corners and one embedded in the lower right) appear in every code and allow the code to be decoded correctly in any orientation.

Around these blocks the format version, error checking version and decoding mask are encoded. The QR code is surrounded by an area of ​​white space called the “quiet zone” which helps the reader find the edges of the code.

QR codes can be of different sizes. The largest QR code, which measures 177 x 177, can contain up to 1,264 characters of ASCII text. The most commonly used QR size is between 29 x 29 and 33 x 33, which can hold around 50 ASCII characters. All sizes are interoperable with modern playback devices like smartphones.

Anatomy of QR code:checking and error-hiding

The Anatomy of a QR Code:How QR Codes Work

The number of error control bits is determined by the level of error control applied, called the EDC level. Depending on the EDC level used, different numbers of characters can be recovered if lost or missing. The higher the error checking level, the less space is left to contain the message. Most QR code generators will employ the correct level of error correction for message length and dimensions.

  • L (Low) 7% of characters can be restored.
  • M (Medium) 15% of characters can be restored.
  • Q (Quartile) 25% of characters can be restored.
  • H (High) 30% of characters can be restored.
The Anatomy of a QR Code:How QR Codes Work

The bits are masked to ensure that the data is expressed efficiently (avoiding all zeros or all ones, for example). This mask is represented as a binary string, which is mathematically combined with the message to produce the QR code. This does not encrypt the message and the 'key' needed to decode the masking is included with the QR code.

Anatomy of QR code:reading QR codes

The Anatomy of a QR Code:How QR Codes Work

The QR code is read in the lower right corner. Pixels are read as groups of 8, containing one byte per 8 pixels. Depending on how the QR code is encoded, these bit patterns will relate to different characters. Although ASCII is probably the most common encoding, the specification also includes options for digits, kanji, and other encodings. The four-bit pattern in the lower right corner of the QR code (marked “Enc” in the diagram above) determines how the bits will be decoded.

Conclusion

QR codes are tedious to decode manually, but if you know how to read the code, it is technically possible. The flexibility and robustness of QR codes ensure that they will remain a popular barcode format for the foreseeable future.

Image credit:Yaohua2000