## 4 Principle and Implementation  
### Water Gauge Mapping Relationship Establishment  
Three dimensions of coordinate information are usually required to describe the position of an object in real space, and the image of the water gauge taken by the camera is a projection of the water gauge in the world coordinate system onto the two-dimensional plane of the pixel coordinate system. Considering the installation of the water gauge in the field, it is assumed in the text that the plane of the gauge is approximately perpendicular to the horizontal plane. In a realistic camera set-up scenario, the imaging plane of the camera will usually show a non-parallel relationship with the plane of the water gauge. According to photogrammetry principles, this results in a non-linear projection distortion of the camera image. In order to reduce the errors caused by the projection distortion, this paper uses the perspective transformation [28] to map the water gauge image into a virtual water gauge plane that is parallel to the water gauge plane in the world coordinate system. According to the projection relationship, at this point there is only a proportional relationship between the water gauge in the real water gauge plane and the virtual water gauge plane without any non-linear projection distortion. In order to establish the mapping relationship, three steps are needed and will be presented in the next paragraphs. Firstly, the matching projection points are selected. The selection of matching projection points is usually arbitrary in the establishment of the perspective relationship, but according to the principles of perspective transformation, at least four pairs of matching projection points must be selected, and the projection points in each coordinate system need to satisfy that three points are not on the same horizontal line [11]. To further ensure the accuracy of the mapping relationship, six pairs of matching projection points are adopted in this paper. The matching projection points are: selected using the rule that they must correspond to the four internal corner points of the E character located at the four corners of the water gauge, as well as the two internal corner points of the E character at any position in the middle of the water gauge, as shown in Figure 2. Let the projection point coordinates in the pixel coordinate system be \((x_{i},y_{i})\), and the projection point coordinates in the virtual water ruler coordinate system be \((u_{i},v_{i})\), where \(i=1,2,3,4,5,6\). Next, the perspective matrix is calculated. Let the perspective matrix be \(M_{3\times 3}\), and according to the perspective projection relationship, we can obtain the coordinates \((u_{i},v_{i})\) under the plane coordinate system of the virtual water gauge and the coordinates \((x_{i},y_{i})\) under the pixel coordinate system, as shown in Equation (1). \[\left\{ \begin{array}{l}u=\frac{m_{i1}x+m_{i2}y+m_{i3}}{m_{i3}+m_{i3}+m_{i3}+m_ {i3}}\\ v=\frac{m_{i2}x+m_{i2}y+m_{i2}y+m_{i3}}{m_{i3}+m_{i3}+m_{i3}}\end{array} \right. \tag{1}\]  
where \(m_{ij}\) is the element of the \(i\)-th row and \(j\)-th column of the perspective matrix. By substituting the six pairs of matching projection points into the above Equation (1), we can  
Figure 1: SegFormer network structure. obtain the matrix of equations as in Equation (2). By solving it, we obtain the perspective matrix \(M_{3\times 3}\). \[\left[ \begin{array}{c}u_{1}\\ u_{2}\\ u_{3}\\ u_{4}\\ u_{5}\\ u_{6}\\ v_{1}\\ v_{2}\\ v_{3}\\ v_{4}\\ v_{5}\\ v_{6}\end{array} \right]=\left[