An overview of invoice QR code scanning enhanced _02_ algorithm

Source: Internet
Author: User

Technology selection

In order to solve the problem that the QR code cannot be scanned, the appropriate technical means must be chosen. Since our app refers to someone else's developed zbar-based image recognition plug-in, without the ability to modify the image recognition plug-in, I decided to solve this problem on the server side, considering the general type of the algorithm, in the service-side verification through the program can also consider porting to the app side, improve the local scanning speed, Reduce server performance consumption. iOS and Android plug-ins have camera focus completed events, in which you can get the image information, I plan to get the focus of the finished picture, after the simple compression of the transfer to the server for resolution processing, and then the server returned by the results of the decoding as the decoded results to the foreground application.

The image analysis and operation belongs to the category of computer graphics processing, OPENCV is a very powerful graphics processing library, which is more suitable for the current demand. Because there was no contact with the graphics processing this piece, is basically learning while doing, mainly from the processing of ideas to find the corresponding graphics processing tools.

OpenCV support multiple languages, such as C + +, Python, the current network of more reference documents are based on C + +, considering the ease of programming language, the decision to use Python development. Given the need to publish an HTTP service to the app-side call, the final Python program needs to be integrated into the Django project.

So the last technology stack is: Python3.6 + Opencv-python + numpy (for matrix operations), using PIP to install two libraries:
Pip Install NumPy
Pip Install Opencv-python

Thinking analysis

Let's start by taking a real-world QR code for analysis:

This picture from the naked eye, basically is a square, the user basically is the camera perpendicular to the two-dimensional code above the shooting, rather than inclined to shoot, compared with our customer's scan results expected.

If we can get a square QR code image, it is easy to construct a coordinate system based on the anchor Point and coordinate point to split the image, get the 0/1 value within each point, and construct a new QR code image.

However, from the image to establish a coordinate system, you can find that the picture is actually not a real square, and even a rectangle is not up, can not be scaled to restore the square, from the two-dimensional code left and right side length and the length of the red box to be seen, the left segment length is shorter than the side line, So it's not even a parallelogram, which is a very important decision when we choose the graph transform algorithm.

We comb the solution, for a normal shot of the full QR code image, we need to do the following steps to resolve the image content:
1. Convert the image into a square
2. Establish a coordinate system based on the location graph and coordinate point information
3. Cut the image according to the coordinate system and extract the data information from each cell
4. Reconstruct a standard two-dimensional code image based on the extracted data information

In line with the above, I split the program subject into the following three sections, which will be described in detail in the subsequent chapters of each section

1. Image preprocessing
2. Image coordinate system construction
3. Data reading and refactoring

An overview of invoice QR code scanning enhanced _02_ algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.