# Applying Vision-Based Pose Estimation in a Telerehabilitation Application
## 2 Materials and Methods
### ExerWeb Module
#### 2.3.1 Patient Management  
ExerWeb has an ExerCam Patient Management web page. This page is the default page accessed when a therapist enters the website (see Figure 6(a)). The Patient Management page offers a preview with the most relevant patient data in a table format. This section includes links to create, edit, delete, access the results of tasks and games and prescribe tasks and games to the patient. Both the creation mechanisms and the prescription of tasks are managed through forms (see Figure 6(b)).  
Figure 5: Different types of exergames developed.  
When the results of a patient are accessed, the history of tasks and games prescribed to that patient is shown (see Figure 7a,b). Each of the prescribed tasks or games has an associated file of results that were generated with the evaluation algorithm and can be downloaded in different formats (txt, JSON or CSV). Likewise, two graphs are displayed (or fewer if not they have enough data) with the evolution of the last two tasks performed and two graphs (or fewer if they do not have enough data) with the evolution of the last two games performed.  
The evaluation algorithm applied to the games consists of showing the degree of improvement set by the therapist when prescribing the game (time to overcome the activity, minimum necessary points, etc.). In the case of the tasks, the evaluation algorithm consists of calculating the ROM value.  
For the calculation of the ROM value, two possible solutions were considered: (1) a first solution based on the targets reached and (2) a second solution based on the variation of joint coordinates. The operations carried out are the following:  
* Target ROM: value obtained taking into account the targets reached. During the prescription of the task, the therapist sets the distance in degrees between each target (\(d\theta\)). Therefore, it is possible to calculate the ROM as a result of subtracting the angle in which the last target (\(D_{F}\)) reached with the angle of the first target (\(D_{I}\)) reached is located (see Equation (5)). We can take as an example the task of shoulder abduction  
Figure 6: Web page of ExerCam.  
Figure 7: Patient Management. (**a**) Main page of the Patient Management section. (**b**) Form for creating a new patient.  
shown in Figure 4c, with an angular pitch of \(10^{\circ}\). If the first target reached was 3 and the last target reached was 14 (see Figure 4c), then we can calculate the \(ROM_{x}\) as seen in Equation (6).  
\[ROM=(D_{F}*d\theta)-(D_{I}*d\theta) \tag{5}\]  
\[ROM_{x}=(14*10)-(3*10)=110^{\circ} \tag{6}\]
* Joint ROM: value obtained from the calculation of the subtraction between the final angle \(\theta_{2}\) and the initial angle \(\theta_{1}\) formed by Vectors v1 and v2 that form the existing segments between a joint (see Equation (7)). The magnitude of the angle between the two vectors is given by Equation (8).  
\[ROM=\theta_{2}-\theta_{1} \tag{7}\]  
\[\theta_{i}=cos^{-1}\bigg{(}\frac{v_{i1}\cdot v_{i2}}{\|v_{i1}\|\ \|v_{i2}\|}\bigg{)} \tag{8}\]  
For the example of shoulder abduction, the vectors involved correspond to those shown in Equations (9) and (10).  
\[v_{1i}[x_{i},y_{i}]=shoulder[x_{i},y_{i}]-neck[x_{i},y_{i}] \tag{9}\]  
\[v_{2i}[x_{i},y_{i}]=elbow[x_{i},y_{i}]-shoulder[x_{i},y_{i}] \tag{10}\]