Methods for Spatiotemporal Analysis of Human Gait Based on Data from Depth Sensors

Gait analysis may serve various purposes related to health care, such as the estimation of elderly people’s risk of falling. This paper is devoted to gait analysis based on data from depth sensors which are suitable for use both at healthcare facilities and in monitoring systems dedicated to household environments. This paper is focused on the comparison of three methods for spatiotemporal gait analysis based on data from depth sensors, involving the analysis of the movement trajectories of the knees, feet, and centre of mass. The accuracy of the results obtained using those methods was assessed for different depth sensors’ viewing angles and different types of subject clothing. Data were collected using a Kinect v2 device. Five people took part in the experiments. Data from a Zebris FDM platform were used as a reference. The obtained results indicate that the viewing angle and the subject’s clothing affect the uncertainty of the estimates of spatiotemporal gait parameters, and that the method based on the trajectories of the feet yields the most information, while the method based on the trajectory of the centre of mass is the most robust.


Introduction
The typical gait requires proper functioning of the musculoskeletal and central nervous systems, which involves the ability to perform complex movement patterns and to rapidly process sensory input [1]. Thus, the analysis of human gait, aimed at detecting its abnormalities and identifying their causes, may support the development and optimisation of therapeutic procedures [2]. Useful information may be obtained by comparing a patient's gait characteristics before and after some medical intervention [3]. Gait analysis may also be part of research activities and contribute to the design of new clinical practices [4]. Some indicators of the variability of selected spatiotemporal gait parameters are correlated with the risk of falling [5,6] and the presence and severity of Parkinson's disease and Huntington's disease [7].
Gait disorders typically accompany ageing-related decline in the general health status and the loss of functional mobility. The accidental falls of the elderly-of which a substantial proportion occurs during walking [8]-are one of the most common causes of bone fractures and head traumas which lead to hospitalisation [9]. The prevention of such falls-aimed at improving the quality of life of the elderly and reducing public expenditures related to health care services-has become a challenge of significant social importance because the share of the elderly in the global population is growing rapidly [10]. The results of gait analysis may serve estimation of the risk of falling [11] and may support the early diagnosis of neurodegenerative diseases [12], thus contributing to the effectiveness of fall prevention efforts.
Enabling elderly people to live independently in their households-rather than admitting them to nursing care facilities-might not only improve their quality of life but also relieve public health care institutions of some of their workloads and thus provide savings on health care expenditures [13]. Monitoring systems devoted to the household environment, capable of tracking the long-term evolution of parameters related to health status and designed to notify caretakers about the need for intervention, may enable and support elderly persons' independent lives [14]. The development of technological solutions allowing for efficient and reliable gait analysis, applicable in monitoring systems operating in household environments, is, therefore, desirable from the social point of view [15].
Various techniques for clinical gait analysis have been developed, including optoelectronic motion-capture systems and platforms and treadmills equipped with force sensors [16]. Wearable sensors-such as inertial measurement units or pressure-sensing foot insoles-have also been used in commercially available gait-analysis systems and research studies [17]. Depth sensors are not yet widely used for gait analysis, but the possibility of using them for this purpose has attracted researchers' interest for over a decade [18]. A depth sensor allows for estimating its distance from points on surfaces reflecting infrared light, thus providing data organised into so-called depth images in which each pixel represents a triplet of three-dimensional coordinates (Figure 1a). What makes such sensors particularly promising for human motion analysis is the existence of effective algorithms for detecting human silhouettes in depth images and algorithms for processing those silhouettes, to estimate the three-dimensional positions of selected anatomical landmarks, including several points along the spine, joints of the upper and lower limbs, and the centres of the head and feet (Figure 1b).
share of the elderly in the global population is growing rapidly [10]. The results o analysis may serve estimation of the risk of falling [11] and may support the early nosis of neurodegenerative diseases [12], thus contributing to the effectiveness of fal vention efforts.
Enabling elderly people to live independently in their households-rather tha mitting them to nursing care facilities-might not only improve their quality of lif also relieve public health care institutions of some of their workloads and thus pr savings on health care expenditures [13]. Monitoring systems devoted to the hous environment, capable of tracking the long-term evolution of parameters related to h status and designed to notify caretakers about the need for intervention, may enabl support elderly persons' independent lives [14]. The development of technological tions allowing for efficient and reliable gait analysis, applicable in monitoring sys operating in household environments, is, therefore, desirable from the social point of [15].
Various techniques for clinical gait analysis have been developed, including o lectronic motion-capture systems and platforms and treadmills equipped with force sors [16]. Wearable sensors-such as inertial measurement units or pressure-sensing insoles-have also been used in commercially available gait-analysis systems an search studies [17]. Depth sensors are not yet widely used for gait analysis, but the p bility of using them for this purpose has attracted researchers' interest for over a d [18]. A depth sensor allows for estimating its distance from points on surfaces refle infrared light, thus providing data organised into so-called depth images in which pixel represents a triplet of three-dimensional coordinates (Figure 1a). What makes sensors particularly promising for human motion analysis is the existence of effecti gorithms for detecting human silhouettes in depth images and algorithms for proce those silhouettes, to estimate the three-dimensional positions of selected anatomical marks, including several points along the spine, joints of the upper and lower limbs the centres of the head and feet (Figure 1b).  Depth sensors are much cheaper and smaller than optoelectronic motion-capture systems and tensometric platforms. They do not require any devices or markers to be worn on the body or clothes of the examined person. A functional gait analysis system may be composed of a depth sensor connected to a computer, so it can be easily installed in various spatial configurations. If the person being monitored in the home is concerned, depth sensors do not violate that person's privacy as much as video cameras. Gait analysis systems based on depth sensors are often considered suitable for screening patients before more detailed diagnostic procedures [18]. The possibility of using depth sensors for gait analysis in monitoring systems dedicated to household environments has not yet been extensively studied, i.e., no data-processing method has been conclusively proven to yield reliable estimates of gait parameters under diverse conditions in such environments.
Despite the practical advantages of depth sensors, their application for gait analysis remains a technical challenge because of the following facts: • estimates of the positions of anatomical landmarks obtainable using depth sensors are corrupted by non-negligible measurement uncertainty-in particular, estimates of the positions of feet [19]; • during walking, the lower limbs may occlude each other from time to time, making it difficult to accurately track the movement of both of them simultaneously; • estimates of positions of anatomical landmarks can usually be obtained only in part of the depth sensor's field of view, typically covering no more than 1 or 2 strides; • the angle between the walking direction and the depth sensor's line of sight, as well as the subject's clothing, may affect the accuracy of localisation of anatomical landmarks.
The last point is irrelevant in the case of diagnostic procedures carried out in health care facilities where the patients can be advised to wear standard clothes and asked to walk in a specified direction. It is, nevertheless, relevant in the case of in-home monitoring systems expected to provide reliable information regardless of the monitored person's walking direction and clothing.
Various methods for spatiotemporal gait analysis based on data from depth sensors have been proposed during the last several years. Ferraris et al. considered analysing the antero-posterior velocity of the ankles using a Kinect v2 device placed in front of the walking person [20]. Dubois et al. considered analysing the vertical oscillations of the walking person's centre of mass using a Kinect v2 device placed at that person's side [21] or in the corner of a room [22]. Several authors considered analysing the distance between the ankles using Kinect v2 devices placed in front of the walking person [23][24][25] or in other spatial configurations [26]. Castaño-Pino et al. considered performing the wavelet analysis of the trajectories of the ankles [27]. Albert et al. considered analysing the anteroposterior positions of the feet using Kinect v2 and Azure Kinect devices placed in front of a treadmill [28]. Vilas-Boas et al. considered analysing the distance between the ankles, the velocity of the ankles, and the shank-to-vertical angle using Kinect devices placed in front of and behind the walking person [29,30]. Atanasov and Kampel considered analysing the horizontal velocity of the walking person's centre of mass [31]. Geerse et al. considered analysing the antero-posterior distance between the spine base and the ankles using a Kinect v2 device placed so that there was a 70 • angle between its line of sight and the walking direction [32]. Auvinet et al. considered analysing the distance between the knees using a Kinect v2 device placed behind a treadmill [33]. Amini et al. considered analysing the knee joint angle and the height of the ankles using a Kinect v2 device placed in front of the walking person [34]. Xu et al. considered analysing the distance between the ankle and the hip using a Kinect v1 device placed in front of a treadmill [34,35]. Hynes et al. proposed an original algorithm for estimation of spatiotemporal gait parameters based on clustering the estimates of positions of feet [36]. Latorre et al. compared five such methods using data from a Kinect v2 device placed in front of walking persons [37]. Some authors also considered using multiple depth sensors simultaneously [38,39] or attaching depth sensors to walkers [40,41]. A systematic review of gait analysis techniques based on depth sensors can be found, e.g., in [42].
The accuracy of most of the aforementioned data-processing methods has been assessed using reference equipment such as optoelectronic motion capture systems: Vicon [20,23,28,33], Qualisys [26,29,30], or Optotrak [32,35]; tensometric platforms, i.e., GAITRite [43] or Zeno Walkway [36]; or wearable inertial measurement units [22]. However, to the best of the authors' knowledge, only one study aimed at a systematic comparison of a subset of those methods has been published [37], and it considered only conditions in which the walking direction and the subject's clothing can be controlled. The influence of the subject's clothing or the angle between the depth sensor's line of sight and the walking direction on the accuracy of those methods has not yet been systematically studied. This paper is devoted to a comparison of three methods for the estimation of selected spatiotemporal gait parameters based on data from a depth sensor, viz.: • a method based on the analysis of the anteroposterior distance between the examined person's knees, being a variant of the method described in [33]; • a method based on the analysis of the vertical oscillations of the examined person's centre of mass, being a variant of the method described in [22]; • a method based on the analysis of the horizontal velocity of the examined person's feet, being a variant of the method described in [20].
The uncertainty of the estimates of selected spatiotemporal gait parameters obtained using these methods was assessed for different depth sensors' viewing angles and various types of subjects' clothing.

