Inclinometer Assembly Error Calibration and Horizontal Image Correction in Photoelectric Measurement Systems

Inclinometer assembly error is one of the key factors affecting the measurement accuracy of photoelectric measurement systems. In order to solve the problem of the lack of complete attitude information in the measurement system, this paper proposes a new inclinometer assembly error calibration and horizontal image correction method utilizing plumb lines in the scenario. Based on the principle that the plumb line in the scenario should be a vertical line on the image plane when the camera is placed horizontally in the photoelectric system, the direction cosine matrix between the geodetic coordinate system and the inclinometer coordinate system is calculated firstly by three-dimensional coordinate transformation. Then, the homography matrix required for horizontal image correction is obtained, along with the constraint equation satisfying the inclinometer-camera system requirements. Finally, the assembly error of the inclinometer is calibrated by the optimization function. Experimental results show that the inclinometer assembly error can be calibrated only by using the inclination angle information in conjunction with plumb lines in the scenario. Perturbation simulation and practical experiments using MATLAB indicate the feasibility of the proposed method. The inclined image can be horizontally corrected by the homography matrix obtained during the calculation of the inclinometer assembly error, as well.


Introduction
The photoelectric measurement system detects and measures objects by placing a visible CCD or an infrared CCD in a fixed site. Due to terrain variations in the shooting range, a variety of inertial sensors or inclinometers are needed to assist attitude calculation [1][2][3][4][5] and image stabilization [6] for the detectors in the system. With the rapid development and wide application of these devices, the calibration of photoelectric measurement systems is becoming a hot research topic both domestically and overseas, as they are widely used in aerospace, navigation [7][8][9][10][11], automotive robots [12,13], and many other fields [14]. Low cost [3][4][5], high precision, small size, low power dissipation, high overload and high reliability are the directions in which the development of photoelectric measurement systems is focused [15][16][17][18].
Detectors in photoelectric measurement systems should have high angular resolution, which increases the measurement accuracy. During the process of calculating the camera attitude Hirata [27], et al. presented a method for measuring the thoracic kyphosis angle in an upright standing position with a digital inclinometer and a digital camera. Results showed that the thoracic kyphosis angle of the digital inclinometer was significantly correlated with the angle derived from the digital image analysis, which suggested that a digital inclinometer is an instrument that is simple and easy to use for measuring the thoracic kyphosis angle in the clinic.
In Ref [10], Fabio, et al. proposed a method of using the altitude of celestial bodies to determine position in unknown territory. The experimental setup was similar to that used in our paper, consisting of a camera, a digital inclinometer, neutral density filters and an adjustable platform. The method obtains the position on Earth based on the principle that "a set of circles of equal altitude can be intersected to yield viewer position". The measurements are processed by non-linear least-squares optimization, replacing the tables used by mariners [28], and which comprises one of the biggest innovations of this method. This paper also analyzed system calibration, providing much inspiration with regard to error analysis.
Motivated by the currently available methods, a new method for inclinometer assembly error calibration and horizontal image correction is proposed based on plumb lines in the scenario. The major contributions of the method proposed in this paper can be summarized as follows.
(1) Based on the principle that "the plumb lines of edges of constructions in the real world should become vertical lines on the image plane after horizontal correction of the attitude of the camera by the inclinometer", only the angle information of the different attitudes obtained by the inclinometer and the plumb lines in the acquired images are needed to calibrate the inclinometer assembly error matrix in the photoelectric system, which is fast and easy. (2) The inclinometer assembly error matrix expression in photoelectric systems is analyzed in this paper, and an optimization function to achieve the optimal solution for the assembly error matrix by minimizing the Sum of Squared Residuals (SSR) is established. (3) A captured image with an arbitrary inclination angle can be horizontally corrected after the system calibration in order to test the correctness of the calibration result. (4) Factors affecting the accuracy of the calibration results are analyzed by means of a simulation perturbation experiment and a practical experiment, which show sufficient accuracy for the proposed method. (5) The experimental setup is simple to implement. The calibration process is easily operated.
The experimental results are stable and effective.

Inclinometer Assembly Error
For some photoelectric measurement systems that employ inclinometers and cameras, the inclinometer coordinate system and the camera coordinate system cannot be completely overlapped during the practical installation process. Figure 1 shows an example of these two coordinate systems, where C − X c Y c Z c , O i − X i Y i Z i and c − xy represent the camera coordinate system, the inclinometer coordinate system, and the image plane Π, respectively.
The transformation relationship between them can be expressed as where X c and X i represent the coordinates of the spatial point of the camera and the inclinometer coordinate system, respectively. R ic and t ic represent the matrices of rotation and translation from the camera to the inclinometer coordinate system, respectively. In practice, the inclinometer is generally placed close to the camera in photoelectric measurement systems, while the distance between the measurement system and the scenario to be measured is greater than the translation distance t ic between the camera and the inclinometer. Thus, t ic can be ignored [29]. In this paper, we define the rotation matrix R ic from the camera coordinate system to the inclinometer coordinate system as the inclinometer assembly error, and we are aiming to calibrate this matrix by using the information in the scenario. experimental results are stable and effective.

Inclinometer Assembly Error
For some photoelectric measurement systems that employ inclinometers and cameras, the inclinometer coordinate system and the camera coordinate system cannot be completely overlapped during the practical installation process. Figure 1 shows an example of these two coordinate systems, where and c xy  represent the camera coordinate system, the inclinometer coordinate system, and the image plane  , respectively.

Inclinometer Assembly Error Calibration and Horizontal Image Correction
The inclinometer can only measure angles between two axes (x-axis and y-axis) and the horizontal plane. It cannot obtain the yaw angle value between the measurement system and the north direction. Thus, this degree of freedom should be avoided during calibration. In Figure 2, o 1 − x 1 y 1 and o 2 − x 2 y 2 represent camera coordinate systems that are in different rotation statuses, and C is the optic center of the camera. When the camera is placed horizontally, no matter how the camera's orientation changes, the plumb line AB in the real scenario should be a vertical line A 1 B 1 or A 2 B 2 on the image plane, which means that points on the plumb line AB should have the same x coordinates (x A 1 = x B 1 , x A 2 = x B 2 ) in the image. Based on this principle, we propose a practical method aiming to calibrate the inclinometer assembly error R ic , in order to avoid the limitation of the lack of the yaw angle information. The transformation relationship between them can be expressed as where c X and i X represent the coordinates of the spatial point of the camera and the inclinometer coordinate system, respectively. ic R and ic t represent the matrices of rotation and translation from the camera to the inclinometer coordinate system, respectively. In practice, the inclinometer is generally placed close to the camera in photoelectric measurement systems, while the distance between the measurement system and the scenario to be measured is greater than the translation distance ic t between the camera and the inclinometer. Thus, ic t can be ignored [29]. In this paper, we define the rotation matrix ic R from the camera coordinate system to the inclinometer coordinate system as the inclinometer assembly error, and we are aiming to calibrate this matrix by using the information in the scenario.

Inclinometer Assembly Error Calibration and Horizontal Image Correction
The inclinometer can only measure angles between two axes ( x -axis and y -axis) and the horizontal plane. It cannot obtain the yaw angle value between the measurement system and the north direction. Thus, this degree of freedom should be avoided during calibration. In Figure 2 ) in the image. Based on this principle, we propose a practical method aiming to calibrate the inclinometer assembly error ic R , in order to avoid the limitation of the lack of the yaw angle information.

Relationship between the Geodetic Coordinate System and the Inclinometer Coordinate System
The relationship between the geodetic coordinate system and the inclinometer coordinate system is shown in Figure 3, where represent the geodetic coordinate system and the inclinometer coordinate system, respectively. Both of these coordinate systems follow the rules of right-handed coordinate systems.

Relationship between the Geodetic Coordinate System and the Inclinometer Coordinate System
The relationship between the geodetic coordinate system and the inclinometer coordinate system is shown in Figure 3, where O − X g Y g Z g and O − X i Y i Z i represent the geodetic coordinate system and the inclinometer coordinate system, respectively. Both of these coordinate systems follow the rules of right-handed coordinate systems.
According to the orthogonality between the i Y -axis and the i X -axis, the base vector i Y in the Then, the base vector i Z is sin sin , , cos cos where  can be interpreted as the angle between the i Y -axis of the inclinometer coordinate system and the north direction. Changing  will not affect the value of the inclinometer. Rotate the geodetic coordinate system around the Z g -axis by α degrees to make the X o -axis the projection of the X i -axis. Define this new coordinate system as an intermediate coordinate system During rotation, the inclinometer gives two angles (θ, φ), which are shown in Figure 3.
According to the geometric relationship, the base vector X i in the intermediate coordinate system According to the orthogonality between the Y i -axis and the X i -axis, the base vector Y i in the where Then, the base vector Z i is The direction cosine matrix R gi from the inclinometer coordinate system to the geodetic coordinate system can be represented as where α can be interpreted as the angle between the Y i -axis of the inclinometer coordinate system and the north direction. Changing α will not affect the value of the inclinometer.

Horizontal Image Correction Using the Inclinometer
Using the angle information given by the inclinometer, combined with the coordinate transformation relationship, an image taken by the camera in any attitude can be corrected to an image taken with a horizontally placed camera. Figure 4 is the flow chart depicting horizontal image correction using an inclinometer, and Algorithm 1 shows the specific steps of horizontal image correction.
Algorithm 1: Horizontal image correction using the inclinometer.

I.
Rotate the camera coordinate system to the inclinometer coordinate system using the rotation matrix ic R in Equation (1);

II.
Rotate the inclinometer coordinate system to the geodetic coordinate system according to the direction cosine matrix gi R in Equation (6); III.
Rotate the geodetic coordinate system to the horizontal camera coordinate system by rotating 90  around the g X -axis, the rotation matrix h R can be indicated as IV.
According to homography matrix theory in multiple-view geometry [9], the homography matrix 12 H between two images can be simplified as 1 12 12

Horizontal Image Correction Using the Inclinometer
Using the angle information given by the inclinometer, combined with the coordinate transformation relationship, an image taken by the camera in any attitude can be corrected to an image taken with a horizontally placed camera. Figure 4 is the flow chart depicting horizontal image correction using an inclinometer, and Algorithm 1 shows the specific steps of horizontal image correction. Algorithm 1: Horizontal image correction using the inclinometer.

I.
Rotate the camera coordinate system to the inclinometer coordinate system using the rotation matrix R ic in Equation (1); II.
Rotate the inclinometer coordinate system to the geodetic coordinate system according to the direction cosine matrix R gi in Equation (6);

III.
Rotate the geodetic coordinate system to the horizontal camera coordinate system by rotating 90 • around the X g -axis, the rotation matrix R h can be indicated as IV. According to homography matrix theory in multiple-view geometry [9], the homography matrix H 12 between two images can be simplified as where K is the intrinsic parameter matrix of the camera, which can be expressed as where f x and f y are focal lengths in x and y directions, and c x and c y are principal points.
R 12 is the rotation matrix from image 1 to image 2 Substitute Equation (10) into Equation (8); the homography matrix H 12 can be written as Substitute Equations (7) and (9) into Equation (11); we have Finally, the horizontal corrected image can be obtained by multiplying the homography matrix H 12 with the original image.

Inclinometer Assembly Error Calibration Based on Plumb Lines
Select two points A(x 1 , y 1 ) and B(x 2 , y 2 ) on the line L in the image captured by the camera in any attitude, define A x 1 , y 1 and B (x 2 , y 2 ) as image coordinates on the vertical line L after the homography transformation. Figure 5 shows a schematic diagram of such a situation. The plumb lines in the scenario should be vertical lines following horizontal image correction using Algorithm 1. where K is the intrinsic parameter matrix of the camera, which can be expressed as where x f and y f are focal lengths in x and y directions, and x c and y c are principal points.

12
R is the rotation matrix from image 1 to image 2 Substitute Equation (10) into Equation (8); the homography matrix 12 H can be written as Substitute Equations (7) and (9) into Equation (11); we have     1 cos + sin sin + cos 0 = sin cos , Finally, the horizontal corrected image can be obtained by multiplying the homography matrix 12 H with the original image.

Inclinometer Assembly Error Calibration Based on Plumb Lines
Select two points   , B x y as image coordinates on the vertical line ' L after the homography transformation. Figure 5 shows a schematic diagram of such a situation. The plumb lines in the scenario should be vertical lines following horizontal image correction using Algorithm 1. Based on the homography matrix theory [30], we have Based on the homography matrix theory [30], we have where s 1 and s 2 are scale factors of homogeneous coordinates.
Substitute Equation (13), (15) into Equation (14), and we have Expand Equation (16), and since x 1 = x 2 , finally we have From Equation (17), we can see that angle α-defined in Equation (6)-can be eliminated during the deduction, which verifies that the changing of α will not affect the value of the inclinometer. No matter what the value α is, the plumb line will always be a vertical line following the horizontal image correction.
In terms of actual measurement error, Equation (17) will not be strictly established. Thus, a method that minimizes the Sum of Squared Residuals (SSR) [31] is used to calculate the inclinometer assembly error R ic . By rotating the photoelectric measurement system, multiple inclinometer values (θ i , φ i ), i = 1, 2, . . . , n are recorded. At the same time, relative images for different inclinometer angles are captured. The Hough line-detection method [32] is applied to detect straight lines that are projections of plumb lines in the same scenario. The coordinates of the lines are recorded as The optimization function can be formed as where I is a 3 × 3 identity matrix.
In the optimization problem in Equation (18), the objective function is the Sum of Squared Residuals, and the restricted condition is the orthogonality constraint of the inclinometer assembly error matrix R ic . Therefore, this is a nonlinear programming problem with constraints, and the matrix to be optimized, R ic , has three degrees of freedom. In order to increase the calibration precision, it should satisfy n ≥ 3 [33].

Experimental Results and Analyses
This section explains the experimental investigation of the inclinometer assembly error calibration in two different photoelectric measurement systems with two different cameras and inclinometers, as well as the results of the horizontal corrected image. Additionally, the calibration error is analyzed by means of both a perturbation simulation experiment [34] and a practical experiment. We also compare the proposed method with other methods.

Photoelectric Measurement System
The camera in the first photoelectric measurement system (defined as System 1) is a high-resolution industrial CCD VC-12MC-65 made by Vieworks Company. The lens is a Distagon 35 mm prime lens made by the Zeiss Company, which has a broad perspective, and negligible radial distortion. The camera parameters are shown in Table 1. The dual-axis inclinometer in System 1 is made by Xi'an Sicong Chuangwei Optoelectronic Co. Ltd., which has a 0.05 • angular accuracy. The inclination data acquired are all 16-bit signed numbers. The angle data in degrees can be calculated by multiplying by a scale factor of 1/3600.
The camera and the inclinometer are fixed on an adjustable platform. A diagram of System 1 is shown in Figure 6.

Experimental Results and Analyses
This section explains the experimental investigation of the inclinometer assembly error calibration in two different photoelectric measurement systems with two different cameras and inclinometers, as well as the results of the horizontal corrected image. Additionally, the calibration error is analyzed by means of both a perturbation simulation experiment [34] and a practical experiment. We also compare the proposed method with other methods.

Photoelectric Measurement System
The camera in the first photoelectric measurement system (defined as System 1) is a high-resolution industrial CCD VC-12MC-65 made by Vieworks Company. The lens is a Distagon 35 mm prime lens made by the Zeiss Company, which has a broad perspective, and negligible radial distortion. The camera parameters are shown in Table 1. The dual-axis inclinometer in System 1 is made by Xi'an Sicong Chuangwei Optoelectronic Co. Ltd., which has a 0.05° angular accuracy. The inclination data acquired are all 16-bit signed numbers. The angle data in degrees can be calculated by multiplying by a scale factor of 1 3600 .
The camera and the inclinometer are fixed on an adjustable platform. A diagram of System 1 is shown in Figure 6. From Figure 6, we can see that the X i -axis and the Y i -axis of the inclinometer are orthogonal along the horizontal direction, while the Z i -axis points to the zenith. The X c -axis and the Y c -axis of the camera are parallel to the x-axis and the y-axis of the image plane, respectively, while the Z c -axis is parallel to the optic axis. Thus, a probable initial value for the nonlinear programming problem in Equation (18) for the inclinometer assembly errorR ic of System 1 could be In the second photoelectric measurement system (defined as System 2), we use a Basler acA2040-25gm camera with the 8 mm fish-eye lens. This lens has significant radial distortion that needs to be corrected before the calibration. The SCA126T dual-axis inclinometer is from China Shenzhen Rion Technology Co., Ltd., with a 0.01 • angular resolution. The camera parameters are shown in Table 2, and the photoelectric measurement system (System 2) is shown in Figure 7.
In the second photoelectric measurement system (defined as System 2), we use a Basler acA2040-25gm camera with the 8 mm fish-eye lens. This lens has significant radial distortion that needs to be corrected before the calibration. The SCA126T dual-axis inclinometer is from China Shenzhen Rion Technology Co., Ltd., with a 0.01° angular resolution. The camera parameters are shown in Table 2, and the photoelectric measurement system (System 2) is shown in Figure 7.  From Figure 7, we can also obtain one probable initial value of the nonlinear programming problem in Equation (18) for the inclinometer assembly error  ic R of System 2:

5.2.Calibration of Camera Intrinsic Parameter and Estimation of Lens Radial Distortion Parameter
To solve the nonlinear programming problem in Equation (18), the camera intrinsic parameter matrix K and the lens distortion parameter [35]   From Figure 7, we can also obtain one probable initial value of the nonlinear programming problem in Equation (18) for the inclinometer assembly errorR ic of System 2:

5.2.Calibration of Camera Intrinsic Parameter and Estimation of Lens Radial Distortion Parameter
To solve the nonlinear programming problem in Equation (18), the camera intrinsic parameter matrix K and the lens distortion parameter [35] are necessary. A commonly used lens distortion model can be written as where r d is the distance from the distorted point (x d , y d ) to the distortion center (x 0 , y 0 ), λ 1 is the radial distortion parameter, and α is the pixel aspect ratio. In this paper, we only consider the first term of the radial distortion, since this is enough for tasks in computer vision, according to Tsai [36]. We use the classical calibration method proposed by Zhang [37] to obtain the intrinsic parameter matrix and the radial distortion parameter. Figure 8 shows the checkerboard used during camera calibration.  is the radial distortion parameter, and  is the pixel aspect ratio. In this paper, we only consider the first term of the radial distortion, since this is enough for tasks in computer vision, according to Tsai [36]. We use the classical calibration method proposed by Zhang [37] to obtain the intrinsic parameter matrix and the radial distortion parameter. Figure 8 shows the checkerboard used during camera calibration.
for System 1, with 0.1013 pixels mean re-projection error [34]; and for System 2, with 0.0966 pixels mean re-projection error. The radial distortion parameters are for System 1; and for System 2. Images captured by System 2 will be corrected for radial distortion using the parameters in Equations (23) and (25) before Hough line detection, to reduce the coordinate detection error caused by the fish-eye lens distortion.

Experimental Data Measurement
During the experiment, changing the attitude of the photoelectric measurement system, taking images of each scenario    for System 1, with 0.1013 pixels mean re-projection error [34]; and for System 2, with 0.0966 pixels mean re-projection error. The radial distortion parameters are k 1 = −0.0994 (24) for System 1; and k 2 = −0.3487 (25) for System 2. Images captured by System 2 will be corrected for radial distortion using the parameters in Equations (23) and (25) before Hough line detection, to reduce the coordinate detection error caused by the fish-eye lens distortion.

Experimental Data Measurement
During the experiment, changing the attitude of the photoelectric measurement system, taking images of each scenario I i (i = 1, 2, . . . , n), and recording the inclination data (θ i , φ i ), i = 1, 2, . . . , n all takes place at the same time. When saving camera images, we make sure that there are obvious building edges in the image. Table 3a shows 12 pairs of the inclination data in degrees for System 1, and Table 3b shows the data for System 2. The Hough line detection method is applied to detect straight lines that are projections of plumb lines in the scenario. Other lines that are not projections of plumb lines are removed. Additionally, in order to ensure precision, only lines longer than D pixels are retained (in our experiments, D = 200 pixels in System 1, and D = 100 pixels in System 2).

Inclinometer Assembly Error Calculation and Horizontal Image Correction
Using Equation (18) for System 2.
For the original image, homography matrices H 12 are calculated with the inclination data in Table 3 by substituting Equation (22) or (23)  for System 2. Finally, the horizontally corrected image is obtained by transformation using the corresponding homography matrix H 12 . Figure 9a shows the original image, I 3 , in which nine lines were detected in System 1; Figure 9b shows the horizontally corrected image, I 3_corrected , which can be seen to be horizontally corrected, as the edges of the buildings are vertical in the corrected image. The horizontally corrected image looks better than the original one.
for System 2. Finally, the horizontally corrected image is obtained by transformation using the corresponding homography matrix 12 H . Figure 9a shows the original image, 3 I , in which nine lines were detected in System 1; Figure   9b shows the horizontally corrected image, 3 _ corrected I , which can be seen to be horizontally corrected, as the edges of the buildings are vertical in the corrected image. The horizontally corrected image looks better than the original one. . Figure 10a-c shows the horizontal correction results of image 6 I using System 2. The original image, 6 I , has serious radial distortion, which is apparent due to the plumb lines of the building having turned into curves (Figure 10a). Firstly, the image was undistorted, 6 _ undistorted I (Figure 10b), to reduce the error caused by coordinate detection, and then horizontally corrected, 6 _ corrected I ( Figure   10c).  Table 4 gives the corresponding coordinates and angle for every detected line in one image using System 2. After the horizontal correction, coordinates on the same plumb line in image 6 _ corrected I all have the same x -axis coordinate except for one, obtained by testing coordinates on the same line, and the corresponding angles with x direction are all 90°. Figure 10a-c shows the horizontal correction results of image I 6 using System 2. The original image, I 6 , has serious radial distortion, which is apparent due to the plumb lines of the building having turned into curves (Figure 10a). Firstly, the image was undistorted, I 6_undistorted (Figure 10b), to reduce the error caused by coordinate detection, and then horizontally corrected, I 6_corrected (Figure 10c).
for System 2. Finally, the horizontally corrected image is obtained by transformation using the corresponding homography matrix 12 H . Figure 9a shows the original image, 3 I , in which nine lines were detected in System 1; Figure   9b shows the horizontally corrected image, 3 _ corrected I , which can be seen to be horizontally corrected, as the edges of the buildings are vertical in the corrected image. The horizontally corrected image looks better than the original one. . Figure 10a-c shows the horizontal correction results of image 6 I using System 2. The original image, 6 I , has serious radial distortion, which is apparent due to the plumb lines of the building having turned into curves (Figure 10a). Firstly, the image was undistorted, 6 _ undistorted I (Figure 10b), to reduce the error caused by coordinate detection, and then horizontally corrected, 6 _ corrected I ( Figure   10c).  Table 4 gives the corresponding coordinates and angle for every detected line in one image using System 2. After the horizontal correction, coordinates on the same plumb line in image 6 _ corrected I all have the same x -axis coordinate except for one, obtained by testing coordinates on the same line, and the corresponding angles with x direction are all 90°.  Table 4 gives the corresponding coordinates and angle for every detected line in one image using System 2. After the horizontal correction, coordinates on the same plumb line in image I 6_corrected all have the same x-axis coordinate except for one, obtained by testing coordinates on the same line, and the corresponding angles with x direction are all 90 • .

