# CREBAS: Computer-Based REBA Evaluation System for Wood Manufacturers Using MediaPipe
## 3 REBA Evaluation System Using MediaPipe
### Calculation of the Angles of Joints Using Inverse Kinematics (IK)  
The input data required for the REBA evaluation method are the angles of six joints: waist, neck, leg, upper arm, forearm, and wrist. However, the joint landmark calculated by MediaPipe does not include the waist and neck, and it has only coordinated information, not angle.  
Figure 11: Detection and body estimation: (**a**) Visualization of the detected body area; (**b**) body estimation and visualization.  
Equation 1 is to find the midpoint M between two connected points to obtain the position of the waist and neck. The position of the pelvis is the center of the left hip (Landmark 23) and the right hip (Landmark 24). The position of the chest is the center of the left shoulder (Landmark 11) and the right shoulder (Landmark 12), and these two positions enable us to know the position of the waist. Equation (1) is to find the midpoint M of two points in a three-dimensional space, and Figure 12 shows the concept for this equation.  
\[M=\left(\frac{x^{1}+x^{2}}{2},\ \frac{y^{1}+y^{2}}{2},\ \frac{z^{1}+z^{2}}{2}\right) \tag{1}\]  
Inverse Kinematics (IK) was used to obtain the joint angles required for REBA evaluation. IK is mainly used in the computer animation and robotics fields and is the opposite of Forward Kinematics. In Forward Kinematics, when the position and direction of the higher-level object in hierarchy change, the position and direction of the lower-level object are affected and determined; on the contrary, in Inverse Kinematics, the position and direction of child object affects the position and direction of parent object.  
In this study, Final IK provided by Unity Asset Store was used for IK calculation [27]. Final IK provides Full Body IK based on Cyclic Coordinate Descent (CCD) [28]. CCD is suitable for calculating the Inverse Kinematics of joints with complex structures. Figure 13 shows the process of CCD. Assume there are five joints, and when P\({}_{1}\) is the Base Joint and E is the End Effector, the angles of all joints are sequentially changed so that the difference in distance and direction between the End Effector and the Target (T) is minimized.  
Figure 12: Procedure of finding midpoints of two points.  
Figure 13: Procedure of CCD IK.  
Equation (2) is to find the angle of each joint through the dot product of two vectors (u,v) obtain from the Target position and the positions of the two joints.  
\[\theta_{i}=\cos^{-1}\biggl{(}\frac{u_{i}\cdot v_{i}}{|u_{i}||v_{i}|}\biggr{)} \tag{2}\]  
Figure 14 shows a model with Full Body IK applied, and the ball on the right hand of the model is an object for the calculation for the right-hand joint. Based on the IK, the position of the ball object appropriately changes the positions of the rest of the joints, creating a natural posture.  
Figure 15 is a human body model in which body parts are connected in a hierarchical form. The Human IK model is basically configured in a top-down manner based on the spine. The model is divided into shoulder and hip based on spine. The shoulder consists of head, arm, and hand, and the hip consists of leg, knee, and foot.  
As shown in Figure 16, the joint landmark of MideaPipe and the Scale Factor of the IK model were matched, and a total of nine joints were linked to an End Effector. Inputting the maximum weight of all linked effectors increases the response sensitivity of the connected joints. Figure 16 shows the angle GUI of the joint through the linked IK model.  
Figure 14: The position change of joints depending on the position change of the target.  
Figure 15: Avatar model information to which IK will be applied: (a) Avatar rigging model; (b) Avatar skeleton mapping; (c) Joint point information.