## 3 Methodology
### Method  
Figure 4 shows the workflow for activity prediction using images from videos of pedestrians waiting for the bus or boarding and alighting the bus. Below, each stage of this methodology is described. Firstly, the data are captured. In this study, real-world video recordings were made using an RGB camera, capturing the dynamic and varied scenarios of passengers boarding and alighting from buses in the urban setting of Valparaiso, Chile. The choice of this environment was deliberate, aiming to capture the natural movements and behaviors of pedestrians and passengers in a typical public transportation context. The recorded activities covered a wide range of common behaviors such as pedestrians standing or sitting while waiting for the bus, pedestrians walking around the bus stop area, and passengers engaging in the process of boarding or alighting from the bus. These activities represent  
Figure 4: Workflow for activity prediction using AlphaPose and Random Forest (RF) ML model. Figure 3: Workflow for activity prediction. typical behaviors that occur at bus stops, providing a comprehensive dataset for analyzing pedestrian movement patterns in transit environments. The diversity of activities in the captured data helps ensure that the model can be generalized to real-world scenarios beyond controlled or artificial settings. Secondly, the estimation of the pose is obtained. Once the videos were captured, individual frames from each video were extracted to be processed using the AlphaPose pose estimator. AlphaPose is a state-of-the-art system for human pose estimation that identifies key body joints (such as the elbows, knees, shoulders, and ankles) from each frame. These key points are used to construct a skeleton model of each person in the scene. The skeletal feature extraction process begins with person detection using an object detector (e.g., YOLOv3 or Faster R-CNN). Once the regions of interest corresponding to each person are identified, the model applies a pose estimation network that predicts the precise location of anatomical key points, thereby generating a skeletal representation. Each skeleton generated by AlphaPose consists of a set of 17 key points (following the COCO format), each represented by a pair of coordinates (x, y) in the image, along with a confidence score indicating the model's certainty regarding the prediction. The 17 key points generated by AlphaPose include Nose, Left Eye, Right Eye, Left Ear, Right Ear, Left Shoulder, Right Shoulder, Left Elbow, Right Elbow, Left Wrist, Right Wrist, Left Hip, Right Hip, Left Knee, Right Knee, Left Ankle, and Right Ankle. The output from AlphaPose is a json file containing the coordinates of the 17 key points for each person in every frame of the video. This file provides a skeletal representation of pedestrians and passengers, which is essential for understanding their movements and posture. The pose estimation process is crucial, as it allows the system to capture detailed information about the human body's positioning, enabling more accurate activity recognition based on body posture and motion. Thirdly, after pose estimation, the raw output from AlphaPose (the json files) is converted into a.csv format to facilitate further analysis. The conversion process involves parsing the JSON data to extract relevant pose features, such as the positions of the joints, and organizing them into a structured table format. These cleaned and organized data are essential for building the feature vector, which serves as the input to the activity prediction model. The feature vector consists of 51 columns, each corresponding to the x-position, y-position, and score of each of the 17 skeleton key points, so 17 \(\times\) 3 = 51. Each row of the.csv file represents a person in each frame of the video, providing a complete dataset of each person's pose at a given time. Finally, we obtain the feature vector, a two-dimensional matrix with 51 columns and rows equal to the number of people detected per frame.