A Rapid Method of Monocular Image Measurement Based on Rectangle Information

A method of rapid measurement of monocular image based on rectangle information is proposed in this paper. Based on the pinhole imaging model, a fast method of calculating the object size in monocular image is derived by fitting the straight line and then finding the intersection point of the straight line. The algorithm can not only measure the size and absolute depth of the object in monocular image, but also meet the conditions of the specific pinhole imaging model with a distance far greater than the focal length. The complexity of the algorithm is low, and it can meet the requirements of real-time calculation. It provides a new idea for the use of small and micro-computing platform.


Introduction
With the development of computer vision technology, there is a strong application demand in the field of vehicle monocular ranging model based on the principle of monocular vision and the corresponding ranging algorithm [1], mobile robot positioning, navigation system [2], andUAV positioning [3]. To complete 3D scene modeling, it is very important to measure the depth, relative distance and other information of 3D scene based on a single image, that is, monocular vision ranging.
Different from binocular vision, monocular vision ranging can only measure distance information by previous knowledge, such as image size change [4], which is very difficult. Some of the existing methods mainly include the indirect measurement of single strain matrix [5] and the direct measurement based on invariants [6]. The calculation of single strain matrix method is complex, and the applicability of direct measurement method based on invariants is narrow. However, with the introduction of neural networks and deep learning methods, more and more scholars begin to study in the field of monocular vision ranging. Typical research results include: Lim J H et al. proposed a hybrid positioning method combining single frequency GPS receiver and monocular vision sensor [7]; Wu et al. studied the integration of monocular camera and laser rangefinder [8]; Han, Lessmann, et al. proposed a monocular vision distance estimation algorithm based on probability [9][10]; Kendall et al. used the deep convolution neural network to explore the method of positioning based on geometric scene learning error cameras [11] and the monocular vision image measurement method based on entropy and weighted Hu's invariant moment proposed by He Lixin of the University of Science and Technology of China [12]. Compared with the monocular vision ranging method based on neural network and deep learning, which needs a lot of data for training and learning, the model-based vision location method is more available. Therefore, a rapid solution algorithm based on the distance information of edge detection and Hough transformation is proposed. Experiments show that the error and time complexity of the algorithm meet the practical requirements.
sin sin sin sin sin sin sin sin In the same way, if the point B coincides with ' B , we can get: We set From equations (6)- (7): , let the diagonal length be L, with the following relationship: It can be concluded from (8) and (9) that: Union (6)-(7) can calculate the coordinates of the rectangular reference in the real world. Furthermore, the normal vector of the plane of the reference rectangle is:

Derivation of Distance Formula
The key to solve the length of line segment is to find the coordinates of the end point. If the end point of the line segment and the rectangular reference ' ' ' ' A B C D is coplanar and the coordinates and normal vectors of a point on the plane are known, there are: The absolute depth from this point to the center of the lens is: The distance between the point i and the point j is: If the line segment to be determined and the rectangular reference ' ' ' ' A B C D is not coplanar, the solution can be completed according to the above formula after the normal vector of the plane where the line segment is located has been solved according to the spatial geometry knowledge and the plane has been calibrated.

Intelligent Line Detection Method
In order to reduce the pixel pick-up error, when calculating the image vanishing point and obtaining the reference rectangle vertex, the intersection point of the line can be obtained by fitting the line. The common methods of obtaining lines intelligently include: line detection by least square method [14], minimum distance method, Radon transform line detection and Hough transform line detection [15]. In this paper, Hough transform is used to realize line detection. The steps are as follows: (1) Image pre-processing. Because the original image is usually large in size and contains many lines, which is not conducive to the selection of target lines, the original image needs to be cut. Take the detection of rectangular reference as an example, the image before and after cutting is shown in figures 4a-4b. At the same time, the image needs to be grayed, as shown in figure 4c.
(2) Edge detection. The purpose of edge detection is to identify the points with obvious brightness change in digital image. The commonly used edge detection operators are Roberts, Sobel, Prewitt, Laplacian, Log/Marr, Canny, Kirsch, Nevitia, and so on. Sobel operator has a good effect on image processing with more gray gradients and noise, and its edge location is more accurate, so it has been widely used. In this paper, Sobel operator is used to process image, as shown in figure 4d.

Measurement Accuracy
Define the relative error of the measurement: calculated dimensions measured dim ension relative error= *100% measured dim ension   Figure 6 is an image taken by the mobile phone, in which the size of A4 paper is 297 210mm  . The objects to be measured are the dimensions of floor tiles, mud box and wall tiles, and the absolute depth of the common end point of the line segment. The calculation results retain 2-bit decimal as shown in table 1. For ease of viewing, the measured value is also marked in figure 6, where the value in brackets is the relative errors. The measured value in table 1 is obtained by taking the average value of scale for many times, leaving a decimal place of 1 bit. In order to reduce the influence of other factors on the model error, firstly, clear photos are selected; secondly, the edge of the object to be tested is easy to be extracted; thirdly, in order to reduce the error caused by camera distortion, try to avoid close shot as much as possible, so as to meet the condition of pinhole imaging model with the object distance far greater than the focal length.
It can be seen from table 1 that the maximum error of object size measurement is 5.97%, indicating that the model in this paper can complete the measurement of monocular image. The measurement error of the size of the object on the wall is obviously larger than that of the object on the ground, mainly because the cumulative error is produced when the cross-plane measurement is produced. At the same time, the experiment also shows that this algorithm can measure the absolute depth of the point on the object. Table 1. Field measurements and measurement errors.

Time Complexity
Because of the length of the solution line segment, the key is to find the coordinates of the end point. In order to facilitate the statistics of calculation time, this paper uses the time measurement algorithm to solve the complexity of a single point, the formula is as follows: total calculation time of N points to be solved time complexity= number N The platform used in the experiment is Xiaomi computer pro, and the CPU is Intel ® coreTM I5-8250u, 8GB memory, 64bit win10 system, software platform is MATLAB 2017a.The experiment calculates a total of 11 points calculation time (units: seconds). Each point is calculated 10 times to get the average. The curve of the total calculation time with the number of points to be calculated is shown in figure 7.
It can be seen in the figure that the trend of change is approximately linear, and the fitting results are as follows:  Figure 7. Change curve of total calculation time with the number of points to be calculated.

Conclusion
Based on the pinhole imaging model, a fastmonocular image measurement method based on rectangular information is derived in this paper. Compared with He Lixin's measurement of monocular vision image, it does not need to take two images of the same scene, and onlya single photo is enough to complete the measurement of the size and absolute depth of the object in the photo. The algorithm complexity in this paper can meet the requirements of real-time calculation. From the experimental results of this paper, the applicability and effectiveness of the algorithm have been confirmed, which provides a new solution for the occasions with limited computing power but the real-time computing requirements. Considering the clarity of the tested image, that is, the quality of the shooting light and the difficulty of the edge extraction of the object to be tested, will have an impact on the accuracy of the algorithm, the next work is to further improve and optimize the algorithm in combination with the above factors.