# Enhanced Fall Detection Using YOLOv7-W6-Pose for Real-Time Elderly Monitoring
## 3 Materials and Methods
### Pose Estimation and Fall Detection Algorithm
#### 3.4.2 Fall Detection Algorithm  
The fall detection algorithm uses a geometric approach to analyze the positions of different parts of a person's body and determine whether they have fallen. Specifically, it relies on the relationship between the positions of the shoulders, torso, and feet, correlating these positions to assess whether the current posture indicates a fall. To better understand this process, it is essential to detail how these coordinates are established and compared, as well as the thresholds that define a fall. 1. The algorithm begins by _extracting the coordinates of key points on the body:_ * Left and right shoulders: \(S_{l}(x_{l}y_{l})\), \(S_{r}(x_{r}y_{r})\). * Torso (both left and right sides): \(T_{l}(x_{Tl},y_{Tl})\), \(T_{r}(x_{Tr},y_{Tl})\). * Feet (left and right): \(F_{l}(x_{Fl},y_{Fl})\), \(F_{r}(x_{Fl},y_{Fl})\). 2. After obtaining these coordinates, an intermediate value is first calculated, called the \"_length factor_\". This factor is computed based on the geometric distance between the position of the left shoulder and the left torso, expressed using the Euclidean distance formula. This factor is later used to determine a relationship between the various parts of the body and evaluate their relative position. \[L_{factor}=\sqrt{\left(x_{l}-x_{Tl}\right)^{2}+\left(y_{l}-y_{Tl}\right)^{2}}\,,\] (1) This factor adjusts the detection thresholds so that the algorithm is applicable regardless of people's height or proportions. 3. _Thresholds_ used for fall detection: * Height of the shoulders relative to the feet: This checks whether the vertical coordinate of the left (or right) shoulder is lower than the vertical coordinate of the left (or right) foot, adjusted by the length factor. In a normal posture, the shoulders should be above the feet, but during a fall, they may end up lower or at a similar level to the feet. The algorithm considers a possible fall if the shoulders drop to a level close to the feet. The threshold can be defined as follows: \[y_{l}\leq y_{Fl}+\alpha\cdot L_{factor},\] (2)where \(\alpha\) is a small adjustment factor to account for natural variations of the body in a normal position. * Difference between the body's width and height: The algorithm calculates the difference between the vertical (height) and horizontal (width) dimensions of the bounding box that encloses the body. If the height becomes smaller than the width (i.e., the body is \"stretched\" horizontally rather than vertically), it is an indication that the person has fallen. The calculation of body dimensions can be performed as follows:  
Body height:  
\[H_{body}=|y_{l}-y_{Fl}|, \tag{3}\]  
Body width (the distance between the shoulders or between the sides of the chest):  
\[W_{body}=|x_{l}-x_{r}|, \tag{4}\]  
The threshold for detecting a fall could be:  
\[H_{body}<W_{body}, \tag{5}\]  
4. _Fall decision_  
If all conditions are met--meaning the shoulders and torso are at an abnormally low height compared to the feet, and the body has a greater horizontal than vertical dimension--the algorithm concludes that a fall has occurred. In this case, a positive fall signal is returned, along with the coordinates of the bounding box enclosing the body. Key thresholds in the algorithm:  
* Height of the shoulders and torso relative to the feet: This threshold is adjusted using the length factor to account for individual body proportions. Essentially, it checks if the shoulder and torso drop below an adjusted level relative to the feet. * Difference between body dimensions: If the difference between the height and width of the body becomes negative (height is smaller than width), this signals that the person is lying down. 5. _Differentiation between a fall and a person who is simply lying down_. To improve fall detection accuracy, we have differentiated between a fall and someone who is just lying down. One significant improvement is tracking the speed of movement.