Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine the amplitude and the frequency of an "oscillating" trajectory

This is the trajectory of a pedestrian moving in jam enter image description here

As you can see, his/her head perform an oscillation-like movement. So not a perfect sinus curve but neither a line.

Is it possible to define for this irregular curve an "amplitude" and a "frequency"?

UPDATE:

So far I tried two different approaches:

  1. The first one is based on calculating the turning points and then make a spline with them.
  2. The second approach is based on the suggestion of unutbu and uses the Ramer-Douglas-Peucker algorithm.

The results are as follows:

enter image description here

The problem that I see with the RDP is the free parameter dist. low values (means more details) imply oscillations in the resulting trajectories. So I'm forced to be careful with this parameter. Besides, the splined curve is much more smoother.

What do you think?

like image 954
Tengis Avatar asked Nov 28 '25 22:11

Tengis


1 Answers

There is no absolute correct way to do this. Below is just one way.

Let's start with the assumption/claim that people generally intend to walk in straight lines. So you could use the Ramer-Douglas-Peucker algorithm to estimate the intended path of the person with a small set of line segments. (There is a Python implementation of the algorithm here.)

Then generate the distances of the true data points from the line segments.

timeseries = []
for point in  points: 
    timeseries.append(
        min((distance between point and segment) 
             for segment in segments))

This array of distances is a timeseries. You could then take the root-mean-squared of the timeseries as a measure of amplitude, and take a Fourier transform to find its dominant frequency (or frequencies).

like image 115
unutbu Avatar answered Dec 01 '25 11:12

unutbu