
Abstract: Two-dimensional codes not only bring convenience to people’s lives, but are also widely used in the industrial field. How to develop QR code function in embedded hardware? This article will introduce you to the ZLG QR code recognition algorithm and teach you how to quickly build a QR code with good recognition effects on the ZLG hardware platform.
The essence of a two-dimensional code is to convert a piece of text information into a picture that can be decoded and recognized according to a certain agreed encoding method. Because a two-dimensional code is just a coding method and a carrier of information, it can be seen that the key to the use of a two-dimensional code is not the two-dimensional code, but how to define the text information and agree on the purpose of the text information. At present, the QR code payment function has changed our way of life. You no longer need to bring cash when you travel. You can use the QR code to take buses, subways, taxis, pay parking fees, and pay for shopping in supermarkets. Because QR codes have the characteristics of large information capacity, high reliability, and strong security and anti-counterfeiting, QR codes are used for common QR code payments.
Next, the ZLG two-dimensional code algorithm will be introduced, and the characteristics of the ZLG two-dimensional code algorithm, interface calling method, achievable platform and performance and effect Display will be explained separately.
1. Characteristics of QR code algorithm
Due to the rapid development of QR code payment related fields, ZLG has carried out targeted research and development and optimization of QR code recognition algorithms. Currently, the ZLG QR code algorithm library only provides calls to the QR code interface. The QR code recognition algorithm features are as follows:
Provided in the form of an algorithm library, supports multi-platform migration, can be used on existing hardware, and greatly saves costs;
The algorithm is simple to call, which is convenient for developers to quickly realize the QR code recognition function;
At the same time, it supports mobile phone screen barcode and paper barcode, which has a wide range of applications;
Fast recognition speed, optimized for mobile payment scenarios, can realize flash payment;
Support mobile phone broken screen QR code recognition, which fits the actual use scene.
2. QR code interface call
The ZLG QR code algorithm library currently provides a list of files: aw_qrcode.h, libqr.a or libqr.so. The algorithm call method is simple, and only requires three steps of algorithm initialization, decoding and memory release. The QR code algorithm header file “aw_qrcode.h” interface is as follows:
Let’s take the M7 series platform based on the AWorks system as an example. Before successfully calling the ZLG QR code algorithm, the work that needs to be prepared is as follows:
Ensure that the video frame data of the camera can be obtained (different platforms can have different implementation methods, and the linux system can obtain the image frame data through opencv), and convert it to a single-channel grayscale image. For example, the M7 platform demo based on the AWorks system uses the following interface to obtain images in RGB565 format.
Since the acquired image is in RGB565 format, it needs to be converted to a single-channel grayscale image. The interface is as follows:
At this point, the preparatory work has been completed, and the gray-scale image data required by the algorithm has been obtained. Next, the algorithm is called. There are three steps to call the QR code recognition interface.
First, use the algorithm initialization interface to realize the initialization operation of the memory:
Then, the QR code decoding interface can be used to realize the two-dimensional code image decoding operation, and the address pointed to by the pointer imgData is the address where the grayscale image is stored.
Finally, release the memory allocated during the initialization process:
The pseudo code for calling the QR code algorithm on the M7 platform based on the AWorks system is as follows:
3. ZLG algorithm cooperation mode and platform support
The ZLG QR code algorithm can be freely opened to all engineers in the form of an SDK package, and only need to use the ZLG embedded core board (hardware platform) to quickly develop a QR code recognition application with commercial performance. In principle, the algorithm can support all hardware platforms based on AWorks and Linux systems. At present, the related performance of the M7 series platform based on the AWorks system and the A7 and A8 series platforms based on the Linux system are mainly tested, and it is available for use by providing a static library or a dynamic library.
The algorithm performance of each platform is as follows:
Four, effect display
The QR code recognition demo based on the cortex-m7 series M1052-M16F128AWI -T platform is equipped with a 4.3-inch LCD screen, which is similar to a mobile phone scanning experience, quickly recognizes the QR code and displays the recognition result. The effect is as follows:
AWorks system M7 platform QR code algorithm demo.mp4
The video shows the cortex-m7 hardware platform based on the AWorks system, paper and screen code recognition under normal continuous code scanning, and automatic sensing (by sensing the code scanning operation to trigger the algorithm, the screen is bright and dark to simulate supplementary light Lights on and off) Paper quality and screen code recognition under scanning code conditions, and screen code recognition under broken screen conditions.
M1052-M16F128AWI-T product picture:
Five, about the algorithm library acquisition
For the acquisition of the algorithm library, please consult the relevant market personnel of ZLG Ligong Technology and ZLG Zhiyuan Electronics.
The Links: 2MBI300VB-060-50 HDM64GS24Y-4-WRXF
Link to this article:The “soft” power of Ligong Technology’s embedded platform-QR code algorithm