## 3 Image Preprocessing  
The fisheye lens is a kind of ultra wide angle lens, which is much larger than that of ordinary camera. The effective viewing angle range is close to 180 degrees. The wide imaging range will also produce a big super-wide-angle lens distortion, resulting in obvious distortion of the image [20]. Therefore, it is necessary to calibrate the fisheye camera to correct the image distortion. The calibration of the cameras mainly involves the transformation of four coordinate systems: world coordinate system, camera coordinate system, image plane coordinate system, and image pixel [21]. Zhengyou Zhang calibration method, the radial alignment constraint (RAC) two-stage method of [PERSON], and the direct linear transform (DLT) method belong to threes of the calibration methods [22; 23; 24; 25]. The main idea of Zhengyou Zhang calibration is to use the black and white checkerboard as the standard template, determine the distortion correction algorithm according to the corner relationship to calculate the internal parameter matrices, distortion coefficient, the rotation matrix R and translation matrix T. The effect of distortion correction is shown in Figure 1.  
As shown in Figure 2, in order to facilitate the correct identification of parking spaces in a complex environment, the image is converted into a top view through the inverse perspective transformation algorithm. The basic realization principle is to project the initial image imaging plane to another imaging plane, which can be expressed as:  
\[\left[ \begin{array}{c}u\\ v\\ 1\end{array} \right]=sH\left[ \begin{array}{c}X\\ Y\\ 1\end{array} \right] \tag{1}\]  
where vector \(\left[ \begin{array}{cc}u&v&1\end{array} \right]^{\text{T}}\) is homogeneous coordinates of the image after inverse perspective transformation; \(s\) is zoom scale; \(H\) is image homograph matrix; \([X\,Y]\) is the point in the ground coordinate system. Figure 1: The distortion correction of the image. (**a**) The original image; (**b**) the corrected image. Figure 2: Inverse perspective transformation. (**a**) The corrected image; (**b**) top view. Since the image with the QR code captured by the camera is easily disturbed by noise and environmental problems, the image needs to be preprocessed. These steps include image grayscale, binarization, and filtering. Image grayscale is to change the three-channel RGB color image into a single-channel grayscale image, which can improve the image processing speed. The color image can be converted to grayscale image by using the following formula [26]:  
\[F(i,j)=0.299\times R(i,j)+0.587\times G(i,j)+0.114\times B(i,j) \tag{2}\]  
Binarization adopts the binarization algorithm of adaptive threshold. The purpose is to present the image with obvious black and white effect, reduce the amount of data, and highlight the contour of the target. The basic principle is to calculate the local threshold according to the brightness distribution of different areas of the image so as to reduce the impact of lighting conditions, and set the image pixel grayscale value according to the calculated local threshold, which can be expressed as:  
\[f(x,y)=\left\{ \begin{array}{rl}255&if&g(x,y)>T(x,y)\\ 0&otherwise\end{array} \right. \tag{3}\]  
where \(f(x,y)\) is an image pixel grayscale which is set, \(g(x,y)\) is a pixel value of the original image, \(T(x,y)\) is a threshold calculated individually for each pixel, which can be expressed as:  
\[T(x,y)=\frac{1}{M}\sum_{(x,y)\in A}h(x,y)-C \tag{4}\]  
where \(M\) is the size of a pixel neighborhood, \(A\) is the collection of neighborhood point which includes pixels \((x,y)\), \(h(x,y)\) is a pixel value of the original image, \(C\) is an offset adjustment value. Normally, \(C\) is positive but may be zero or negative as well. In this paper, the median filtering is adopted to smooth and denoise, which can help eliminate the sharp noise of images and realize image smoothing.