Saturday, October 11, 2008

New gesture recognition......ITS A KEEPER

deep breath....


After a brainstorming session....a new gesture recognition idea was developed...with inbuilt volume and tempo control.

How you ask...it can't be done you say?....pffft...with some coffee, no social life and no sleep anything can be done...

Okies...so here how the new one works...

When the app detects the IR point, it begins to track it... and then the fun begins

While its tracking, a beat timer runs in the background...counting in seconds up to 8...and simultaneously, between each beat the distance covered is measured with a specific tolerance of pixels so that the recognition is not too sensitive.

next....the current and previous coordinates of the IR position is constantly being updated... therefore, I can test whether the user is conducting up or down or left or right.

Using this i did the following...

from the initial Ir point I ignored the x values and concentrated in the y...as soon as the IR point was less than the previous coordinate, I know that the direction has changed, so I trigger that as a beat.

next I had to determine which direction the user was conducting in now...
to check if it was left or right do this ignored the Y value and concentrated on the X value.
including the tolerance, I checked the current X value against the previous x value and could then tell the direction.

if the user conducts straight back upwards, the recorder goes back to ignoring the X value....

Next...essentially I mimicked the x checking for determining when the hit the 3rd and 4th beats.

Then, when the user releases the button and the IR is lost...the final beat is recorded and the whole thing resets.

here is a code snippet...

tracking...
public function track(e:TimerEvent):void{

newX = p1x;
newY = p1y;

if(i == 0){
prevX = newX;
prevY2 = prevY;
prevX2 = prevX
prevY = newY;
i = 1;
}
else if(i == 1){
prevX = newX;
prevY = newY;
i = 0;
}

}

and here is the bit that checks from beat 2 to what the next beat is...


public function leftorright():void{

beat2 = true;
if(p1x < prevX2 - tolerance){
directionfound = true;
//trace("Heading to beat 4");
goingleft = true;
beat1to2.stop();
beat2to4.start();
goingup = false;
goingdown = false;
squarecount = 0;
numofbeats +=1;
}

else if (p1x > prevX2 + tolerance){
directionfound = true;
//trace("Heading to beat 3");
beat1to2.stop();
beat2to3.start();
goingup = false;
goingdown = false;
numofbeats +=1;
}

else if(p1x > prevX2 - tolerance && p1x < prevX2 + tolerance && p1y < prevY2 - (3 * tolerance)){
directionfound = true;
//trace("Heads back to beat 1");
beat1to2.stop();
backto1.start();
numofbeats +=1;
}
// beat2to4.start();

}


A little bit hard to digest...however...essentially...

this allows the user to freely conduct and control tempo plus time signatures...

so is really good

:D

No comments: