## 3 Method
### Golf Swing Analysis Algorithm
#### 3.2.1 Spatial and Temporal Alignment  
In this section, we introduce an algorithm for spatially and temporally aligning coordinates to compare golf swing poses that were gathered in various environments. Spatial alignment refers to adjusting coordinates estimated at different resolutions to the same size and location. To do this process, we define the standard coordinate \(s(x^{s},y^{s})\) and height \(h^{s}\) for normalizing the size and location of the pose. We first calculate the ratio \(r\) by dividing the standard height \(l^{s}\) by the target height \(h^{t}\), which is calculated as the distance between the head and foot coordinates of the target pose. Then, we calculate the distance between the standard coordinates \(s(x^{s},y^{s})\) and the resized root joint \(t(x^{root},y^{root}r)\) of the target pose to derive the required coordinate shift distances \(d^{x}=x^{s}-x^{root}r\) and \(d^{y}=y^{s}-y^{root}r\) for each axis. Finally, we can acquire the normalized \(X\) of each target joint \(i\) by:  
\[X^{i}_{SpatialNorm}=((x^{i}r)+d^{x},(y^{i}r)+d^{y}) \tag{1}\]  
Temporal alignment involves the use of a posture segmentation algorithm to divide the swings of both learners and experts into stages based on the eight distinct actions in golf. The primary goal of this algorithm is to adjust temporal differences between two videos by recognizing each segment of the swing action through action segmentation. In this study, golf positions were categorized into Address, Takeback, Backswing, Backswing-top, Downswing, Impact, Follow, and Finish. We annotated the joint coordinates manually using standard swing posture images representing each posture and calculated the similarity of the user's entire swing and each action using Euclidean distances. However, due to the nature of golf swing actions, the Address, Takeback, and Backswing positions display similar motions to the Impact and Downswing positions. This similarity causes irregular posture segmentation and prevents the adjustment of the temporal differences between positions by reversing the temporal flow of the swing. In this study, we proposed an algorithm that divides golf swing positions into two segments based on the Backswing-top and Finish positions to distinguish each action. The proposed algorithm is detailed in Algorithm 1, and the flow chart is illustrated in Figure 1 in Appendix A.  
Algorithm 1 analyzes changes in the y-coordinates of both wrists to detect the Backswing-top and Finish actions in a golf swing, where the wrist has the highest value. When the y-value increases from the preparatory action, the action is considered to have started, and the search for the highest height begins. The algorithm tracks changes, updates the highest y-value, and determines that the Backswing-top action has been found when the value no longer increases and begins to decrease. Afterward, the y-value is updated again until the Finish action appears. Through this process, the golf action is divided into two sections based on the Backswing-top, and the Euclidean distance measurement is used to determine the reference frames for the Address, Takeback, and Backswing actions in the first section and the remaining actions in the second section. In this way, the posture data containing the action segmentation markers for the temporal alignment of golf swing video frames can be obtained. Finally, we are able to obtain the normalized data's \(X_{Norm}\) through the spatial and temporal alignment algorithms.