Transformation of the Coordinate System
The data acquired using a depth sensor represent estimates of the three-dimensional position in a coordinate system relative to the sensor's internal structure. On the other hand, the studied methods for estimation of spatiotemporal gait parameters, described in subsequent sections of this study, involve processing estimates of the positions of body parts-such as the knees or feet-either along the body's antero-posterior axis or its vertical axis. Therefore, before further processing, two rotations of the depth sensor's coordinate system are necessary: a rotation that places one of the coordinate axes parallel to the examined person's vertical axis and a rotation that places one of the remaining coordinate axes parallel to the person's walking direction ( Figure 2). the subject's clothing or the angle between the depth sensor's line of sight and the walkin direction on the accuracy of those methods has not yet been systematically studied. This paper is devoted to a comparison of three methods for the estimation of selecte spatiotemporal gait parameters based on data from a depth sensor, viz.: • a method based on the analysis of the anteroposterior distance between the examine person's knees, being a variant of the method described in [33]; • a method based on the analysis of the vertical oscillations of the examined person centre of mass, being a variant of the method described in [22]; • a method based on the analysis of the horizontal velocity of the examined person feet, being a variant of the method described in [20].
The uncertainty of the estimates of selected spatiotemporal gait parameters obtaine using these methods was assessed for different depth sensors' viewing angles and variou types of subjects' clothing.

