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:
- Start the accelerometer and record the data
- Perform the gesture
- Stop the accelerometer
- Use Excel to analyze the data
- Write the gesture detection code
- 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:
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.
great post, thanks for sharing
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
Actually, figured it out. 🙂
I thought of going down the ‘curve fitting’ route but then realized simple approximations were good enough.
Happy Holidays..
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
This is hosted on WordPress.com.