## 4 Methodology: Computer Vision and Deep Learning
### Computer Vision
Although movements are analyzed in three dimensions, the patient's feedback interface is two-dimensional: an arc is shown that delineates the trajectory to be followed, bounded by the extreme points as shown in Figure 9.  
This approach was chosen to make the visual feedback clearer and more accessible. Depending on the exercise, the patient will need to position themselves either facing or sideways to the camera. In the case of the shoulder abduction exercise, for example, the user must face the Kinect sensor, since the movement mainly involves the frontal plane (\(x\), \(y\)). However, it remains important to monitor depth variations to avoid incorrect or potentially  
Figure 8: Stylized human skeleton with joint points labeled as S (starting), I (intermediate), and T (terminal) on each limb. harmful postures. The correct supervision of exercises therefore depends on the precise definition of the limits within which a movement is considered physiological. The correct performance of exercises depends not only on identifying the area in which the movement should be carried out but also on the user's performance. The expected movement area defines the limits within which the limb must move safely without exceeding thresholds that are too high or too low. At the same time, performance evaluation serves to determine how closely the user approaches the intended goal. To measure performance along the horizontal (\(P_{x}\)) and vertical (\(P_{y}\)) axes, the following formulas are used:  
\[P_{x}(\%) =\frac{T_{x}-S_{x}}{L}\times 100,\] \[P_{y}(\%) =\frac{T_{y}-S_{y}+L}{L}\times 100.\]  
where  
* \(\vec{S}=(S_{x},S_{y})\) is the starting node position (e.g., shoulder or hip);
* \(\vec{T}=(T_{x},T_{y})\) is the terminal node position (e.g., hand or foot);
* \(L=\|\vec{T}-\vec{S}\|=\sqrt{(T_{x}-S_{x})^{2}+(T_{y}-S_{y})^{2}}\) is the limb length, i.e., the Euclidean distance between the two nodes;
* \(P_{x}\) and \(P_{y}\) represent the percentage of movement extension along the horizontal and vertical axes, respectively, normalized by the limb length. The formula for \(P_{x}\) calculates the percentage of horizontal displacement of the terminal node relative to the total limb length. The formula for \(P_{y}\) measures the vertical displacement, adjusted by the initial vertical position of the starting node and also normalized by the limb length. These percentage values allow assessing how closely the limb's movement approaches the correct execution, enabling accurate feedback for real-time monitoring. In some types of exercise, such as those that involve backward movement of the limb (such as shoulder or hip extension), the motion is evaluated based on the angle \(\alpha\) (where \(\alpha\) is expressed in radians) between the limb and the torso, as shown in Figure 10.  
Figure 9: Trajectory to be followed by the patient, represented as an arc. In these cases, performance \(P_{\alpha}\) is calculated using the following formula:  
\[P_{\alpha}(\%)\ =\ \frac{\alpha}{\pi}\times 100\]  
Another important aspect of the system is the repetition counter, which must be carefully managed to avoid mistakes, especially when movements are minimal or the patient does not maintain the correct posture. For each repetition, it is essential to ensure that the limb is fully extended and the performance values along \(x\) and \(y\) increase compared to the initial position.