Datamatrix Two-dimensional barcode source code analysis Detect and identify image location

Source: Internet
Author: User

Date: 2014-10-31

The code structure of the Datamatrix is basically the same as the QR code:

The function of detector is to find out the part of the symbol code from the original image, and make the perspective transformation to correct the distortion. The decoding process is similar to the QR code, and the key is how to remove the real symbol image from the original image. As stated above, the Perspectivetransform method in the digital Image warping written by George Wolberg can establish a mapping relationship between the two quads. It then corrects the possible irregular symbols in the original image to the regular rectangle by mapping each point. The main step in detector in the QR code is to find the locator, and the key to detector in the Datamatrix is to find the vertices of the four corners. The steps are as follows: 1. The position of the symbol image  whiterectangledetector (in/core/com/google/zxing/common/detector) is used to do the work. It does this by drawing a 30x30 box from the middle of the image and then pushing it to the sides to detect if there are black dots on the sides until there are no black dots on each side. As shown in the code to detect the right border: The Containsblackpoint function is to detect the black point on the line from up to down, with the x-axis coordinates. As you can see, the code is to keep right up + +, so that the left border continues to the right until the symbol image is fully rolled out. The final detection of four edges will get the approximate position of the symbol image 2, look for the symbol image four vertices    approximate range determined after you need to determine the symbol image four corner of the vertex, with four corners of the vertex can be a perspective transformation, symbol code image can be removed. Zxing in the first Four corners of the large detection frame with a 45-degree straight line to detect, as shown: In the figure of the four angle of the arrow to scan the direction shown, the first black point is detected to return. If a black dot is not detected on the line, the scan line is pushed diagonally. So you can find the vertices of the four corners. 3, determine the locator Datamatrix is at the edge of the symbol image of a circle into two L-shaped, an L is a solid line, an L is a dashed search method is a line along the 4 edge of the black and white conversion number of times the method of drawing a line here is the use of the Bresenham algorithm (HTTP/ zh.wikipedia.org/wiki/bresenham%e7%9b%b4%e7%b7%9a%e6%bc%94%e7%ae%97%e6%b3%95), the algorithm is all integers in the process of seeking straight points, Therefore, the calculation speed is greatly improved. The number of black and white transformation is the edge of the real line, more is the edge of the dashed lines, and then to find two L-shaped intersections,The lower left and upper right corner of the two points are determined, and then the distance between the two points is determined by a comparison of four vertices. 4, calculate the latitude and determine the symbol shape latitude is the symbol of how many modules on one side, the calculation method is to find the dotted line locator How many times the black and white transformation (Datamatrix latitude are even, so error correction). Latitude is calculated to know the width of each module, and then you can calculate how many of the four edges of each module. This allows you to calculate the aspect ratio of the symbol to determine whether it is a rectangle or a square. Finally, the same as the QR code, using Samplegrid for the perspective transformation and sampling transformation, the original image of the symbol image correction, transformation for us to decode the required rules, in the module of the symbol matrix.  
    • Previous: VB barcode reading and Generation tutorial

Datamatrix Two-dimensional barcode source code analysis Detect and identify image location

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.