# Applying Vision-Based Pose Estimation in a Telerehabilitation Application
## 2 Materials and Methods
### ExerPlayer Module
#### 2.2.2 ExerPlayer Task Mode  
The objective of the task mode is to provide the therapist with a mechanism to evaluate the range of motion (ROM) of specific joints and the reaction time of each patient. Additionally, it can be used as a goniometer. The task is to perform a specific movement that has been previously prescribed by the therapist (in Figure 4, an example of the shoulder abduction task is shown), and for this, the application gives visual support through a band of targets and the virtual skeleton (see Figure 4a,b). Through the REST API, the data of the tasks prescribed by the therapist are received via HTML. With the GET statement, the exact positions of all the targets of the exercise are obtained. The targets and their position are automatically generated by the target location algorithm (TLA). The TLA algorithm developed for ExerCam calculates the exact position where the targets should be and ensures that the movement performed is correct. The TLA algorithm adapts the distance and location of the targets to each patient and each session, taking into account the main joint of the task and the parameters collected in the calibration mode. The number of targets to be displayed is set by a parameter configurable by the therapist. For the development of the TLA algorithm, the movements of the articulations included in the tasks were studied in depth. What all the tasks have in common is that joint movements describe a circular movement so that the targets will form a semicircle by taking as a central point the joint to be measured. In this sense, the placement algorithm will require a central point (it will be the main articulation of the task), a radius (distance between joints) and a start and end angle. Table 1 shows, for each of the tasks implemented in ExerPlayer, the maximum and minimum values assigned for each joint. These values were obtained from theoretical values marked by the articular scales established in the R.D. 1971/1999 (based on the American Medical Association guide) [44]. As an aid, the TLA algorithm sets the initial position of the main joint of the task and shows a target of the color of the corresponding main joint (see Figure 4a). In this way, the patient can be positioned correctly. For the example of the left shoulder abduction task, the algorithm TLA takes the patient's shoulder joint (Center 2) as its central point and shows the shoulder target in the center of the positioning zone (see Figure 4a). For other joints, the target is drawn in other positions. The algorithm calculates the value of the radius \(r\), as shown in Equation (3), where the radius is equal to the distance between the shoulder joints, represented by \(C(h,k)\), and the wrist \(P(h,k)\). The joints involved in each task are reflected in the Radius column of Table 1.  
\[ \begin{array}{c}\textit{Shoulder}\ \rightarrow\ C(h,k)\\ \textit{Wrist}\ \rightarrow\ P(h,k)\\ d(C,P)=r=\sqrt{\left(x-h\right)^{2}+\left(y-k\right)^{2}}\end{array}  \tag{3}\]  
Once the radius is obtained, the algorithm of the incremental method of drawing a circle [45] is applied, and given an angular step, constant and selected by the therapist (\(d\theta\)