## 3 Materials and Methods
### Person Detection and Subject Anonymization
This process works in an iterative way, with the system continuously checking whether the video stream has concluded. If the stream is ongoing, the algorithm advances to the next frame, repeating this procedure until the end of the stream, ensuring comprehensive and continuous monitoring throughout. For animating the 2D avatar, this study utilizes Panda3D, an open-source game engine that is supported in the Python programming language. Pose data, extracted in the form of pixel coordinates from the YOLOv8 model, identify 17 keypoints that represent a human figure's posture within a frame, as shown in Figure 5a. To align these keypoints with the rig joints of the 2D avatar, the raw keypoint data are transformed into joint angle data, ensuring that the avatar's movements accurately mirror those of the detected human posture, as shown in Figure 5b. Additionally, two extra keypoints are generated at the midpoint between keypoints [5; 6] and [11; 12] to determine the upper torso center and lower torso center coordinates, respectively. These coordinates are used for calculating the neck and spine angles, aligning with the 2D avatar's rig. To ensure smooth and natural transitions in the avatar's movements across consecutive video frames, a 3 rd-order polynomial fitting is applied to the extracted joint angle data to prevent any sudden jumps or jerk motions. Given three keypoints, \(A\), \(B\), and \(C\), where \(B\) is the joint for which the angle is calculated and \(A\) and \(C\) are adjacent joints, the angle at \(B\) can be calculated using the dot product formula. Using vectors \(\overrightarrow{BA}\) and \(\overrightarrow{BC}\) from the pixel coordinates of these points, the angle \(\theta\) for joint \(B\) can be calculated as shown in Equation (1):  
\[\theta=arccos\left(\frac{\overrightarrow{BA}\cdot\overrightarrow{BC}}{ \left\lVert\overrightarrow{BA}\right\rVert\left\lVert\overrightarrow{BC} \right\rVert}\right) \tag{1}\]  
However, considering the relative orientation of joints and given the planar nature of 2D avatar animation, this study uses a more direct approach to calculate the angles in 2D space, which can be represented as Equation (2), below:  
\[\theta=arctan2\left(u_{y},u_{x}\right)-arctan2\left(v_{y},v_{x}\right) \tag{2}\]  
Figure 5: (a) Pose keypoints extracted from the YOLOv8 model. (b) A 2D avatar and skeletal rig. where \(u_{y}\) and \(u_{x}\) are the \(x\) and \(y\) axis components of \(\overrightarrow{BA}\) and \(v_{y}\) and \(v_{x}\) are the \(x\) and \(y\) axis components of \(\overrightarrow{BC}\). This method significantly enhances 2D avatar animation by accurately accounting for vector orientation, which is crucial for replicating human movements. Utilizing the _arctan2_ operator, which assesses both vector magnitude and direction, ensures that angles are measured across the full 360\({}^{\circ}\) range, from 180\({}^{\circ}\) to -180\({}^{\circ}\). This capability allows for capturing motion in all four quadrants, an important feature for animating complex movements with lifelike accuracy. The study applies a 3 rd-order polynomial fitting to smooth the transitions of these angles over time, ensuring natural movement of the 2D avatar. Given a set of joint angles \(\theta\) over time \(t\), the polynomial fitting can be represented using Equation (3):  
\[\hat{\theta}(t)=a_{0}+a_{1}t+a_{2}t^{2}+a_{3}t^{3} \tag{3}\]  
where \(a_{0}\), \(a_{1}\), \(a_{2}\), and \(a_{3}\) are the coefficients determined by fitting the polynomial to the historical data of joint angles using the least squares method.