Taking into account camera tilt when correcting a three-dimensional model of a hollow pipe during visual diagnostics with a self-propelled complex

. This paper investigates the problem of assessing the degree of pipe deformation and the deviation of its longitudinal section profile from a cylindrical shape based on a three-dimensional point model of a hollow pipe under conditions when this model turns out to be displaced (rotated in space) relative to its real position. An algorithm for correcting a three-dimensional point model based on data on the current tilt of the camera is considered, as well as an algorithm for the actually obtained image overlaid with virtual cross-sections of the pipe, close to ideal.


Introduction
Long-term operation of hollow pipes often leads to the fact that such pipes can be deformed under the influence of miscellaneous external factors, can become corroded, and accumulate accidentally falling foreign bodies within it. All these factors can lead to a deterioration in the permeability of the pipe or even to a violation of its integrity.
One of the approaches that makes it possible to diagnose such hollow pipes is to use video diagnostics of the pipe condition by using self-propelled robotic platforms equipped with video cameras and other sensors, which composition depends on the purpose of diagnostics and the destination of the pipeline. Modern technical devices of capturing video images allow us to combine receiving a video stream with obtaining a three-dimensional point model of the considered object, which allows an operator to use software instruments to measure the visible dimensions of pipe defects or objects within it.
The creation of the software for an operator of a self-propelled robotic platform made it necessary to measure a deformation of the pipe and the deviation of its longitudinal section profile from the cylindrical shape. This problem can be solved by the actually obtained image overlaid with virtual cross-sections of the pipe, close to ideal. However, since the camera mounted on a self-propelled platform can change the angle of inclination to the longitudinal axis of movement, the three-dimensional model obtained from the camera turns out to be displaced (rotated in space) relative to its real position, and it is required to correct this model using the data on the current tilt of the camera. This paper considers a special case, when a self-propelled platform is installed in such a way so the vector of its movement direction coincides with the pipe axis. The method of turning a three-dimensional point model obtained from the directional camera of a selfpropelled platform is used, and an algorithm for constructing pipe cross-sections close to ideal, based on the obtained data is being developed.
The following designations were used: C is the point where the camera is located, t is the vector of the direction of the camera's view, α is the angle of inclination of the camera along the pipe axis, r is the radius of the pipe cross-section.

Formulation of the problem
The self-propelled platform is located inside the hollow pipe so that the vector of its movement direction coincides with the axis of pipe. It is known that a camera mounted on a self-propelled platform is located at an angle α to the pipe axis, as it is shown in the Figure  1. It is necessary to define an unambiguous mathematical description of the camera, represented by the position of the camera in world space, the direction it is looking at, a vector pointing to the right direction, and a vector pointing upwards from the camera; to perform software implementation of the camera based on the mathematical description; define a rotation matrix to transform a three-dimensional point model of a hollow pipe; after transforming the 3D model, construct pipe cross-sections close to ideal.

The solution of the problem
World space means coordinates relative to a single global reference point in a threedimensional Euclidean coordinate system. By agreement, OpenGL technology uses a righthanded coordinate system that means the positive X-axis is to the right, the positive Y-axis is upward, and the negative Z-axis is inward of the monitor screen [1].
The point C (x0, y0, z0) can describe the position of the camera in world space. Let C be the base point of the origin in the view space. It is known, that the self-propelled platform and the pipe where it is located have the same coordinate system, and the camera mounted on the platform is rotated around the global Ox axis by an angle α, so we can say that the axes Oxt of the pipe and Oxv of the camera view space coincide. The camera direction vector lies on the positive Z-axis of the camera, and the direction vector of the camera view is on the negative Z-axis of the camera. The Oyv axis can be calculated by vector multiplication of the Oxv and Ozv axes. Thus, we got a triplet of vectors generating the right-handed coordinate system of the camera as it is shown in the Figure 2. This mathematical description is necessary since the concept of a camera is absent in OpenGL technology, and it allows us to implement a software camera by defining a special matrix for transforming vectors into the coordinate space of the camera view. The LookAt matrix in general form, according to [1], looks as follows: where R is the right vector (X-axis of the camera), U -vector pointing upward (Y-axis of the camera), D -camera direction vector (Z-axis of the camera), P -the position of the camera. Because of the software implementation with the camera position shown in the Figure 2, images converted into three-dimensional point models without taking into mind the camera rotation by the angle α were obtained from the directional camera. One of such models is shown in the  According to the conditions of the problem, it is necessary to rotate the obtained threedimensional point model around the X-axis by a known angle α for further detection and analysis of defects in the pipe. Since this paper considers a special case when the global Xaxis coincides with the Oxv axis of the camera, it is sufficient to apply the basic geometric rotation of the points of the three-dimensional model around the X-axis, which, according to [2, p. 35], can be described by the matrix Rx of the following form: The software implementation of the rotation of the three-dimensional point model of the pipe by an angle α around the X-axis realized as follows:

Points.ModelMatrix=Matrix4.CreateRotationX(MathHelper.DegreesToRadians(PointsXRo tAngle));
This software implementation made it possible to obtain images converted into threedimensional point models, taking into mind the rotation of the camera by the angle α, as it is shown in the Figure 4, and also made it possible to further analyze pipe defects by overlaying it with pipe cross-sections close to ideal. In conditions of shooting at a real camera, images of "points cloud" may contain different defects: the presence of extra points outside the real pipe or the absence of some groups of points where they exist in the real pipe. For further analysis, it is necessary to exclude such defects as much as possible, since they can interfere with the compilation of the correct model. To exclude such defects, it is necessary, using the existing three-dimensional point model as well as the radius of the cross-section of the pipe r, to reject all points that do not fall within a certain range. Defects are excluded and a pipe model close to ideal is built according to the following algorithm: 1. Having the coordinates of the points of the three-dimensional model of the pipe, sort these points by their distance from the camera with the center at point C. In this case, sorting occurs by the coordinates of the Z-axis. The result is shown in the Table 1. This kind of sorting allows you to select the points that form the cross-sectional planes into separate layers; 2. according to the algorithm from [3], on each layer a hundred triplets of points are selected, for each triplet a circle into which the points of this triplet fall is calculated; 3. after obtaining a set of circles with certain centers for each layer, calculate the radius of each circle; then, based on the set of semi-diameters, exclude from this set those circles which radius deviates excessively from the median value of the radius for this set; 4. after exclusion for each layer the circles, the radius of which does not fall within the allowable range, calculate the median radius and the average center in the remaining sets; 5. grouping layers by ten, find an average among the centers and among the semi-diameters over the available corresponding sets; 6. on the basis of the obtained averaged radius and center for each group of layers, construct a circle, which is a cross-section of the pipe, close to ideal. The result of this algorithm is shown in the Figure 5.

Conclusion
In this paper, a special case when a self-propelled platform was installed in such a way that the vector of its direction of movement coincided with the axis of the pipe within it was located was considered. To solve the problem of turning a three-dimensional point model, a mathematical description of the camera was given, a software implementation of the camera was performed based on the mathematical description; a rotation matrix for transforming a point three-dimensional model of a hollow pipe was determined. Also, an algorithm for constructing pipe cross-sections close to ideal, based on the obtained data, was developed.