Graphic Coding and Decoding Methods Using Relative Coordinates

There are many processes in PCB production. In order to facilitate management and problem tracing, PCB monitoring is required in each production process. The production process of PCB is very different from that of common products. Barcode, QR code or electronic label can be pasted on common products, but not on PCB. Because corrosive chemical solution is used in many PCB production processes. In order to solve this problem, a coding method based on relative coordinates and a graphic decoding method combining Hough transform and projection transformation are proposed. This method takes into account that the most commonly used NC drilling machine in PCB manufacturing enterprises. The graphic coding method uses the relative coordinates of holes drilled on the PCB. The relative coordinates of the holes centers represent the encoding information. The image decoding method uses the Hough transform and the projection transformation. First, the captured image is transformed by Hough transform, and the center coordinates of the image are detected. Secondly, the image is projective transformed by the centers of the most lateral four holes as the feature points. The distortion image is transformed into a regular image. Then, the image decoding is realized by calculating the relative coordinates of the centers. The practicability of the method and the correctness of the algorithm are verified by experiments. This method has been used in the PCB production line of an enterprise.


Introduction
Graphic coding refers to arranging certain information according to certain rules to express certain information. Graphics decoding refers to the translation of the meaning expressed by a specific graph according to certain rules [1][2]. Different graphic coding methods have different best application areas. The most commonly used method of image decoding is image recognition. Image recognition is to use computers to process and analyze images, so as to understand the information represented by images [3][4][5][6][7][8][9]. The most common field of graphic code is two-dimensional bar code.
The key technology is the encoding method of two-dimensional bar code, that is how to generate two-dimensional bar code, and the two is decoding technology, that is, how to recognize two-dimensional bar code. In order to improve the level of information and improve the automation level of production management, the printed circuit board (PCB) production enterprise needs to test and count the PCB in every process on the production line. Because chemical corrosion solutions are used in many processes during the production of PCB, labels or bar codes cannot be attached to PCB. Due to the problem of production process, it is not suitable for engraving two-dimensional barcode on PCB. In order to solve this problem, a graphic encoding and decoding method based on relative coordinates is proposed, considering that all PCB production enterprises have drilling equipment. Drill a series of holes on the PCB board, and encode the relative coordinates of the boreholes. Considering the chemical etching solution on PCB, the contactless decoding method is used. It is proposed that PCB can be photographed by camera and then decoded by image recognition.

Coding Method Based on Relative Distance
A two-dimensional image coding method based on relative distance is adopted in this paper. The specific method is that four holes are drilled on the PCB whose center points are respective four corners of the square. The centers of the holes are also the characteristic points. The interior of a square is divided into 11 rows and 11 columns. That is, there are 10×10 intersection points. The intersection point is coded to 0-9 from top to bottom and from left to right. 10 decimal numbers encoded can be generated. Row X represents the No. X bit of numbers encoded, and the column Y represents the value of the number. For example, the 1708256789 are the 10 bits decimal encoding numbers. The meaning is that it is No. 6789 products produced on 08 2017, 25. Its coded drill hole is shown in Figure 1. In Figure 1, the size of the square is 11×11mm, and the diameter of the hole is 1mm. The values and lines in Figure 1 are added to illustrate the coding method, which is not necessary in practice.

The Decoding Process of Graphics
The function of graphic decoding is to calculate the meaning expressed according to the encoded image. In actual production, image is usually distorted and not standardized due to the improper installation of camera and unreasonable adjustment of focal length. Therefore, the captured image must be transformed into a square normal image before decoding the image. The process of image decoding is shown in Figure 2.
First, the coded image is photographed by a camera. Secondly, Hough transform is applied to the coded image, and the coordinates of the center of the holes are detected by Hough transform. Then, the projective transform is applied to the image, and the centers of the holes are took as the feature points. The deformed image is transformed into the image with regular shape and size. Finally, the image is decoded by calculating the relative coordinates of the centers of the holes.

Acquisition of Image Sample
The function of image acquisition gets the image to be decoded by shooting the PCB drilled coding holes on the production line. The ordinary industrial cameras can be selected in this system, which is equipped with LED white light source and pixels 1000×1000. When the PCB to be inspected is in the shooting range, a photoelectric signal is triggered. A coded image is captured by the camera which is controlled by photoelectric signal.

Detecting the Coordinates of the Centers of Holes using Hough Transform
The coordinates of the centers of the holes are detected by Hough transform. The basic principle of Hough transform for detecting the coordinates of the center is that the circular ( ) ( ) , , a b r . That is to say, the number of circles or cones that pass through the pixel is counted [10][11].
Due to camera installation and other reasons, the image acquired is distorted. That results some deviation of the radius of the circle in the image. But this deviation is usually not very large in this design. Therefore, the range [ ] min max , r r of r can be determined based on the known radius of holes. The speed of algorithm can be improved by narrowing the range of r .

Standardize the Shape and Size of the Image Using Projection Transformation
The 4 feature points detected by Hough transform form a quadrilateral in which the encoded graph is located. But because the installation is equal to the reason, the quadrilateral is usually not a regular square. Therefore, we need to transform the quadrilateral and internal coding patterns into a unified square. But the quadrilateral is usually not a regular square because of installation and other reasons. Therefore, the quadrilateral and internal coding graphs are needed to transform into the unified square.
Projection transformation is also called perspective mapping. It can transform the deformed image into a standard image by projecting an image into a new view plane. The function of projection transformation is shown as shown in Figure 3.
The camera is 1000×1000 pixels in this system. In order to improve the speed of encoding and decoding, the image of coded graph is reduced to less than 500×500 by controlling the distance between camera and PCB. An image of 500×500 pixels containing the coded graph is intercepted.
Then, it is transformed to an image of the 400×400 pixels by the projective transformation.

Graphic Decoding by Calculating Relative Distance
The main function of graphic decoding is to translate the coded information represented by the graph by calculating the relative coordinates of the centers of the holes. It is known that the decoding method is as follows according to Figure

Experimental Results and Analysis
Hough transform and projection transformation are applied to the collected images. The results of one of the sets of transformations are shown in Figure 4. Where, Figure 4 (a) is the initial image coded. It is distorted, that the location of the centers of the holes are different. Figure  4 (b) is the image of Hough transform of the original image, which the main function is to detect the center coordinates. Figure 4 (c) is the image of projection transformation of Figure 4 (b). The main function is to adjust the shape and size of the image. It can be seen that the locations of the centers of the holes are adjusted, and the height of the center is the same. The transformation matrix of the projection transformation is: The number "1708256789" can be obtained by decoding the normalized Figure 4 (c) which is in accordance with the pre coding. It verifies the correctness of the algorithm.

Conclusions
In the aspect of image coding, the paper puts forward the method of drilling holes on PCB. This method solves the problem that the barcode, QR code and electronic label cannot be pasted on the PCB, because the corrosive chemical solution is used in some the PCB production processes.
In the aspect of image decoding, Firstly, the pictures are adjusted the shape and size of the image by Hough transform and projection transformation after taking pictures of the coded graphics on the PCB. Secondly, then the relative coordinates of holes on PCB are calculated. Finally, the decoding algorithm can be ensured to get the information.
In practice, this method has obvious advantages. On the one hand, this method is very easy for PCB enterprises to achieve. On the other hand, the fault tolerance of all the whole systems is also very high because of the high stability of the Hough transform algorithm in the detection of holes.