Transformation of the Coordinate System
The data acquired using a depth sensor represent estimates of the three-dimension position in a coordinate system relative to the sensor's internal structure. On the oth hand, the studied methods for estimation of spatiotemporal gait parameters, described subsequent sections of this study, involve processing estimates of the positions of bod parts-such as the knees or feet-either along the body's antero-posterior axis or its ve tical axis. Therefore, before further processing, two rotations of the depth sensor's coord nate system are necessary: a rotation that places one of the coordinate axes parallel to th examined person's vertical axis and a rotation that places one of the remaining coordina axes parallel to the person's walking direction ( Figure 2). (a) The coordinate system (x p , y p , z p ) associated with the examined person, in which the x p axis corresponds to that person's medio-lateral axis, the y p axis-to that person's vertical axis and the z p axis-to that person's anteroposterior axis; (b) The angle ϑ of rotation necessary to make one of the coordinate axes associated with the depth sensor parallel to the examined person's vertical axis; (c) The angle ϕ of rotation necessary to make one of the coordinate axes associated with the depth sensor parallel to the examined person's walking direction.
The angle ϑ between the sensor's y s axis and the examined person's y p axis ( Figure 2b) can be estimated by identifying the ground plane, e.g., using the RANSAC algorithm [44]. Algorithms for this purpose are implemented in popular devices comprising depth sensors such as the Microsoft Kinect devices [45]. The corresponding rotation of the coordinate system can be described by the following formula: (1) where x s , y s and z s denote coordinates along the sensor's axes shown in Figure 2. The angle ϕ between the sensor's z s axis and the examined person's walking direction (Figure 2c) can be estimated by fitting the horizontal trajectory of that person's centre of mass with a straight line. The position of the examined person's centre of mass can be approximated by an estimate of the position of that person's spine base, which-in turn-can be obtained using a typical algorithm for localisation of anatomical landmarks in human silhouettes in depth images. The corresponding rotation of the coordinate system can be described by the following formula: The data processing method called the KD method (referring to the acronym of "knee distance") is based on the observation that during walking, the local maxima of the distance between the knees, measured along the anteroposterior axis, approximately coincide with the foot contact (FC) moments (i.e., the moments when the feet touch the floor) [46].
The coordinates of the positions of the examined person's knees can be estimated from depth images using a general-purpose algorithm for locating anatomical landmarks. Such algorithms are implemented in the Microsoft Kinect devices. Similar algorithms, applicable to other devices comprising depth sensors, are available commercially. Alternatively, these coordinates can be estimated using a dedicated algorithm for locating knees. Such an algorithm may involve extracting human silhouettes from depth images and identifying the parts of these silhouettes which correspond to the knees. That identification can be based on the observation that the knees are located at about 0.26 body height [46].
The estimation of spatiotemporal gait parameters using the KD method involves the following sequence of operations: 1.
computation of the anteroposterior distance between the knees according to the following formula: The positive values of the elements of the sequence d 1 , . . . , d N correspond to the time intervals when the right knee is ahead of the left one. Its negative values, on the other hand, correspond to the time intervals when the left knee is ahead of the right one.
The left step time is defined as the average time which elapses from a right FC moment to the next left FC moment [47]. It can be estimated as the average time from a local minimum of the sequence d 1 , . . . , d N to its subsequent local maximum. The right step time-defined analogously for the right foot-can be estimated as the average time from a local maximum of that sequence to its subsequent local minimum. Stride time is the average time which elapses between two consecutive FC moments of the same foot [47]. It can be estimated as the average time between successive local minima of that sequence or as the average time between its successive local maxima. One of these options should be chosen so as to use as much of the available data as possible. For example, in the case illustrated in Figure 3, the time between the local maxima should be considered because that particular dataset represents two full strides which start with right FC moments and only one full stride which starts with a left FC moment. The positive values of the elements of the sequence d1,…, dN correspond to the intervals when the right knee is ahead of the left one. Its negative values, on the o hand, correspond to the time intervals when the left knee is ahead of the right one.
The left step time is defined as the average time which elapses from a right FC ment to the next left FC moment [47]. It can be estimated as the average time from a minimum of the sequence d1,…, dN to its subsequent local maximum. The right step tim defined analogously for the right foot-can be estimated as the average time from a maximum of that sequence to its subsequent local minimum. Stride time is the ave time which elapses between two consecutive FC moments of the same foot [47]. It ca estimated as the average time between successive local minima of that sequence or a average time between its successive local maxima. One of these options should be ch so as to use as much of the available data as possible. For example, in the case illustr in Figure 3, the time between the local maxima should be considered because that pa ular dataset represents two full strides which start with right FC moments and only full stride which starts with a left FC moment. The positions of the feet, estimated at the FC moments detected according to the above-described procedure, can be used to estimate the left and right stride length, step length, stride width and step width according to standard definitions [47].

CH Method
The data-processing method, called the CH method (referring to the acronym of "centre height") is based on the observation that during gait, the local minima of the height of the centre of mass approximately coincide with the FC moments [48]. On the other hand, its local maxima approximately coincide with the mid-swing (MS) moments, i.e., the moments when the anteroposterior positions of both feet are equal. Furthermore, at the MS moments, the centre of mass is also approximately aligned with the feet along the anteroposterior axis. As in the case of the KD method, the coordinates of the position of the examined person's centre of mass can be obtained using a general-purpose algorithm for processing depth images or a dedicated one. The latter may involve the extraction of the examined person's silhouettes from depth images and the identification of the centre of each silhouette [49].
The estimation of spatiotemporal gait parameters using the CH method involves the following sequence of operations: The estimation of spatiotemporal gait parameters using the CH method involves following sequence of operations: 1 smoothing of the sequences of coordinates of the height of the examined person's tre of mass, e.g., using a Savitzky-Golay filter ( Figure 4a); 2 identification of the local minima and maxima of that height ( Figure 4b); 3 estimation of the mean step and stride time based on the detected FC moments; 4 estimation of the mean step and stride length based on the detected MS moments  In addition to the oscillations expected, the exemplary estimates of the height of examined person's centre of mass, shown in Figure 4, seem to follow a decreasing tre it is a consequence of the imperfect identification of the vertical axis at the preprocess stage (cf. Section 2.1.1).
The analysis of the vertical oscillations of the centre of mass does not allow for tinguishing left FC moments from right ones. The mean step time, irrespective of the s can be estimated as the average time between consecutive local minima of the heigh the centre of mass. The stride time can be estimated as the average time between ev second local minimum of the height of the centre of mass. The mean step length, irresp tive of the side, can be estimated as the average distance between the positions of In addition to the oscillations expected, the exemplary estimates of the height of the examined person's centre of mass, shown in Figure 4, seem to follow a decreasing trend; it is a consequence of the imperfect identification of the vertical axis at the preprocessing stage (cf. Section 2.1.1).
The analysis of the vertical oscillations of the centre of mass does not allow for distinguishing left FC moments from right ones. The mean step time, irrespective of the side, can be estimated as the average time between consecutive local minima of the height of the centre of mass. The stride time can be estimated as the average time between every second local minimum of the height of the centre of mass. The mean step length, irrespective of the side, can be estimated as the average distance between the positions of the centre of mass along the antero-posterior axis at consecutive maxima of its height. The stride length can be estimated as the average distance between the positions of the centre of mass along the antero-posterior axis at every second maximum of its height.

FV Method
The data processing method called the FV method (referring to the acronym of "foot velocity") is based on the observation that during walking, the horizontal speed of a foot is close to zero during the stance phase and larger during the swing phase. The coordinates of the positions of the examined person's feet can be estimated from depth images using a general-purpose algorithm locating anatomical landmarks. The estimation of spatiotemporal gait parameters using the FV method involves the following sequence of operations: 1.
smoothing of the coordinates of the positions of feet, e.g., using a Savitzky-Golay filter ( Figure 5a); 2.
estimation of the horizontal velocity of the feet by numerical differentiation of the sequences of position estimates; 3.
comparison of that velocity with an empirically selected threshold value; 4.
detection of the FC moments and the foot-off (FO) moments (i.e., the moments when a foot is lifted off the floor) by identifying the moments when velocity falls below or rises above-respectively-the aforementioned threshold value (Figure 5b); 1. smoothing of the coordinates of the positions of feet, e.g., using a Savitzky-G filter ( Figure 5a); 2 estimation of the horizontal velocity of the feet by numerical differentiation o sequences of position estimates; 3 comparison of that velocity with an empirically selected threshold value; 4 detection of the FC moments and the foot-off (FO) moments (i.e., the moments w a foot is lifted off the floor) by identifying the moments when velocity falls belo rises above-respectively-the aforementioned threshold value (Figure 5b); 5 estimation of selected spatiotemporal gait parameters based on the detected FC FO moments and the estimates of positions of feet.

Methodology of Experimentation
Two sets of data were collected in order to assess the uncertainty of the estimates of spatiotemporal gait parameters obtainable using the three data processing methods described in Section 2.1. The data were collected using a Microsoft Kinect v2 device. Among various types of devices comprising depth sensors, the Kinect v2 device seems to be the one most commonly considered in research studies related to health care applications of such sensors (cf. the review of literature in Section 1), although it has not been produced since 2017. The use of Kinect v2 is convenient because this device provides estimates of positions of anatomical landmarks without the need to purchase additional software packages. The reference data were collected using a 2-m long Zebris FDM platform. The spatiotemporal parameters were estimated for 5 subjects: 3 women and 2 men, aged 22-45, free from gait disturbances. Subjects #1-#3 wore typical trousers, Subject #4-wide-leg trousers, and Subject #5 wore a skirt. Some anthropometric information about the subjects is collected in Table 1. An exemplary silhouette of each subject is shown in Figure 6. It can be seen in Figure 6 that the localisation of knees, ankles and feet is hindered in the case of these particular silhouettes of Subjects #4 and #5 because of their clothing. scribed in Section 2.1. The data were collected using a Microsoft Kinect v2 device. Amo various types of devices comprising depth sensors, the Kinect v2 device seems to be t one most commonly considered in research studies related to health care applications such sensors (cf. the review of literature in Section 1), although it has not been produc since 2017. The use of Kinect v2 is convenient because this device provides estimates positions of anatomical landmarks without the need to purchase additional softwa packages. The reference data were collected using a 2-m long Zebris FDM platform. The spatiotemporal parameters were estimated for 5 subjects: 3 women and 2 me aged 22-45, free from gait disturbances. Subjects #1-#3 wore typical trousers, Subject #4 wide-leg trousers, and Subject #5 wore a skirt. Some anthropometric information abo the subjects is collected in Table 1. An exemplary silhouette of each subject is shown Figure 6. It can be seen in Figure 6 that the localisation of knees, ankles and feet is hinder in the case of these particular silhouettes of Subjects #4 and #5 because of their clothing  The time intervals, covering each of the subjects' passages across the Zebris FDM platform, have been identified by visually inspecting the sequences of depth images. The subsequences of depth images corresponding to those time intervals have been extracted from the data set. Those subsequences have been processed offline using software developed by the authors. The implementation of the Savitzky-Golay filter available in the MATLAB function smooth has been used for smoothing the estimates of positions of the knees, feet and centre of mass [50]. In the conducted experiments, the MATLAB function smooth has yielded better results than the function sgolay and another implementation of the Savitzky-Golay filter, developed by the authors of this paper. For this reason, in the case of the FD method, the sequences of foot position estimates have been first smoothed and then differentiated using the central-difference method rather than using a differentiating Savitzky-Golay filter. The MATLAB functions islocalmin and islocalmax have been used for the detection of local extrema [51,52]. All tunable parameters of the data-processing algorithms have been optimised empirically.
According to the examination procedure associated with the Zebris FDM platform, the subjects' passages across the tensometric platform have been grouped into triplets. In each experiment, each subject made three such triplets of passages. Within each triplet of passages, the estimates of spatiotemporal gait parameters have been averaged. The estimates of those parameters, obtained using the Zebris FDM platform, have been used as reference values. For each spatiotemporal gait parameter under analysis, the following indicators of uncertainty have been computed:  The time intervals, covering each of the subjects' passages across the Zebris F platform, have been identified by visually inspecting the sequences of depth images subsequences of depth images corresponding to those time intervals have been extra from the data set. Those subsequences have been processed offline using software d oped by the authors. The implementation of the Savitzky-Golay filter available in MATLAB function smooth has been used for smoothing the estimates of positions o knees, feet and centre of mass [50]. In the conducted experiments, the MATLAB fun smooth has yielded better results than the function sgolay and another implementati the Savitzky-Golay filter, developed by the authors of this paper. For this reason, in case of the FD method, the sequences of foot position estimates have been first smoo and then differentiated using the central-difference method rather than usin • the mean error ME, defined in the following way: • the standard deviation of errors SDE, defined in the following way: • the mean absolute value of the relative errors MARE, defined in the following way: where: • p denotes a given spatiotemporal gait parameter under analysis-such as the step length or time;

Results
This section is devoted to the assessment of the accuracy of the estimates of the step time and length, based on the results of the experiments described in Section 2.2. Complete results of these experiments, including the indicators of accuracy of other gait parameters, are presented in Appendix A. Figure 8 shows a comparison of the results obtained using the studied data processing methods. It presents the values of the indicators ME, SDE and the minimum and maximum errors of the estimates of the step time and length. The results are collected into two sets: The dispersion of the reference values, obtained using the Zebris FDM platform, is also shown in Figure 8. This dispersion was quantified by comparing each reference value to the average reference value of the given parameter obtained for the given subject, and computing the standard deviation of the differences, the maximum difference, and the minimum difference. This dispersion is caused not only by the measurement uncertainty of the Zebris FDM platform, but also by the fact that gait was not perfectly consistent in repeated passages. Such dispersion can also be expected to appear in practical applications related to the analysis of natural overground gait.  The dispersion of the reference values, obtained using the Zebris FDM platform, is also shown in Figure 8. This dispersion was quantified by comparing each reference value to the average reference value of the given parameter obtained for the given subject, and computing the standard deviation of the differences, the maximum difference, and the minimum difference. This dispersion is caused not only by the measurement uncertainty of the Zebris FDM platform, but also by the fact that gait was not perfectly consistent in repeated passages. Such dispersion can also be expected to appear in practical applications related to the analysis of natural overground gait.
It can be seen in Figure 8 that for Subjects #1-#3 and ϕ = 180 • , the dispersion of the errors of the estimates of the step time and length is similar to the dispersion of the reference values (Figure 8a,c). It is significantly larger for the KD and FV methods when different values of ϕ and subjects with different clothes are considered (Figure 8b,d). For the CH method, it is somewhat larger in those cases, but the difference is smaller than for the other methods. The step length tends to be underestimated (cf., the horizontal lines in Figure 8c,d), but, on the whole, the mean errors of the estimates of the step time and length are small if compared to their standard deviations.  It can be seen in Figure 9 that for subjects wearing typical trousers the accuracy o estimates of the step time and length is similar, regardless of whether the depth sen line of sight is parallel or diagonal to the walking direction (φ = 180° or 135°). On the hand, the step time estimates are significantly less accurate when the depth sensor's of sight is perpendicular to the walking direction (φ = 90°). The step length estimate tained using the KD method are also much less accurate for φ = 90°. Those obtained u the CH and FV methods are only slightly less accurate in that case. Figure 10 shows a comparison of the results obtained for different subjects. It pre It can be seen in Figure 9 that for subjects wearing typical trousers the accuracy of the estimates of the step time and length is similar, regardless of whether the depth sensor's line of sight is parallel or diagonal to the walking direction (ϕ = 180 • or 135 • ). On the other hand, the step time estimates are significantly less accurate when the depth sensor's line of sight is perpendicular to the walking direction (ϕ = 90 • ). The step length estimates obtained using the KD method are also much less accurate for ϕ = 90 • . Those obtained using the CH and FV methods are only slightly less accurate in that case. Figure 10 shows

