How QR Codes Are Built

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to another episode of James explains where today we'll take a look at QR codes and how they're formed QR codes are formed with the 2d array of pixels which are one color to represent zero or a contrasting color to represent one they can range from version 1 which is 21 by 21 pixels which we're looking at in this video up to version 4 T which is 177 by 177 pixels one of the easiest ways to identify a QR code is the distinctive pattern in the corners these patterns are the same size and occur on QR codes of any size and are used when reading the QR code to detect the position and rotation of the code larger versions also include smaller alignment structures however the version 1 code we were looking at here does not include any of these the next structure that occurs on all QR codes is the timing structure this pattern aligns with the edge of the outer positioning squares and alternates between the two colors of the code at a size of 1 pixel this allows the reader to confirm the version of this code as well as the timing of the bits along both axes the next patterns included on QR codes are to denote the format of the data in the code the first of these is the level of error correction used in the code this can be low which can restore roughly 7% of data medium which can restore roughly 15% high which can restore roughly 30% or quartile which is able to restore roughly 50% of the data the second part of the formatting pattern is the mask that is applied to the data the mask is used to break up large blocks of identical bits to make the pattern easier to read there are several different mask patterns that are used in QR codes and each can be represented by a formula taking in the coordinates of the pixel to determine which pixels are masked larger versions of QR codes can also include a format section that specifies the version code that is used with a version 1 code like this the version information is not present the remaining section in the formatting pattern error-correction for the five bits covered so far all of the formatting data is mirrored in both sections of the formatting pattern the next part of a QR code is a single bit which is always represented as one this bit is not required for the data and also not required for the formatting information so it is relatively unused part of the code once we have this added the remainder of the code is used to represent the stored data to look at how this data is stored we first need to look at the pattern that the individual bits are arranged in the data starts in the lower right corner starting with the most significant bit of the data this pattern then follows a zigzag pattern working its way up to columns to the top of the data space this then continues back down the next two columns continuing in a right-to-left order to the bottom of the data space this pattern continues in the same manner through the remainder of the space following a general right to left up and down pattern however in larger versions with alignment patterns this pattern does change slightly to navigate around these fixed sections the first four bits in the data specify the type of encoding the data is stored in this includes numeric alphanumeric kanji hole bytes as well as other more complicated structures our data will be stored as hole bytes so we'll leave that encoding as the format in our example a QR code is able to store multiple different data types in the same code where each section starts with its own specific encoding indicator the next byte of data stores the message length our message will be 14 bytes long which is represented in binary as 0 0 0 0 1 1 1 0 using our existing color scheme of black 4 1 and white 4 0 we can transpose this data into the message length section of our code as we now know the length of the message we can show the 14 bytes that will store this data and start to fill in the bits representing the data we're storing the first byte we will store is the ASCII capital J which is represented with the following bits we can then transpose these into the first by in our data space following the same process we can fill in the remainder of the data space with the rest of our message and our QR code is starting to fill out more following our data the next four bits in the code are the end of message indicator this indicator is for zeros which now code is represented by four white pixels now that the message in our code is complete we still have ten remaining bytes of storage space which is used to store the error correction data of our message QR codes use reed-solomon error correction which is a more complicated concept than we'll cover in this video but the error correction data for a message looks like this now that the complete array of pixels have been filled we have what looks like a completed QR code but there's still one more step to follow to finalize it when scanning a QR code large sections of identical pixels can cause issues with the timing of the reader so we want to try to reduce the pixel grouping in our final code to do this a mask is applied which inverts pixels according to the pattern of the mask in generating the code multiple masks can be tested and the outcome given a score based off the size of the remaining groups for this code we're using the masks represented by this formula which applies the pattern in the highlighted cells to apply a mask we invert the bit for all the highlighted pixels which now leaves us with the final arrangement of the pixels in our code the last thing we need to make sure this code is readable is a quiet zone of 4 pixels width around the code in the same color as 0 bits this ensures the reader is able to distinguish the code from any background noise once we have applied this we have a working QR code that can be decoded by any mobile device that has QR functionality if you have any other suggestions for future James explains videos or any further questions about how QR codes work leave them in the comment section down below and as always thanks for watching
Info
Channel: James Explains
Views: 79,308
Rating: undefined out of 5
Keywords:
Id: 142TGhaTMtI
Channel Id: undefined
Length: 6min 32sec (392 seconds)
Published: Sat May 16 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.