# Error-Resistant Movement Detection Algorithm for the Elderly with Smart Mirror
## 4 Movement Detection Algorithm for the Elderly in Smart Mirror
### Vector Sum Method for Solving Limitations  
Looking at Figures 4c and 6, the amount of movement is insignificant even when the hexagon and the inverted triangle ( in Figure 6) in the shoulder area are compared, but the distance between the hexagon and the triangle () is very large, even though the distance between the triangle-rhombus and the rhombus-hexagon is small in the wrist figure. Therefore, if one compares the magnitude of the vector sum moved several frames in a row instead of making a one-to-one comparison with the previous frame, it would be acceptable to set the threshold somewhat higher. This method is called the Vector Sum Method (VSM). Formulas are given below Figure 6.  
Figure 5: Locus of left elbow point (which is represented as a circle). Locus shows as much as before RecentFrame (RF) from the Current Frame. RecentFrame is the frame depth variable, which is 5 in the current figure. Figure 6: Locus of left elbow point (which is represented as a circle), as much as before RecentFrame (RF) from the Current Frame. RecentFrame is the frame depth variable, which is 5 in the current figure. This figure is from the shoulder area of Figure 4c. In expression (5), sum of displacement of joint at each frame (\(\left|\sum_{l=0}^{k}\overline{P_{l}P_{l+1}}^{\gamma}\right|\)) is compared with threshold to return boolean value whether it is less or more, through frame depth. In expression (6), as we use the majority result of recent frames for handling detection error, variable 'Moved' and 'Stopped' is counted based on the method's return value. \[ \begin{split}\forall k\text{ in }0\leq k<RF,\begin{cases}\text{Moved} \longleftarrow\text{Moved}+1,&\text{if }\left|\sum_{l=0}^{k}\overline{P_{l}P_{l+1}} \right|\geq\text{threshold}\\ \text{Stopped}\longleftarrow\text{Stopped}+1,&\text{if }\left|\sum_{l=0}^{k} \overline{P_{l}P_{l+1}}\right|<\text{threshold}\end{cases}\\ \text{Movement at current frame}\longleftarrow\begin{cases}\text{True},& \text{if Moved}\geq\text{Stopped}\\ \text{False},&\text{if Moved}<\text{Stopped}\end{cases}\end{split} \end{split} \tag{5}\]  
Even if vector sum is used for displacement, using VSM is different from just downsampling all the frames because the downsampling method is faulty in the case of periodic motion. Figure 7 shows 5 coordinates moving to the right and coming back. This case is detected as a movement by the vector sum method, as \(\overline{P_{0}P_{1}}\), \(\overline{P_{0}P_{2}}\) is greater than the threshold. However, if downsampling occurs by calculating only the initial-final coordinates (\(\overline{P_{0}P_{RF}}\)), the final displacement will be smaller than the threshold, as shown in the figure (\(P_{0}P_{RF}<\text{Threshold}\)). The rationale for using this method is that negligible movements--natural error, changes according to physiological movements--have no direction, so there is no difference between the change between frame \(t=1\) and \(t=600\), whereas if there is a movement, even if the difference is insignificant, difference continues to increase, as shown in Figure 8. Even if the movement is slow, the size of the sum of vector through N frames increases maximally N times, so if the movement is intentional, the threshold can be amplified. Figure 7: Locus of returning point (which is represented as a circle). However, the VSM also has limitations. Because the information of past frames has to be compared, the memory will be increased. Additionally, compared with the ASFM, where only the previous coordinates were compared and calculated, the computation will be increased as well. In addition, there is a possibility that the slower the object, the larger the value of frame depth is needed. In addition, there is another limitation to this detection method. This algorithm cannot increase the threshold and frame depth too much. This is an issue of periodic motion. Intentional movement assumes that there is a direction for a very short time, no matter how irregular, as long as the person intends it.