Gestures with the WP7 Accelerometer

22 11 2010

First and foremost, if you want in depth information about the accelerometer you should check out Dave Edson’s excellent blog post, Using the Accelerometer on Windows Phone 7.  While his post is extremely informative, it was a bit of overkill for what I needed.  I assume this may be true for a lot of you as well.

I just needed to recognize a simple gesture I wanted to see what it “looked” like to the accelerometer.  I didn’t smooth out the curve or use the AccelerometerHelper class.  Here are the steps I followed to determine that the raw data appeared to be sufficient for my needs:

  1. Start the accelerometer and record the data
  2. Perform the gesture
  3. Stop the accelerometer
  4. Use Excel to analyze the data
  5. Write the gesture detection code
  6. Test, Test, Test

I wrote a quick and dirty program (included below) to capture the data and send me an email.  The email is plain text that I save into notepad then import into Excel as a delimited text file.

These are the x-axis readings for one trial for me flicking the phone with my right hand:

image

There are two key points on this chart: When the x value hits about 1.3G, and when it hits about –2G.  My gesture detection code looks for these values, in this order, in a small time frame (about 1 second).

Tips

  • Perform several trials before you start coding your gesture recognition.  If possible, use different people.  What worked 10 out of 10 times for me worked 3 out of 10 times for someone else.
  • Left and Right handed gestures can be drastically different.
  • Be cognizant of how long the gesture should take and code your recognition accordingly.
  • Relax your gesture parameters as much as possible, but be wary of false positives.  In order to prevent stacking gestures, I put in a pause of about 250 ms between gestures.
  • Give some sort of feedback when they successfully perform a gesture.  A vibration lasting about 200 ms seemed to work well for my scenario.

Download Accelerometer Test Solution Here

Advertisements

Actions

Information

5 responses

17 12 2010
Daniel

great post, thanks for sharing

28 12 2011
rohan

Thanks for the post. I am trying to learn how to recognize basic gestures using accelerometer. Can you point me to any posts/links that will help me with “Write the gesture detection code” I see the pattern in graphs and data, but what is the most efficient way to recognize it.

the answer can be as simple as “try harder and you will get it ” 🙂 but if its a solved problem, I would like some pointers !

Thanks
Rohan

30 12 2011
rohan

Actually, figured it out. 🙂

I thought of going down the ‘curve fitting’ route but then realized simple approximations were good enough.

Happy Holidays..

26 05 2012
here

If you dont mind, exactly where do you host your weblog? I am looking for a very good host and your weblog appears to be extremely fast and up just about all the time

26 05 2012
Rich

This is hosted on WordPress.com.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: