Reading this and having tried np.correlate and cv2.matchTemplate I still have a question that I don't seem to be able to solve.
I've got two numpy arrays each with the shape (6000,50)
. 6000 sequences with each 50 values. Now I would like to do a cross-correlation of two 1-dimensional sequences of this array to detect the timeshift. I tried openCV briefly, but for me this returns a single number (I expect the highest correlation), so now I use numpy.correlate like this:
np.correlate(x[2500], y[2500], mode='same')
(In the cross-correlation plot I'm not looking for the highest peak, but I'm looking for the first peak using this. See plot for an example)
As you might expect, I would like to do this for all 6000 sequences, but hoping to avoid iteration. I was hoping this would work:
np.correlate(x, y, mode='same')
But this gives me the following error: ValueError: object too deep for desired array
.
Is there any change that this is possible with NumPy or OpenCV. Or will i have to do it like this :(
for i in range(x.shape[0]):
np.correlate(x[i], y[i], mode='same')