|
GECKO 1.0
Human-computer interface based on hand gesture recognition
|
Guesses the hand gesture using the hand characteristic data previouly found. {
const float closed_hand_threshold = 2; //-- Ratio between the outer circle and the inner circle
if ( _hand_found)
{
//-- Open palm
if (_hand_num_fingers == 5 || _hand_num_fingers == 4 )
{
_hand_gesture = GECKO_GESTURE_OPEN_PALM;
}
//-- 2-finger signs
else if ( _hand_num_fingers == 2 )
{
//-- Find angle between fingers:
float angle_between_fingers = findAngle( _hand_fingertips[0], _hand_fingertips[1], _max_circle_incribed_center);
//-- Victory sign
if ( angle_between_fingers < 60 )
_hand_gesture = GECKO_GESTURE_VICTORY;
//- Gun sign
else if ( angle_between_fingers < 90 )
_hand_gesture = GECKO_GESTURE_GUN;
}
//-- Closed hand
else if (_hand_num_fingers == 0)
{
if ( _min_enclosing_circle_radius / _max_circle_inscribed_radius < closed_hand_threshold )
_hand_gesture = GECKO_GESTURE_CLOSED_FIST;
else
_hand_gesture = GECKO_GESTURE_NONE;
}
else
{
_hand_gesture = GECKO_GESTURE_NONE;
}
std::cout << "[Debug] Gesture: ";
switch ( _hand_gesture )
{
case GECKO_GESTURE_OPEN_PALM: std::cout << "Open Palm"; break;
case GECKO_GESTURE_VICTORY: std::cout << "Victory sign"; break;
case GECKO_GESTURE_GUN: std::cout << "Gun sign"; break;
case GECKO_GESTURE_CLOSED_FIST: std::cout << "Closed hand"; break;
default: std::cout << "No sign";
}
std::cout << std::endl;
}
}
|
1.7.4