How QR code works

QR code (Quick Response code) is a type of two-dimensional barcode that contains encoded information. It looks like a black-and-white square with many smaller black and white squares inside. Let’s explore how QR codes work.

how QR code scan works

Basics

  1. Camera: First, point your smartphone camera at the QR code. Most modern smartphones come with a built-in QR code scanning feature. However, it’s not always necessary to use the camera directly. On our website, you can find instructions on how to “scan” a QR code from a screenshot on our website.
  2. Scanning: The camera captures an image of the QR code and sends it to a special application or built-in function for processing.
  3. Decoding: The program reads the black-and-white squares and converts them into digital information. This could be text, a link to a website, contact details, or other useful information.
  4. Action: After decoding, the phone performs an action based on the content of the QR code. For example, it opens a webpage, adds a contact to the address book, or displays a text message

Now, let’s dive deeper into each of these steps.

Camera

The first step in using a QR code is to point your smartphone camera at it. It doesn’t matter if it’s a static QR code or dynamic QR code — at this stage, they work the same way. Yes, in this case, the resolution and quality of your phone’s camera matrix do matter.

The camera acts as a viewfinder, capturing the image of the QR code. The phone’s camera sensor detects the contrast between the black and white squares, allowing it to see the pattern clearly. Modern smartphone cameras are highly sensitive and can quickly focus on the QR code, even in low-light conditions. The viewfinder helps align the QR code within the frame, ensuring that the entire code is captured accurately.

Let’s take a look at what’s inside a QR code

QR code patterns
  • Quiet Zone: Grey area around the QR code.
  • Finder Pattern: Yellow squares in the corners of the QR code.
  • Alignment Pattern: Green square inside the QR code.
  • Timing Pattern: Blue lines inside the QR code.
  • Version Information: Purple area near one of the Finder Patterns.
  • Data Cells: The main part of the QR code where the data is stored (black and white cells).

How smartphone camera identify and orient QR code?

Finder Patterns

To identify and orient the QR code correctly, the scanning software looks for the three large squares located in three yellow corners (in the top-left, top-right, and bottom-left corners) of the QR code. The Finder Patterns themselves do not differ significantly between different versions of QR codes. These patterns remain consistent across all versions of QR codes to ensure the scanner can accurately detect the code regardless of its size or data capacity.

Alignment Patterns

Alignment Patterns are important features in QR codes starting from version 2 and above. They help the QR code scanner read the code correctly, especially if the QR code is a bit crooked or printed on a curved surface. They look like a smaller black square inside a white square, which is then inside another black square (see the image above). As the version number of the QR code goes up, more Alignment Patterns are added to keep the scanning accurate. For example:

  • Version 2: Has one Alignment Pattern in the center.
  • Version 3: Adds more Alignment Patterns near the edges and center.
  • Higher Versions: Keep adding more Alignment Patterns to cover the bigger QR codes.
Timing Pattern

Timing Patterns (blue at the image above) help QR code scanners read the code correctly. They are lines of black and white squares that run between the big squares in the corners (Finder Patterns). The main job of Timing Patterns is to help the scanner figure out the size and shape of the QR code’s grid. This ensures that the data is read accurately

Version Information

This block (purple area at the image above)helps QR code scanners know which version of the QR code they are reading. This is important because different versions can store different amounts of data. QR codes come in different versions, from version 1 to version 40. Higher versions can store more data. So version 1: smallest — Version 40: Biggest

Based on all the data from the QR code patterns, the camera can recognize which part of the image in the viewfinder is a QR code.

Scanning

Once the QR code is in the viewfinder, the camera quickly adjusts its focus and exposure settings to ensure the QR code is clear and well-lit. The camera captures a snapshot of the QR code. This is a high-resolution image that ensures all the small details of the QR code are visible. If it’s dark or the QR code is far away, you might need to adjust the lighting or move closer so the camera can capture the image properly. The processed image is then sent to a special application or built-in function designed to read QR codes. This function will handle the decoding process.

Decoding

Real-time Analysis! All these steps happen almost instantly. The camera continuously captures and processes images in real-time as you hold your phone over the QR code. This allows the phone to quickly recognize when a QR code is present and ready to be decoded. After the camera captures an image of the QR code, the decoding process begins. Here’s what happens step-by-step:

Image Analysis

The captured image is sent to a special application or built-in function that starts analyzing the QR code. It looks for the key patterns like we talking before: Finder Patterns, Timing Patterns, Alignment Patterns, and Version Information.

Grid Formation

The app forms a grid based on the patterns it detected. This grid helps it understand where each module (small square) of the QR code is located.

Binary Conversion

Each module in the QR code is either black or white. The app converts this pattern of black and white squares into a binary format (1s and 0s)

Error Correction

QR codes have built-in error correction. This means that even if part of the QR code is damaged or dirty, the app can still read it and make the code readable. It uses Reed-Solomon error correction to fix any errors and ensure the data is accurate.

Data Interpretation

The binary data is then interpreted according to QR code standards. It could be a URL, text, contact information, or other types of data. Finally, the decoded data is displayed or used by the phone to perform an action. For example, it might open a website, show a message, or add a contact to your address book.

Action! Displaying the Result

After decoding the QR code, the phone often displays a preview of the information. For example:

  • If the QR code contains a URL, the phone might show a part of the URL on the screen.
  • A message might pop up asking if you want to open the link in your browser.
  • If the QR code has contact information, a preview of the contact details will appear, asking if you want to save it to your phone.

This preview helps you quickly understand what the QR code contains and decide whether to take action. Thanks to this technology, mobile devices can quickly convert encrypted data into readable information. The QR code reader makes accessing information easy

About The Authors

Scroll to Top