9
$\begingroup$

I have the need to detect two different gestures that occur when looking at accelerometer data. Here's a run down (as brief as I can make it):

Lets say an iPhone is being oscillated back and forth while remaining face-up. The user can either do one oscillation (once forward or backward, gesture one) or a continuous oscillation for any amount of time (gesture two).

Currently my code maintains a list of the device's accelerometer data (y-axis) from the last 50 frames . Each frame this data is put through an FFT algorithm (this one http://goo.gl/yi3mn), and then I try to interpret the frequency domain given. I have noticed a strong relationship between the speed of the oscillations, and the power of the mid to low range of the frequency space.

The problem is that I need to detect (in real-time as the movement animates something on screen) whether the just finished oscillation is a singular one, or one that continues into another oscillation in the opposite direction. Here I should point out that accelerometers work with pressure plates. When an oscillation stops the input data will show the opposite value from when the oscillation was being performed. This makes it difficult to see any obvious difference between a single forwards movement and a double forwards then backwards movement (at the end of the each first oscillation).

Can anyone suggest how I might make use of an FFT to decipher an accurate magnitude value (or something else useful) that I can use to tell the difference between the gestures described above?

I have recorded the data I am using to text files. It is the raw data (g-force values) along the y-axis of the accelerometer input.

http://pastebin.ca/2108123 shows data for 2 singular oscillations (I hold the device still at the start, end, and between the two oscillations).

enter image description here

NOTE: new raw data with 20 oscillations has been uploaded, but not yet plotted. http://pastebin.ca/2108387 shows data for 20 continuous oscillations (I hold the device still at the start and end).

enter image description here

$\endgroup$
  • $\begingroup$ Not having seen the data myself, my first impression is that this doesn't seem to be a good application for an FFT. Do you have some captured data that you could post, either in raw format or as a plot? $\endgroup$ – Jason R Jan 31 '12 at 12:44
  • $\begingroup$ Hi, thanks for the feedback. Would just a file showing each value chronologically be acceptable, with a ',' delimiter? I am getting approximately 60 values per second. I suspect that this might not be a good application also. Perhaps we can work through it with some of the data though. $\endgroup$ – rykardo Jan 31 '12 at 12:49
  • 2
    $\begingroup$ If you post the raw data, it's likely that someone could transform it into a plot and edit your post with it. $\endgroup$ – Jason R Jan 31 '12 at 12:50
  • $\begingroup$ Ok great. Will upload some shortly. $\endgroup$ – rykardo Jan 31 '12 at 12:50
  • $\begingroup$ That took way longer than I expected. I am running the project with Unity, which can only receive the input data from the device at 60 frames / second. This means I cannot have a high sample rate, but nevertheless. Is this what you meant with your suggestion? $\endgroup$ – rykardo Jan 31 '12 at 13:30
2
$\begingroup$

Looking at the data I can't see why you'd want to use FFT for this purpose (I may be wrong though). Lets say you want to detect single or multiple movements based on this data set (which you've attached) the methods I'd be looking at would be

  1. Something on the lines of rate of change of absolute values. First derivative would do nicely I guess.
  2. Wavelet transform maybe? I can't elaborate more on its utility until I know whether you want to know the the position of the peaks or not.

If the only thing you want to detect is single vs multiple oscillation then FFT is, in my opinion, not a very good choice for analysis.

$\endgroup$
  • $\begingroup$ Thanks for the feedback! A friend suggested FFT might be the way to go, before that I had never used one before. What I need to detect is if a new oscillation is starting at the end of each oscillation, or not. The plots above should expose why it is difficult. I thought I could use a magnitude algorithm, but this is tricky because the power/speed of the oscillations will be different per user. $\endgroup$ – rykardo Feb 2 '12 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.