System Error Analyses
The inclinometer assembly error calibration result R ic in Equation (18) is deduced under ideal conditions. In real-world conditions, due to error arising during measurement and image processing, the calibration results will be affected by image noise, camera intrinsic parameter calibration errors, inclinometer angle reading errors, coordinate detection errors, etc. In order to verify the feasibility of the proposed method, one simulation experiment and one practical experiment are performed to analyze the system error.

Error Analyses by Simulation Experiment
In the simulated perturbation experiment, standard Gaussian random noise with a zero mean and one-pixel standard deviation is added to the endpoints of detected lines to simulate the coordinate detection error caused by image noise, the radial distortion of the lens, and the inaccuracy of the Hough line detection method.
In order to analyze the system error, the inclinometer assembly error matrix R ic is decomposed into Euler angles (yaw, pitch, and roll) [38]. The pseudocode of the perturbation experiment is shown in Algorithm 2.  Figure 11 shows Euler angles for each experiment. In addition, Table 5 shows the mean and the standard deviation of the Euler angles.  From Figure 11 and Table 5, we can see that the mean of the Euler angle with the Gaussian white noise illustrates the angle between the inclinometer and the camera coordinate systems, while the standard deviation with the Gaussian white noise illustrates the calibration precision, indicating the feasibility of the proposed method.

Error Analyses by Practical Experiment
In the practical experiment, the calibration precision is tested by horizontally correcting images using the calibrated system. The pseudocode of the practical experiment is shown in Algorithm 3.
Bulleted lists look like this: (III) Calculate the inclinometer assembly error ic R using the N images and corresponding information.
(IV) Horizontally correct the n N  retained images using the calibrated matrix ic R .
(V) Detect the endpoints of the horizontal corrected images and calculate the angle with the xaxis on the same line.  From Figure 11 and Table 5, we can see that the mean of the Euler angle with the Gaussian white noise illustrates the angle between the inclinometer and the camera coordinate systems, while the standard deviation with the Gaussian white noise illustrates the calibration precision, indicating the feasibility of the proposed method.

Error Analyses by Practical Experiment
In the practical experiment, the calibration precision is tested by horizontally correcting images using the calibrated system. The pseudocode of the practical experiment is shown in Algorithm 3.
Bulleted lists look like this: Algorithm 3: Pseudocode for the practical experiment.
(III) Calculate the inclinometer assembly error R ic using the N images and corresponding information. (IV) Horizontally correct the n − N retained images using the calibrated matrix R ic . (V) Detect the endpoints of the horizontal corrected images and calculate the angle with the x-axis on the same line.
We first captured 9 images using the camera and inclinometer in System 1, and recorded the corresponding inclination data. Then, we used 6 of the 9 images to calibrate the inclinometer assembly error R ic . Finally, we horizontally corrected the remaining 3 images using the calibrated R ic . Figure 12 shows the correction results with the lines detected on them, which can be seen to be horizontally corrected, as the edges of the building are vertical in the corrected image. Table 6 provides the coordinates of the endpoints and the angle with the x direction of each line, from which we can see that most of the coordinates on the plumb line have the same x-axis coordinate after horizontal correction. It also shows that angles with the direction are 90 • , which means that the calibrated result is of sufficient accuracy. We first captured 9 images using the camera and inclinometer in System 1, and recorded the corresponding inclination data. Then, we used 6 of the 9 images to calibrate the inclinometer assembly error ic R . Finally, we horizontally corrected the remaining 3 images using the calibrated ic R . Figure 12 shows the correction results with the lines detected on them, which can be seen to be horizontally corrected, as the edges of the building are vertical in the corrected image. Table 6 provides the coordinates of the endpoints and the angle with the x direction of each line, from which we can see that most of the coordinates on the plumb line have the same x -axis coordinate after horizontal correction. It also shows that angles with the x direction are 90°, which means that the calibrated result is of sufficient accuracy.
(a) (b) (c) Figure 12. Images with lines detected before (first row) and after (second row) horizontal correction. Table 6. Coordinates and angles of each detected plumb line before and after horizontal correction.

