# Design and Validation of Rule-Based Expert System by Using Kinect V2 for Real-Time Athlete Support
## Materials and Methods
### System Architecture  
The movement data in our system during training is obtained through Kinect via a USB 3.0 connection. The data received are in the form of depth data. The system is written in C# language. The computer in which the system is run has a i7 2.4 GHz processor, 12 GB of RAM, 1 TB HDD, and a 4 GB external graphics card. Skeletal inference is performed as shown in Figure 4a by processing with SDK 2.0, which is part of Kinect that we use in the system and can be downloaded from Microsoft's official website. Users do their training at a distance of 2.5 m from Kinect, which is placed on a tripod 0.8-1.2 m high from the ground, as described in [33; 59]. In addition, joint angles and inter-joint distances are calculated using the data obtained from skeletal extraction (see Section 2.3). The obtained angle and distance values are sent to Expert System as input values over the running memory. The Expert System, which we develop according to the movement model, consists of 7 sections (Figure 4b). These are expert interface, Expert System rule base, system database, running memory, inference module, knowledge base editor, and user interface. Rules can be added to the expert system through the expert interface. In the interface shown in Figure 5a, experts can enter the angle, distances, states of accuracy, and warnings about the training system. The created rules are made available in Expert System by converting them into \"If-Then\" structures in the knowledge base editor before they are added to the rule base, as shown in Section 2.5. This process is done by compiling the converted \"If-Then\" structures in the interface as a dynamic-link library (DLL) both before and during running [74; 75]. The rules created here are classified according to the type of movement and displayed first in the rule base and then sent to the database. On the other hand, during usage, the rules are retrieved from the database as DLL and transferred to the rule base [76], then processed in the inference engine. The inference engine processes by taking rules from the running memory and rule base on which training data of the user is arranged for use. The inference engine performs three main functions: matching, selecting, and executing. Based on the data from the inference engine, it looks for a match in the rules on the rule base. This matching is done in two ways as forward and backward chaining in Expert System [77]. In terms of ease of use in our system, the forward chaining model is preferred as used in [78]. It executes the specified operations by selecting rule or rules about matching (creating movement accuracy and movement correction data) as shown in Figure 6.  
Figure 6 illustrates the work of the inference engine in a case where the rules 2-3, 4-5, and 7-8 are active. Inference engine processes rule according to their relationship to each other (availability in the DSP and/or LR movement, rule scope). This process consists of two parts. The first part is the exclusion of rules by using OR procedure in the rules used for the same movement. In this process, warning selection is made by considering which rule is more comprehensive. In the second part, AND procedure is performed in rules used for different movements and a warning is extracted. In this process, a warning selection is made for both rules by considering which rules contain more common features. By applying the same operations to the warnings, the warning selection is made, and the inference engine concludes. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \multirow{2}{*}{**Y**} & \multirow{2}{*}{**Output Cases**} & \multicolumn{8}{c}{**Rules Conditions**} \\ \cline{3-10}  & & **Q1** & **Q2** & **Q3** & **Q4** & **Q5** & **Q6** & **Q7** & **Q8** \\ \hline
**1** & 1 xx1111 & 1 & x & x & x & 1 & 1 & 1 & 1 \\
2 & 111x1x11 & 1 & 1 & x & 1 & x & 1 & 1 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Sample Output Values of Main Conditions.