# Predicting Dog Emotions Based on Posture Analysis Using DeepLabCut
## 3 Materials and Methods
### Dog Emotion Detector
#### 3.3.3 Pose Metrics  
The general idea underlying the formulas for measuring the dog's posture is to determine various angles that are as independent as possible of breed, other characteristics of the dog, or other objects in the photograph. Figure 2 can be referred to for interpretation of the landmark numbers. Preliminary testing of the newly trained DLC detector showed that the keypoint detection performs significantly worse when the dog is not standing or sitting. Therefore, no calculations are performed to determine an exposed belly, which is a strong sign of submission in dogs. The **body weight distribution** of a dog can be calculated using the slope of the hypothetical line between the withers (keypoint 22) and the base of the tail (keypoint 12) as shown in Figure 3. To prevent an uneven surface or the dog's posture from affecting the slope, the angle \(\alpha\) is calculated using the to line between the front (keypoint 0/6) and back (keypoint 3/9) paws of one side. If possible, the paw coordinates of the side facing the camera are used, as these are usually more accurate. If the intersection of the two lines considered is in front of the withers (keypoint 22), i.e., in the direction of the dog's head, the angle between the lines is recorded as positive. In the opposite case, a negative degree is recorded, and in the case of parallelism, the value zero is recorded. Figure 3: Calculation of the body weight distribution. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
\begin{tabular}{c} Open, tongue \\ visible \\ \end{tabular} \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Dog posture characteristics [26; 27]. If the withers are obscured, it should be possible to measure the body weight distribution using the throat keypoint (23). For comparability of both calculations, the following linear equation was obtained to convert the throat-based angle:  
\[\text{body weight distribution}=-14.1+0.3\times\text{(throat-based body weight distribution)} \tag{1}\]  
This equation was obtained by applying a linear model to all keypoint pairs (withers/throat). The **tail position** can be calculated by using the angle \(\alpha\) displayed in Figure 4 between the hypothetical line connecting the withers (keypoint 22) and the base of the tail (keypoint 12), hereafter referred to as the dorsal line, and the hypothetical line between the base of the tail (keypoint 12) and the tip of the tail (keypoint 13). A raised tail, characterized by the tip of the tail being above the extended dorsal line, is recorded as a positive value. A lowered tail, recognizable by a tail tip below the extended dorsal line, is given a negative sign. Zero is measured for the tail position if the tail tip is exactly on the extended dorsal line. Again, it should be possible to perform the calculation using the throat point (23) instead of the withers point (22). The following equation is used for the conversion:  
\[\text{tail position}=18.7+0.98\times\text{(throat-based tail position)} \tag{2}\]  
The **head position** measures the degree of elevation of a dog's head by observing the slope of the line connecting the withers (keypoint 22) and the nose (keypoint 16), as shown in Figure 5. Like the body weight distribution calculation, the angle \(\alpha\) is calculated using the baseline between a front (keypoint 0/6) and back (keypoint 3/9) paw. A raised head is measured positively, while a lowered head indicates a negative value. In the case of hidden withers, the throat-based calculation can be converted using the following equation:  
\[\text{head position}=-2.78+0.06\times\text{(throat-based head position)} \tag{3}\]  
The **ear position** describes the orientation of the ears in relation to the head as described by the angle \(\alpha\) and displayed in Figure 6. Since usually, just the keypoints of one ear are entirely available, only one ear is considered for the calculation and, if possible, the one facing the camera.