Comparison with Other Methods
The precision of horizontal image correction reflects the accuracy of the calibration of inclinometer assembly error in our photoelectric measurement system, since the homography matrix used for horizontal image correction is related to the inclinometer assembly error in the proposed method. In this section, we compare the proposed horizontal image correction method with three other classical image processing methods-the slant correction method based on Principal Component Analysis (PCA) [39], the image tilt correction method based on the Hough line detection method [40], and the horizontal image correction method based on the Radon method [41]-to evaluate our proposed method.
We compare the above four methods in terms of the aspects of computation time and horizontal image correction error. In our experiment, the horizontal image correction error is defined as where N is the number of plumb lines detected in the corrected image, k is the number of experiments, 2 n N  is the number of endpoints on the detected lines, and The comparative experiment is carried out using System 1. Figure 13 shows the horizontal correction results with lines detected using the four methods. Table 7 shows the comparison of the results, with the optimal results in boldface.  From the comparison of the results, we can see that all the methods are able to horizontally correct the image by rotating using the inclination data, with the proposed method using the calibrated inclinometer assembly matrix to obtain the homography matrix for horizontal correction,  From the comparison of the results, we can see that all the methods are able to horizontally correct the image by rotating using the inclination data, with the proposed method using the calibrated inclinometer assembly matrix to obtain the homography matrix for horizontal correction, while the other three methods use image processing methods without calibrating the inclinometer assembly error. The PCA method uses the PCA algorithm to acquire the correcting geometrical transform matrix by covariance matrix calculation and eigenvalue decomposition. The Hough method uses the horizontal lines by finding the most prominent line or edge in the image. However, it traverses the entire image for image interpolation, resulting in a longer calculation time. The Radon method is based on the rotation and projection transformation [42,43], which uses the distance from the image center pixel to the image boundary to calculate the image inclination angle.
Therefore, compared with these methods, the proposed method has the advantages of calibrating the inclinometer assembly error of photoelectric measurement systems and horizontally correcting the tilt image at the same time. The horizontal image correction error is very small compared with other methods, while the computation time is not increased, which shows the feasibility and accuracy of the proposed method.

Conclusions
This paper analyzes the expression of inclinometer assembly error in photoelectric systems. Aiming to solve the problem of the lack of yaw angle information, an inclinometer assembly error calibration method is proposed that utilizes the plumb lines in the scenario. An optimization function for calibration by deriving transformation relationships between different coordinate systems is established, and the constraint equation satisfies the inclinometer-camera system.
The experimental results of the simulated photoelectric measurement systems show that the assembly error can be calibrated only by using the inclinometer angle information in conjunction with the plumb lines in the scenario. The perturbation experiment for the input parameter indicates the feasibility of the proposed method, which provides a theoretical basis for future work on the correction of and compensation for inclinometer assembly error, as well as improvements in accuracy and precision for photoelectric measurement systems.
Future work may include the decreasing of calibration error, and the application of the proposed method in the photoelectric detection system.