Saturday, September 27, 2008

More Gesture Recognition

Okay, so calling the gesture recognition function took five minutes...learning, recording and creating the gestures took a lot longer.

to not bamboozle you, once again look at the mouse direction diagram on this page here.

Essentially, as each direction is assigned a number, you can use this to see what beat pattern the user is trying to make...

for a simple 2/4 beat, the user has to move the stick down then up...so the gesture code is 26.

to call this in action script 3 it was simply...

mg.addGesture("2beat","26");

great, well that's great if you want to limit the user to going only directly up and down... so i added some curves and flicks...

essentially the final 2/4 beat gestures looked like this...

mg.addGesture("2beat","26");
mg.addGesture("2beat","206");
mg.addGesture("2beat","2106");
mg.addGesture("2beat","21076");

that allowed for the user to make a u-shape in the air, add flicks to the movement, and it would still register as a 2/4 beat gesture.

now, 4 entries looks nice... by the time i got to the 6/4 gestures I was going insane trying to think of extra flicks and movements someone might make...

mg.addGesture("6beat","246246246205");
mg.addGesture("6beat","2462462462405");
mg.addGesture("6beat","24624624624605");
mg.addGesture("6beat","24624624624675");
mg.addGesture("6beat","24535353475"); mg.addGesture("6beat","245353543475");
mg.addGesture("6beat","2546346346065");
mg.addGesture("6beat","2546346346205");
mg.addGesture("6beat","2546346346305");
mg.addGesture("6beat","253463463405");
mg.addGesture("6beat","253453462405");
mg.addGesture("6beat","253453453405");
mg.addGesture("6beat","263463463405");
mg.addGesture("6beat","26346346305");
mg.addGesture("6beat","253535305);");
mg.addGesture("6beat","25353505);");

It looks like a lot of work, and it did take a couple of hours of testing and recording to get to this point. But i wanted to give whoever uses this as much freedom as possible, as long as they stick to the basic beat patterns(which will be in the next post), they will be fine.

Next was to change the tempo of the music...
As i previously posted, i have the 6 tracks pre-recorded and ready to play.

Essentially, one sound channel is playing the tracks, but only one at a time, if the user conducts a 5/4 beat pattern, the faster track will play, then if they change to say a 3/4 pattern, the channel stops playing the faster track, plays the 3/4 speed track from the same point that the music was up to, only slower.

After getting the above working, i found a little problem, the gesture recognition was far far too sensitive. If someone had a tremor, or unsteady arm, they would not find it very easy to stick to the patterns. Luckily, within the mouse gesture class there was a pixel-level sensitivity setting which i turned way way down to reduce adverse effects...after a bit of testing it seems to be working well.

Obviously what I have made is not perfect, but I think it's working damn well considering gesture recognition is a tedious process.

my next step is to apply the above to the IR conducting stick

Cheers

No comments: