This article comes from WeChat WeChat official account:Ai faner (id: ifanr), Author: Chen Wenjun, title map from: vision china
We scan the code almost every day, log in to the website, register information, pay for consumption, add friends … As long as we open it and scan it, we can save a lot of tedious steps.
Every time you turn on the tool to scan the code, these tools usually give a 1:1 scanning code box. Align the box with the QR code, and the mobile phone can immediately identify the information in it.
However, I wonder if you have noticed that even if these tools frame the "scanning area", sometimes scanning can be completed without aligning the frame. As long as the QR code is within the camera’s framing range, the system can immediately identify the content.
Then what’s the use of this box?
In fact, this has a lot to do with the purpose of each app scanning function. Looking at the 10 most commonly used apps in our daily life, the design of QR code scanning pages can be divided into several categories:
Fixed-area scanning is the code scanning mode that we are most exposed to at present. Users need to aim their mobile phones at the QR code scanning to make them recognize. If the target QR code is not in the frame, the app cannot recognize the content.
In some of our more commonly used apps, such as WeChat and Alipay, they have changed from "fixed frame scanning" to "full screen scanning", that is, the entire mobile phone screen is a scanning frame.
The mobile phone can recognize without facing the QR code, and the recognition speed is much faster than that of framed scanning. Before the camera is in focus, the system can recognize the information immediately.
The QR code can be recognized even if it is not in the box (the actual speed is faster than GIF).
Of course, there is also an example here. When I turn on Weibo code scanning, the page is designed with a fixed code scanning area, but the scanning mechanism of app is actually full screen scanning. So every time I prepare to scan, the information has been read before the QR code enters the box.
Is the designer lazy? Not necessarily.
It is obviously not enough to pry open the details of the scanned page, but also need to consider from many aspects, such as the hardware used for code scanning and the decoding ability on the software level.
In fact, it is not difficult to make the scanned code page full screen, but it is not unnecessary to vacate a box as the scanning area.
The reason is that when the QR code first entered our life, neither the app itself nor the code scanning equipment was specially optimized, and the success rate of code scanning was often related to the ambient light, distance and clarity of the QR code.
Personally speaking, the code scanning area provides a hint of code scanning recognition, and its task is to tell the user that the camera is ready for scanning, so long as it is aligned, the information can be read. As for the device itself, whether the camera can quickly identify the QR code has something to do with the focusing performance of the camera and the decoding operation ability of the processor.
The history of QR code can be traced back to the 1980s, but it didn’t begin to spread to our daily life until the past decade.
However, in the early days, the focusing response and speed of smart phones were relatively slow, and they were also easily affected by ambient light and lens clarity. Therefore, when developing app scanning pages, developers need to adjust the camera’s framing range to make the camera focus on a specific area, instead of focusing on a wide area.
The code scanning speed of the old mobile phone is slower than that of the new mobile phone (pay attention to the focus bellows and use Meizu MX5 test)
Simply put,Separating the code scanning area is actually to take care of the equipment with relatively slow focusing speed in the early days.. The principle is similar to the fixed-point focusing area of the camera. The camera only measures and focuses on the area within the square frame, thus reducing the interference of other factors around the target QR code, thus improving the camera focusing speed and the success rate of code scanning.
Looking at it from another angle, the code scanning box is not only a way to tell the user that the scanning function is on, but also a way to improve the recognition accuracy. As long as the key elements of the QR code in the box meet the requirements, the recognition accuracy is about 100%.
In order to enable users to scan codes in different environments and conditions, developers will integrate flash, remote automatic zoom, etc. when using scanning code development libraries such as zxing, all of which are aimed at enabling mobile phones to see the QR code information in the box and facilitate users to scan in any use situation.
However, in recent years, the camera focusing speed of smart phones has improved rapidly, and the ability of the core processor to process images has gradually improved. Therefore, modern mobile phone code scanning does not need long-term focusing, even if it does, it can only be completed in less than one second.
At the same time, with the application of QR code becoming mainstream, app developers also improve the speed and success rate of code scanning by creating their own code scanning engine, instead of relying solely on the hardware level to complete the identification process-WeChat is one of them.
Although WeChat is not the first app to use QR code, it has to be admitted that it is the most frequent app to use QR code and scan code, which not only makes users think of WeChat once they mention "scan code", but also indirectly promotes WeChat’s development of scan code technology.
Before QBar came out, there were mainly two kinds of code scanning engines, zxing and zbar. These two engines have different advantages, but both have their own shortcomings. At the same time, these two engines have more restrictions on barcode recognition than QR codes.
In 2016, the WeChat technical team introduced the working principle of QBar code scanning engine in a tweet published by WeChat official account WeChat School.
Compared with the traditional code scanning method, QBar will screen out the barcode/QR code content through the pre-judgment algorithm when scanning the code page, quickly identify the graphic code information in front of the screen through scanning the page, and then decode the image through QBar engine to output the final result.
In other words, when the user opens the code scanning page, as long as there is a barcode or two-dimensional code image in the frame, the system has already started to predict the user’s code scanning target and start to classify and identify it.
GIF can be recognized only in one corner (using WeChat scan function)
And because the QR code itself also has a fault-tolerant mechanism.(Originally designed to make the QR code work normally under damage)In fact, the camera does not need to compare the complete QR code, just find the key points of the QR code within the fault-tolerant range to identify it. Combined with the characteristics of QBar engine, the code scanning camera can identify and decode the QR code and its key information in one second by predicting and screening it.
Flow chart of WeChat code scanning prediction module, picture from: WeChat School
The recognition principle announced by WeChat seems complicated, but in modern smart phones, these tasks can only be completed in a few milliseconds. According to the reference data of "WeChat School",The decoding time of WeChat on iOS client is 5 milliseconds, and that of Android client is 12 milliseconds..
As for why the code scanning speed of iOS devices is faster than that of Android, this may be related to the decoding performance between iOS and Android devices at that time.
IPhone 11 Pro Max uses WeChat code scanning speed (slightly accelerated due to the number of GIF frames).
In the test in the daylight environment, the iPhone using A13 processor has indeed completed the recognition before focusing, and even the iPhone 7 in 2016 can achieve the "one-stroke scanning" response; The Android flagship using Snapdragon 865 also responds very quickly, but there is a slight speed gap compared with iOS.
If the iPhone scan code is "complete identification before you see it clearly", then Android is "complete identification immediately after you see it clearly".
The difference between the two is only in milliseconds.
One plus eight uses the code scanning speed of WeChat (slightly accelerated due to the number of GIF frames)
However, although the scanning speed of Android is slightly lower than that of iOS, compared with the speed difference between the two camps five years ago, the improvement of Android has been very obvious, which is almost the same as the recognition speed of iOS. If you don’t pay attention, you can hardly see the difference between the two.
Therefore, the recognition time of the past 5/12 milliseconds is not absolute, and they will change with the iteration of mobile phone hardware and soft algorithm.
It is worth mentioning that when using Android devices to scan multiple QR codes at the same time, multiple QR codes in the screen will be identified together, and then an entrance will be provided for users to choose their own objects; Although the recognition speed of iOS is faster, when faced with multiple QR codes, the system chooses one more.
Wechat without a fixed scanning frame can identify multiple QR codes at the same time (note: at present, this function is only tested in gray scale in some Android clients)
In addition to WeChat, Alipay also uses a full-screen scan similar to WeChat. Although its recognition speed is slightly slower than WeChat, it can also achieve the level of recognition by raising your hand.
According to the technical documents shared by CSDN users, Alipay’s code scanning function is integrated by libqrencode library. Although it is not Qbar of WeChat, its recognition speed under deep optimization can also be calculated in milliseconds.
With a more perfect algorithm engine and hardware decoding ability, mobile phones have become "sensitive" to the identification of QR codes, and they can quickly identify the contents of the codes without high-definition images.
In this way, the box used to fix the focus in the past will naturally be replaced by full-screen scanning.
Alipay’s recognition speed is also very fast (iPhone 11 Pro Max test).
The changes in the form of code scanning are particularly obvious in the apps with more code scanning behaviors such as WeChat, Alipay and Weibo.
Users can quickly complete code scanning transactions on WeChat and Alipay; Weibo allows users to quickly complete the two-step verification of code scanning.
The change of code scanning speed and accuracy depends on the improvement of code scanning engine and algorithm by several head enterprises, but from the side, it actually benefits from the continuous upgrading of mobile phone hard power. Only a camera with higher resolution and a processor with better computing performance can carry more complex decoding engines and algorithms and realize millisecond scanning code recognition.
IPhone 7 and the old version of WeChat scan box
From the evolution of the code scanning page, it can be seen that the code scanning efficiency of mobile phones is constantly improving, and commonly used apps can complete scanning without aligning codes when scanning codes. Then let’s look back, is the most primitive scanning code box still meaningful?
Actually, there is.
First of all, the current retention rate of old equipment is high, and the service life of smart phones is generally 2 to 3 years, or even 4 to 5 years. The focusing and recognition capabilities of old phones are not as good as those of new phones.
The function of the scanning box, as mentioned above, is convenient for the old mobile phone to quickly find the focus and improve the scanning speed and accuracy of the QR code, and it can also intuitively guide the user to aim the mobile phone at the code scanning, which actually indirectly improves the recognition efficiency of the old mobile phone every time it scans the code.
Although JD.COM and Taobao scan codes are full screen, they still need to be scanned in the frame.
In addition, although WeChat has its own code scanning engine, not all app developers have the ability to develop engines or specially optimize engines.
For the app with little demand for code scanning, the scanning function is mainly to scan the QR code, and the scanning success rate is more important than the speed. Therefore, under the premise of not optimizing the recognition engine, using the original in-frame scanning can ensure that both old and new devices have a high recognition success rate.
The popularity of two-dimensional code greatly simplifies our operation in inquiry, payment and registration, and the mobile phone used to scan it is also becoming efficient and diversified with the upgrading of decoding ability of software and hardware.
Today’s code scanning page can scan more than two-dimensional code, and it can also be combined with neural network to recognize things. According to the introduction of the latest function document of WeChat, based on 850,000 plant image data provided by Kunming Institute of Botany, Chinese Academy of Sciences, at present, the sweeping function can identify more than 36,000 plants, which basically covers the data of flowers and trees we see every day.
It can be seen that the code scanning page is carrying more functions with more meta-algorithms.
For this reason, the scanning code box used to guide users and improve the focusing speed of equipment in the past has gradually withdrawn from the stage with the algorithm upgrade, hardware iteration and the scanning code page supporting more scanning targets. howeverIt didn’t really leave us, just evolved from 1:1 in the past to the same proportion as the mobile phone screen..
This article comes from WeChat WeChat official account:Ai faner (id: ifanr), Author: Chen Wenjun