# Psychological Training Method for Table Tennis Players Using Deep Learning
## 4 Investigation on Psychological Training of Table Tennis Players
### Video-Based Face Heart Rate Detection Process  
#### 4.2.1 Video Heart Rate Detection  
Based on the actual training scene of the smart table tennis in this paper, the daily environment is under the illumination of natural light or normal light. In this paper, the camera installed above the ball machine can collect continuous normal face images. Since video-based heart rate detection has high requirements for real time and stability of face image frames [24], in this paper, a relatively mature algorithm based on the ERT method of the Dlib library is selected to perform face detection feature point labeling and related tracker methods to track face feature parts. In this paper, the skin color RGB signal is extracted based on a fixed ROI (RegionOfInterest), and the average real-time heart rate is obtained by digital signal processing. As shown in Figure 2, it is a flowchart of video heart rate detection: \begin{table}
\begin{tabular}{c c c} \hline  & always & 75 \\ \cline{2-3}  & often & 15 \\ \cline{2-3}  & sometimes & 5 \\ \cline{2-3}  & never & 5 \\ \hline  & always & 70 \\ \cline{2-3}  & often & 20 \\ \cline{2-3}  & sometimes & 5 \\ \cline{2-3}  & never & 5 \\ \hline \end{tabular}
\end{table} 
Table 3: Post-match psychological stress. Landmark is a technology for extracting facial feature points. The Dlib library is marked with 68 face points. Figure 3 is a schematic diagram of the 68 marked face key points. Through the rapid real-time detection of the extracted 68 key points, a very wide range of applications can be generated, which can be used for eye fatigue detection and so on. The purpose of face detection is to extract the rectangular outline frame of the face from each frame of the video. The purpose of face alignment is to find several landmark parts on the face, such as the nose, eyes, etc. It is further cropped to facilitate subsequent processing. In the Dlib library, due to the high real-time requirements in the actual scene of this paper, this paper adopts the method of HoGFaceDetector [25]. The main idea of HoG is to use the local edge features of the face to represent the directional gradient histogram to detect the region of the face shape. The model consists of 5 HOG filters--front, left, right, front but rotated left, and front but rotated right [26; 27]. The gradient of any pixel \((x,y)\) in the simulated image \(f(x,y)\) is a vector, as shown in Equation (1):  
\[\
abla f(x,y)=\big{[}G_{x}G_{y}\big{]}^{T}=\bigg{[}\frac{\partial f}{\partial x }\frac{\partial f}{\partial y}\bigg{]}^{T}. \tag{1}\]  
Figure 3: Schematic diagram of face key point annotation. Figure 2: Flow chart of video heart rate detection. Among them, \(G_{x}\) is the gradient along the \(x\) direction, \(G_{y}\) is the gradient along the \(y\) direction, and the magnitude and direction angle of the gradient can be expressed as shown in Equations (2) and (3):  
\[|\
abla f(x,y)|=mag(\
abla f(x,y))=\left(G_{x}^{2}G_{y}^{2}\right)^{\frac{1}{2}} \tag{2}\]  
\[\phi(x,y)=arctan\big{(}G_{x}/G_{y}\big{)}. \tag{3}\]  
The one-dimensional discrete differential template then calculates the gradient information of the image simply, quickly, and effectively. The formulas are shown in Equations (4) and (5):  
\[G_{x}(x,y)=H(x+1,y)-H(x-1,y) \tag{4}\]  
\[G_{y}(x,y)=H(x,y+1)-H(x,y-1) \tag{5}\]  
In the formula, \(G_{x}\), \(G_{y}\), \(H(x\), \(y)\), respectively, represent the gradient of the pixel point \((x,y)\) in the horizontal and vertical directions and the gray value of the pixel. The formulas for calculating the magnitude and direction of its gradient are shown in Equations (6) and (7):  
\[G(x,y)=\sqrt{G_{x}(x,y)^{2}+G_{y}(x,y)^{2}} \tag{6}\]  
\[a(x,y)=tan^{-1}\bigg{(}\frac{G_{y}(x,y)}{G_{x}(x,y)}\bigg{)}. \tag{7}\]  
The advantages of using the HOG feature-based method are as follows. (1) It has the characteristics of being lightweight and is the fastest method running on the CPU. (2) It is used for frontal and slightly non-frontal faces.