## 3 Methodology
### Method 1  
The detection principle of Method 1 is shown in Figure 3a.  
A rectangular coordinate system consisting of \(x\)-axis and \(y\)-axis was given, the edge of the conveyor belt is always parallel to the \(y\)-axis direction and consistent with the speed when the conveyor belt runs normally and no deviation occurs. At this point, we define the distance from any point on the right edge of the conveyor belt to the \(y\)-axis, \(d\). When the conveyor belt is deflected or completely offset, the intersection point of the right edge of the conveyor belt and the x-axis will change. As shown in Figure 3a, after the conveyor belt is deflected to the left, \(d_{x}<d\), and a deflection angle \(\theta\) will appear at the same time.  
Based on the above detection principle, we propose to use a combination of Canny edge detection and Hough straight line detection to obtain a straight line that effectively fits the edge of the conveyor belt, and then extract the slope of the straight line, the abscissa of the intersection of the straight line and the \(x\)-axis, that is, extract \(d_{x}\), \(\theta\) shown in Figure 3a.  
Canny Edge detection algorithm and the Hough line fitting algorithm were proposed to effectively extract the edges of the conveyor belt, and directly extract and detect the slope of the fitted straight line and the intersection of the straight line and the coordinate axis. The canny operator is a multi-stage optimization operator that integrates filtering, enhancement, and detection, which was proposed by [PERSON] in 1986 [18], is optimized to deal with the step edge affected by white noise. The process of the Canny edge detection algorithm consists of four steps:  
1. Apply a Gaussian filter to smooth the image to remove the noise.
2. Find the intensity gradients of the image.
3. Apply non-maximum suppression to get rid of spurious response to edge detection.
4. Apply a double threshold to determine potential edges and connect edges.  
Figure 3: Principle of deviation detection: (**a**) principle of Method 1, (**b**) principle of Method 2.  
Figure 2: Schematic diagram of deviation: (**a**) normal condition, (**b**) deflection condition, (**c**) overall offset condition, \(v\) represents the speed direction of the conveyor belt, and \(\theta\) represents the deflection angle of the conveyor belt, \(d_{m}\) represents the lateral displacement of the conveyor belt along the bandwidth direction.  
The Hough transform was used to detect the line after the edge detecting by canny algorithm, the basic principle of the algorithm is to transform the image from image space to parameter space. The transformation formula is as follows:  
\[y=kx+b \tag{1}\]  
\[y=\frac{-\cos\theta}{\sin\theta}x+\frac{\rho}{\sin\theta} \tag{2}\]  
\[\rho=x\cos\theta+y\sin\theta \tag{3}\]  
After transformation, the relationship between image space and parameter space is as follows: a point in the image space is a curve in the parameter space, and the points of the colinear image space correspond to the curves at a point in the parameter space.  
The basic principle of Hough transformation is to use the transformation between two coordinate spaces, as shown in Figure 4, to map the line in the Cartesian coordinate system to a point in the polar coordinate space to form a peak, thus transforming the problem of detecting the line into a problem of the statistical peak.