# Real-Time Detection Method for Center and Attitude Precise Positioning of Cross Laser-Pattern
## 3 Methodology
### Cross Laser-Pattern Separation  
The X and Y axis separation of cross laser is the premise to realize the center extraction and attitude positioning of the cross laser-pattern, and the foundation is to complete the extraction of the edge line of the cross laser-pattern. However, the traditional straight line detection algorithm, such as the Hough transformation method, takes a long time and has poor real-time performance, which does not meet the requirements of this project. With the characteristics of the project, the angle of the cross spot in the image coordinate system is less than \(\pm 5^{\circ}\), and the cross laser intersects the boundary of the field of view as shown in Figure 4a. Here the rising and falling edges of the image is defined firstly. As shown in the Figure 7, the gray value curve of the image in the horizontal pixel direction is presented, here the segmentation threshold is the one that obtained by the maximum inter-class variance method mentioned above. In order to eliminate noise interference, a hysteresis is set on the basis of segmentation threshold. When the gray value of the searched pixel is greater than or equal to \"ideal threshold plus hysteresis\" and the gray value of the previous pixel is less than that pixel, the point is designated as the rising edge in that searching direction. When the gray value of the searched pixel is less than or equal to \"ideal threshold minus hysteresis\" and the gray value of the previous pixel is greater than that pixel, the point is designated as the falling edge in that searching direction. Take the left edge straight line detection process of cross laser-pattern as an example, search each pixel line by line from left to right along horizontal direction, the algorithm is shown in Figure 8. \(L\) is 1.2 times the cross-line width in pixel. Figure 8: Flow chart of edge detection line search. Figure 7: Definition of rising and falling edges. 1. If the first searched edge is raising edge, then keep searching: 1 If the falling edge is searched, then stop searching: 1 If \(\Delta X\leq L\), then store the raising edge coordinates into the feature data set; 1 If \(\Delta X>L\), then return null. 2 If there is no falling edge in the searching direction, then return null; 2 If the first searched edge is falling edge, then keep searching: 1 If the raising edge is searched, then stop searching, and store the raising edge coordinates into the feature data set; 2 If there is no raising edge in the searching direction, then return null; 3 If there is no raising edge nor falling edge in the searching direction, then return null. So far, the feature data set containing the pixel coordinates of the left edge of the cross spot could be obtained. Least square method is a mathematical method to seek the best function matching of data, and its standard is the minimum sum of squares of errors. In this paper, the left edge feature data set was used as the sample to fit the most suitable edge line, realizing the left edge line extraction. For other cross laser-pattern edges in right, upper and lower direction, edge line extraction algorithm was similar to the left one, the difference is seen in the searching directions. Therefore, the cross-laser edge lines extraction was finished, and the result is shown in Figure 9.  
On this basis, the separation of X and Y axis line of cross laser-pattern was conducted, the algorithm is introduced as follow. Taking the Y axis separation as an example, set the left side pixels' gray value of left reference line, which forms by shifting the left edge line a certain distance left-side, to be zero, and set the right-side pixels' gray value of right reference line, which forms by shifting the right edge line a certain distance to the right-side, to be zero. X axis separation is similar. In order to eliminate the influence of the overlapping part of the cross laser on the Gaussian fitting, the corresponding overlapping area on the X and Y axis was removed.