Methodology to determine similarity between two signals

35 Views Asked by At

I'm working on the following problem:

I have an object detection model that detects bounding boxes of objects in a point cloud. I convert the point cloud to a bird-eye-view perspective, i.e. I create an image of the point cloud to be able to see a top-view of the point cloud. With the bounding boxes, I use a simple algorithm based on Kalman Filter to track the objects on consecutive LiDAR scans. So far, no problem.

The output of the tracking is the historical (x, y) coordinates, in pixels, of the tracked objects.

Now, what I wanted to do is to determine the type of path that the objects are performing. Example: straight trajectory, left-turn, right-turn or u-turn.

I will first address this trajectory estimation for vehicles (cars, trucks and etc) cause their behaviors are simple to handle.

I formulated this problem as follows:

  • $p_i$ is the historical path of a vehicle. Example $p = [(0.0, 1.0), (0.0, 2.0), (0.0, 3.0), ...]$, $p_i$ is a Nx2 vector.
  • $P_{linear}$ is a pre-defined linear path, the linear equation $y = x$. $P_{linear}$ is also a Nx2 vector.

Then, to verify if $p_{i}$ is similar, up to a degree, with my $P_{linear}$, I use the correlation between both signals.

I did the following tests:

  1. I correlated a linear curve with itself.
  2. I correlated a linear curve with an exponential curve.
  3. I correlated an exponential curve with itself.

The results are on the following graphs, respectively: experiments

In this approach, I saw two main useful points, that are:

  1. When a signal correlates with itself, produces a peak in the middle index of the output array.
  2. If we apply the correlation operator between two different signals, the peak produced is lagged or leading with respect to the middle index of the output array.

With these results I decided to keep pursuing this idea.

The other experiments that I did to validate if this is a valid algorithm to determine the type of trajectory performed by a vehicle, I tried to correlate the following signals:

x = np.linspace(0.0, 5.0, 200)
y1 = x
y2 = -x

This, produced the following result:

enter image description here

Now, the peak is negative, which makes sense. But, to overcome this, I can apply the absolute of the vector, in case the vehicle is going in a different direction, but still performing a straight path.

So, after this investigation, I see that I can use this simple algorithm to determine default patterns.

However, I was thinking if there's a simple way or a better way to tackle this problem.