Reading QR Codes
EasyQRCode detects QR (Quick Response) codes in an image, decodes them, and returns their data.
Error detection and correction algorithms ensure that poorly-printed or distorted QR codes can still be read correctly.
![Closed](../../../../Skins/Default/Stylesheets/Images/transparent.gif)
A QR code is a square array of dark and light dots. One dot (or "module") represents one bit of information.
QR codes contain various types of data and can be different models, versions, and levels. They always contain a message, metadata about alignment, size, format, and error correction bits. They comply with the international standard ISO/IEC 18004 (1, 2 and 2005).
![Closed](../../../../Skins/Default/Stylesheets/Images/transparent.gif)
The QR code symbol consists of an encoding region, containing data and error correction codewords, and of function patterns, containing symbol metadata and position data.
A QR code must be structured with the following elements:
□ | Quiet zone: blank margin around the QR code |
□ | Finder patterns: recognizable zones identifying a QR code |
□ | Extension patterns: markers for the alignment of the QR code (model 1) |
□ | Alignment patterns: markers for the alignment of the QR code (models 2 and 2005) |
□ | Timing Patterns: data giving the module size (in pixels) |
□ | Format information: zones providing the QR code level |
□ | Version information: data giving the QR code size, for instance 25 x 25 modules (models 2 and 2005) |
□ | Data contents and error correction codewords: the primary information carried by the symbol, with additional information for error correction |
Variants of this structure exist, according to the model, format, or version of the QR code. For instance, model 1 QR codes do not feature alignment patterns but extension patterns. Micro QR codes include only one finder pattern, and no alignment pattern.
Structure of a model 1 QR code symbol
Structure of a QR code 2005 symbol
Structure of a Micro QR code symbol
![Closed](../../../../Skins/Default/Stylesheets/Images/transparent.gif)
A QR code can be one of the following subtypes:
□ | Basic: the default subtype. |
□ | ECI (Extended Channel Interpretation): the ECI subtype provides a consistent method to embed interpretation information of data in the QR code. The ECI protocol is defined in the AIM Inc. International Technical Specification. |
□ | GS1: the data contained in the QR code are formatted in accordance with the GS1 General Specification. |
□ | AIM: the data contained in the QR code are formatted in accordance with a specific industry application previously agreed with AIM Inc. The application indicator value is embedded in the QR code data. |
![Closed](../../../../Skins/Default/Stylesheets/Images/transparent.gif)
The QR code data can be any mix of these types:
□ | Numeric data (0-9) |
□ | Alphanumeric data (0-9, A-Z, /,$ , %...) |
□ | Byte data (possibly ECI-encoded) |
□ | Kanji characters |
Byte data interpretation
In a QR code, the byte data can represent any information. Their interpretation depends on the subtype of the QR code:
● | Basic subtype: |
□ | If some byte data are present in the QR code, you need to know how to interpret them. |
□ | Use the EByteInterpretationMode enum to select the corresponding byte interpretation mode (see the retrieving decoded data section in Detecting and Decoding QR Codes for more details). |
● | ECI-encoded byte data: |
□ | The ECI subtype provides an ECI table indicator. |
□ | This indicator defines the character set to use to interpret the byte data. |
□ | EasyQRCode currently supports the UTF8 conversion table (ECI table indicator 26). |
![Closed](../../../../Skins/Default/Stylesheets/Images/transparent.gif)
□ | Model 1: original QR code international standard, with versions ranging from 1 to 14. Note that the "version" of a QR code is the symbol size (in number of modules). It does not relate to the version of the standard, which is called the "model". |
□ | Model 2: improvement of model 1. It provides versions from 1 to 40. It defines alignment patterns to improve reading of distorted QR codes, or QR codes printed on curved surfaces. |
□ | Model 2005: improvement of model 2, including white-on-black QR codes, and mirror symbol orientation. |
□ | Micro QR codes: (not yet supported) smaller QR codes, from version M1 to version M4. They have been introduced to save printing space. |
![Closed](../../../../Skins/Default/Stylesheets/Images/transparent.gif)
□ | QR codes: from version 1 (21 x 21 modules) to version 40 (177 x 177 modules), with an increment of +4 x +4 modules (version 2: 25 x 25 modules, version 3: 29 x 29 modules, ..., version 39: 173 x 173 modules). |
□ | Micro QR codes: (not yet supported) version M1 (11 x 11 modules), version M2 (13 x 13 modules), version M3 (15 x 15 modules), version M4 (17 x 17 modules). |
Examples of QR codes
From left to right:
Micro QR code, version M3, 15 x 15 modules,
Model 2 QR code, version 4, 33 x 33 modules, 67-114 characters,
Model 2 QR code, version 40, 177 x 177 modules, 1852-4296 characters
![Closed](../../../../Skins/Default/Stylesheets/Images/transparent.gif)
QR codes contain error correction data. The standard offers the following levels of error correction:
□ | L: (low) about 7% of codewords can be restored |
□ | M: (medium) 15% |
□ | Q: (quality) 25% |
□ | H: (high) 30% (not available for Micro QR codes) |
![Closed](../../../../Skins/Default/Stylesheets/Images/transparent.gif)
When the QR code reader finds an array of dots that could match a QR code, it returns the "geometry" of this QR code candidate.
A QR code geometry is a set of points. It contains the coordinates of the corners of the QR code quadrangle (bottom left, top left, top right, bottom right), and the coordinates of the finder pattern centers (bottom left, top left, top right).
QR code geometry