# Study on Relay Contact Bounce Based on the Adaptive Weight Rotation Template Matching Algorithm
## 4 Contact Bounce Analysis  
### Analysis of Contact Bounce Process  
In this paper, viewed through the lens of image processing and taking into account the characteristics of the tested relay, the contact bounce is redefined: when the relay absorbs or releases the contact, in the process of the joint vibration of the relay contacts, if the movable contact and the corresponding stationary contact are separated, it is considered that a contact bounce has occurred. Therefore, the critical aspect of analyzing contact bounce is determining the contact state of the moving contact and the stationary contact. As the moving contact appears as a circle and the stationary contact as a rectangle in the image, the contact problem of the moving contact and the stationary contact can be transformed into the tangent problem of the circle and the rectangle, as shown in Figure 12. Through the Hough circle detection algorithm, the coordinates of the center of the circle, (\(x_{0}\),\(y_{0}\)), and the radius size, \(r\), of the moving contact can be identified, and the tilted rectangle of the stationary contact can be identified by using the adaptive rotating template matching algorithm proposed in this paper. The coordinates of the two upper vertices of the rectangle are obtained as (\(x_{1}\),\(y_{1}\)) and (\(x_{2}\),\(y_{2}\)), respectively. The expression of the line on which the upper edge of the rectangle lies is first computed from the coordinates of the vertices of the rectangle, and the equation of the line is represented by the two-point formula:  
\[\frac{(y-y_{1})}{(x-x_{1})}=\frac{(y_{2}-y_{1})}{(x_{2}-x_{1})} \tag{20}\]  
Summarizing after collation yields the general form equation as follows:  
\[(y_{2}-y_{1})x-(x_{2}-x_{1})y+(y_{1}x_{2}-y_{2}x_{1})=0 \tag{21}\]  
In the general form equation, the equation is simplified for subsequent calculations by applying the following:  
Figure 12: Diagram for judging the contact status of the moving contact and the stationary contact. \begin{table}
\begin{tabular}{c c} \hline \hline
**Algorithm** & **Accuracy** \\ \hline Traditional template matching algorithm & 54.3\% \\ The rotation template matching algorithm for traditional formulas & 71.9\% \\ Improved formula-based rotation template matching algorithm & 98.7\% \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Comparison of the effectiveness of different template matching algorithms. \[\left\{ \begin{aligned} & A=y_{2}-y_{1}\\ & B=-(x_{2}-x_{1})\\ & C=y_{1}x_{2}-y_{2}x_{1}\\ \end{aligned} \right. \tag{22}\]  
Therefore, the straight line can be simplified as follows:  
\[Ax+By+C=0 \tag{23}\]  
From this, the vertical distance from the center of the circle of the moving contact to the upper edge of the stationary contact can be calculated as follows:  
\[D=\frac{|Ax_{0}+By_{0}+C|}{\sqrt{A^{2}+B^{2}}} \tag{24}\]  
By subtracting the radius of the moving contact from this distance, the vertical distance between the moving contact and the stationary contact can be calculated as follows:  
\[\mathrm{d}=D-r=\frac{|Ax_{0}+By_{0}+C|}{\sqrt{A^{2}+B^{2}}}-r \tag{25}\]  
Assuming that the distance from the center of the circle of the moving contact to the stationary contact in the i-th frame image is \(d_{i}\), it is only necessary to determine whether this distance is greater than the radius of the moving contact, i.e., whether the distance between the moving contact and the stationary contact is zero, to determine the contact state of the moving contact and the stationary contact in the  
The bounce distance of the contacts is the distance between the moving contact and the stationary contact after the occurrence of a bounce. To provide a clearer observation of the relay contact bounce, the bounce distance is plotted and displayed in Figure 13.  
The analysis of the data and curves reveals that the relay experiences a contact bounce during the action process.