I have some data in python which represents the motion of detected SURF keypoints across multiple frames of a video. I need to separate the points which are oscillating from the points experiencing other kinds of motion. I am thinking that I should be able to do this by fitting a sine function to the data and then thresholding the parameters to discard motion outside the parameters of what I'm looking for.
So I defined the generic sine function and call scipy.optimize.curve_fit
def sine(x,a,b,c,d):
return a * np.sin(b*(x+c)) + d
opt, cov = opt.curve_fit(sine, np.linspace(0,119,119), x[:,5])
(x[:,5]
is a data element I know to have fairly clean and obvious sine characteristics)
But when I plot sine(sine(np.linspace(0,119,119), *opt)
against x[:,5]
in matplotlib I end up with a curve that doesn't look anything like my data except perhaps the y-axis bias
Am I missing something, or is this simply outside of what can be done?