# Automatic Detection of Maintenance Scenarios for Equipment and Control Systems in Industry
## 2 Materials and Methods
### Component Processing and Boundary Extraction
#### 2.3.3 Peaks Width Estimation  
Once the peak top has been determined, the next step is to identify its boundaries, namely the places of the beginning of growth and the end of decline, thus marking the boundaries of the action (Figure 5). Initially, it is required to find the height where the peak width will be calculated. The described height \(h_{eval}\) is obtained using the Formula (6):  
\[h_{eval}=h_{peak}-P*R, \tag{6}\]  
where \(h_{peak}\)--peak top (_top_ on Figure 5), \(P\)--height defining the independence of the peak. The given parameter is variable depending on the processed signal and cannot be a constant. In our work, we obtain it as a result of the peak search function, \(R\)--relative height, where the peak width is measured as a percentage of the peak value \(P\). With a value of 1, the peak width is calculated from the lowest contour line, and with a value of 0.5, it is estimated from half the height using the value of \(P\).  
Then, a horizontal line is made at the \(h_{eval}\) level in both directions until it intersects with the signal. The peak width is calculated as the horizontal distance between the obtained two points, namely, between the _up_ and _down_ points in Figure 5.  
The described algorithm for calculating peak widths is embedded in the peak_widths function of the Scipy library designed for scientific and engineering calculations, and we used it to process the time series.  
In this way, the obtained peaks are the reactions to the human hand actions in the video. Then, the video is divided into scenes; thus, the point of the beginning of the peak rise and the end of the fall are the scene boundaries. A complete algorithm for automatic actions detection of maintenance scenarios is shown in Algorithm 1.  
Figure 5: Scheme of the points of the beginning of growth, the end of decline, and the top of the peak.  
```
1 for each frame in video:
2 hands_data = mediapipe_model(frame)
3 if hands_data is not empty:
4 if hands_data has label = 'Left hand':
5 Store left hand data of X, Y, Z axis to left_hand_array
6 else:
7 Store 0 to left_hand_array
8 if hands_data has label = 'Right hand':
9 Store right hand data of X, Y, Z axis to right_hand_array
10 else:
11 Store 0 to right_hand_array
12 else:
13 Store 0 to left_hand_array and to right_hand_array
14 endfor
15 Create matrices from X, Y, Z axis of the left_hand_array and right_hand_array
16 Vertical stack matrices to the one trajectory matrix
17\(\sqrt{\lambda}\)UVT= SVD(the trajectory matrix)
18 MSSA components = Reconstruction \(\sqrt{\lambda}\)UVT to time series
19 For the last MSSA component create the trajectory matrix MSSA
20\(\sqrt{\lambda}\)UVT = SVD(the trajectory matrix MSSA)
21 SSA components = Reconstruction \(\sqrt{\lambda}\)UVT to time series
22 Find peaks in the first SSA component
23 Calculate peaks width
24 Action start = The beginning of the peak rise
25 Action end = The end of the peak fall
26 Split video into scenes
```  
**Algorithm 1** Actions scenes detection using multichannel singular spectrum analysis