Discussion
Among the three studied data-processing methods, the FV method allows fo most detailed characterisation of the gait. It enables the determination of the initial-co moments and the toe-off moments, thus making possible the estimation of the dura of the phases of the gait cycle. The CH method, on the other hand, provides the lea formation: the left and right steps cannot be distinguished based on the vertical os tions of the examined person's centre of mass. It seems that the informativity of th method could be increased by supplementing it with the analysis of the lateral (i.e. right) position, velocity or acceleration of the centre of mass, but this possibility ha been considered in the study reported herein. The KD method provides more inform than the CH method, but less than the FV method.
The results of the conducted experiments indicate that in the case of subjects we typical trousers and walking towards the depth sensor (i.e., Subjects #1-#3, φ = 180 three studied data-processing methods yield quite satisfactory results: the bias of the mates of spatiotemporal gait parameters is small, and their dispersion is similar to th the reference values obtained using the Zebris FDM platform (Figure 8a,c). In these ditions, the accuracy of all three methods is similar, with the CH method yielding re slightly less dispersed than the KD and FV methods. Thus, all three studied methods to be applicable in gait analysis systems designed to operate in settings in which the jects' clothing and walking direction can be controlled to some extent, e.g., in such sys aimed at supporting diagnostic procedures performed at health care facilities. Thes servations conform with some previously published ones [18,53,54]. The dispersion o estimates of spatiotemporal gait parameters is partially caused by the imperfection o data and methods for their processing, and partially-by the natural variability of th man gait. That variability is also reflected by the non-zero dispersion of the referenc ues.
In the case of subjects wearing different types of clothing and walking in diff directions (i.e., Subjects #1-#5; φ = 90°, 135°, 180°), the errors corrupting the estima It can be seen in Figure 10 that the accuracy of the estimates of the step time and length, obtained using the KD method, is quite similar for subjects wearing typical trousers (#1-#3) and the subject wearing wide-leg trousers (#4), but it is significantly worse for the subject wearing a skirt (#5). The estimates obtained using the CH method have similar accuracy for all subjects. Those obtained using the FV method are significantly less accurate for Subject #4 and even less accurate for Subject #5.

Discussion
Among the three studied data-processing methods, the FV method allows for the most detailed characterisation of the gait. It enables the determination of the initialcontact moments and the toe-off moments, thus making possible the estimation of the durations of the phases of the gait cycle. The CH method, on the other hand, provides the least information: the left and right steps cannot be distinguished based on the vertical oscillations of the examined person's centre of mass. It seems that the informativity of the CH method could be increased by supplementing it with the analysis of the lateral (i.e., left-right) position, velocity or acceleration of the centre of mass, but this possibility has not been considered in the study reported herein. The KD method provides more information than the CH method, but less than the FV method.
The results of the conducted experiments indicate that in the case of subjects wearing typical trousers and walking towards the depth sensor (i.e., Subjects #1-#3, ϕ = 180 • ), all three studied data-processing methods yield quite satisfactory results: the bias of the estimates of spatiotemporal gait parameters is small, and their dispersion is similar to that of the reference values obtained using the Zebris FDM platform (Figure 8a,c). In these conditions, the accuracy of all three methods is similar, with the CH method yielding results slightly less dispersed than the KD and FV methods. Thus, all three studied methods seem to be applicable in gait analysis systems designed to operate in settings in which the subjects' clothing and walking direction can be controlled to some extent, e.g., in such systems aimed at supporting diagnostic procedures performed at health care facilities. These observations conform with some previously published ones [18,53,54]. The dispersion of the estimates of spatiotemporal gait parameters is partially caused by the imperfection of the data and methods for their processing, and partially-by the natural variability of the human gait. That variability is also reflected by the non-zero dispersion of the reference values.
In the case of subjects wearing different types of clothing and walking in different directions (i.e., Subjects #1-#5; ϕ = 90 • , 135 • , 180 • ), the errors corrupting the estimates of spatiotemporal gait parameters, obtained using the KD method and the FV method, are significantly larger (Figure 8b,d). The estimates obtained using the CH method, on the other hand, are corrupted with errors of similar magnitude as in the previous case. The latter method seems, therefore, to have a better applicability potential in systems for in-home monitoring. The accuracy of its results in the various tested conditions is comparable to that of the reference Zebris FDM platform. It only allows, however, for estimating the step time, stride time, step length and stride length-without distinguishing the left and right sides of the body. Further research seems necessary to develop a data-processing method as robust as the CH method, but capable of providing more detailed results of gait analysis. The depth sensor's viewing angle has a non-negligible influence on the results of gait analysis, obtainable using the studied data-processing methods. This influence is most pronounced in the case of the KD method ( Figure 9): the relative errors of the estimates of spatiotemporal gait parameters are somewhat larger when the subject is observed at the diagonal angle (i.e., ϕ = 135 • ) and very large when he or she is observed from the side (i.e., ϕ = 90 • ). These large errors are probably caused by the fact that the antero-posterior position of the knees is easier to estimate when the front of the subject's silhouette is visible in the depth images. When the subject is observed from the side, one of his or her knees is occluded from time to time. Perhaps, better results could be obtained for ϕ = 90 • if the position of the knees were estimated using a dedicated algorithm for processing depth images, instead of a general-purpose algorithm for localisation of anatomical landmarks, but this possibility was not considered in the study reported herein. The originators of this data-processing method considered placing the depth sensor behind a treadmill (i.e., ϕ = 0 • ) [33].
In the case of the CH method, the estimates of the step time are significantly less accurate for ϕ = 90 • than for other viewing angles ( Figure 9). This observation indicates that local minima of the height of the centre of mass are more difficult to accurately detect when the subject is observed from the side. On the other hand, the estimates of step length, obtained using the CH method, are comparably accurate for all considered values of ϕ.
In the case of the FV method, the estimates of both the step time and the step length are the most accurate for ϕ = 135 • and the least accurate for ϕ = 90 • . In the latter case, the errors are large probably because of one of the subject's feet periodically occluding the other one.
The results of the conducted experiments show that the subject's clothing may also affect the results of gait analysis ( Figure 10). In the case of the KD method, significantly worse results were obtained for Subject #5-the one who wore a skirt-than for other subjects. These results indicate that the localisation of knees based on depth sensor data is hindered when the subject is wearing a skirt, but this is not the case for wide-leg trousers: the results obtained for Subject #4 (who wore such wide-leg trousers) are similar to those obtained for Subject #2 (who wore typical trousers). The results obtained using the CH method are quite similar for all the subjects, which indicates that this method is insensitive to the subject's clothing. The FV method, on the other hand, is the most sensitive to the subject's clothing: its results are significantly worse for Subject #4 (who wore wide-leg trousers) than for Subjects #1-#3, and even worse for Subject #5 (who wore a skirt).
The experimental results described above indicate that, in certain conditions, reliable results of spatiotemporal gait analysis can be obtained using the Kinect v2 depth sensor.
The CH method can be recommended for the analysis of gait of persons wearing different types of clothing, but if detailed characterisation of gait is sought, then further research is required to develop a data-processing method which would combine the robustness of the CH method and the informativeness of the FV method. None of the studied data-processing methods is capable of providing accurate estimates of spatiotemporal gait parameters of subjects observed from the side (ϕ = 90 • ), so further research is needed to develop a method useful in that setting. The implementation of a dedicated algorithm for processing raw depth images, instead of using a general-purpose algorithm for localisation of anatomical landmarks, seems a good starting point for such research.
The experiments reported herein were subject to certain limitations. Five subjects took part in these experiments for ϕ = 180 • and ϕ = 135 • , and only two subjects-for ϕ = 90 • . Furthermore, all the subjects were persons of working age, free from gait disorders. The presented experimental findings need, therefore, to be validated using more data in order to corroborate the usefulness of the studied methods for the analysis of gait of elderly people and people suffering from gait disorders.
The development of more sophisticated data processing methods-in particular, methods based on a fusion of information obtained using the three methods studied in this paper-may allow for obtaining more accurate and robust estimates of various useful spatiotemporal gait parameters independently of the subject's clothing and walking direction. The development of reliable gait analysis systems based on depth sensors-in particular, those dedicated to in-home monitoring settings-seems desirable because such systems have certain advantages over the currently available gait analysis systems based on other technological solutions. The optoelectronic motion-capture systems are much more expensive than depth sensors and they need to be installed in quite large rooms, which makes their application for in-home monitoring impractical. Platforms and treadmills equipped with force sensors, relatively common in clinical facilities and laboratories, are also more expensive and less convenient for in-home use than depth sensors, and they cannot serve for estimating the angles in the ankle, knee and hip joints-which is reportedly feasible using depth sensors [55]. Gait analysis systems based on wearable sensors are proliferating [17], but the need to wear a device on the body or clothes may be considered cumbersome by the potential users of such systems [56]. Furthermore, a system for in-home monitoring of the elderly, based on a wearable device, may become useless if its user forgets to recharge or wear the device or decides not to use it.

Conclusions
The findings of this study can be summarised as follows:

•
The results of gait analysis based on data from a Kinect v2 device can be comparable in accuracy to those based on data from a Zebris FDM platform if the subject is wearing typical trousers and walking toward that device. In such a case, the FV method allows for the most detailed characterisation of human gait.

•
The angle between the walking direction and the depth sensor's line of sight significantly affects the accuracy of the estimates of the spatiotemporal gait parameters, obtained using all three studied data-processing methods.

•
The subject's clothing significantly affects the accuracy of the gait analysis results obtained using the FV method and the KD method, but not the CH method.

•
The practical advantages and disadvantages of the studied data processing methods, identified based on experimental results described above, may serve as a basis for further research aimed at developing more versatile methods for spatiotemporal gait analysis, dedicated to in-home monitoring systems.
The authors' plans for future research include: • the development and testing of other methods for processing data from depth sensors, aimed at obtaining more accurate and robust estimates of spatiotemporal gait parameters; • conducting more experiments aimed at testing the usefulness of gait analysis systems based on depth sensors in clinical practice and in systems for in-home monitoring of the elderly. Informed Consent Statement: Informed consent was obtained from all subjects involved in the study.

Data Availability Statement:
The data presented in this study are available on request from the corresponding author.
Acknowledgments: This work has been supported by the Institute of Radioelectronics and Multimedia Technology at the Faculty of Electronics and Information Technology, Warsaw University of Technology.

Conflicts of Interest:
The authors declare no conflict of interest.

Appendix A
This Appendix contains all the obtained experimental results. The reference values obtained using the Zebris FDM platform are shown in Table A1. The values of the indicators of accuracy, defined in Section 2.2, obtained for the 3 studied data-processing methods described in Section 2.1, are shown in Tables A2-A4. These values have been grouped according to: • the data processing method: KD (Table A2), CH (Table A3) and FV (Table A4); • the angle ϕ between the depth sensor's line of sight and the walking direction; • the subjects whose gait was analysed: Subjects #1-#3, who wore typical trousers, and, separately, Subjects #4 and #5, who wore wide-leg trousers and a skirt, respectively.