本文整理汇总了C++中Finger::isExtended方法的典型用法代码示例。如果您正苦于以下问题:C++ Finger::isExtended方法的具体用法?C++ Finger::isExtended怎么用?C++ Finger::isExtended使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Finger
的用法示例。
在下文中一共展示了Finger::isExtended方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onFrame
void MangoListener::onFrame(const Controller& controller) {
const Frame frame = controller.frame();
HandList hands = frame.hands();
int extendedFingers = 0;
for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
const Hand hand = *hl;
for (int i = 0; i < hand.fingers().count(); i++)
{
Finger finger = hand.fingers()[i];
if(finger.isExtended()) extendedFingers++;
}
if (!onGesture && !frame.hands().isEmpty() && frame.hands().count() == 1 && extendedFingers == 0)
{
preGestureCounter++;
std::cout << preGestureCounter << std::endl;
if (preGestureCounter > MAX_PREGESTURE && frameCount == 0)
{
onGesture = true;
preGestureCounter = 0;
frameCount++;
note.show();
}
}
else if (preGestureCounter > 0)
{
preGestureCounter--;
}
}
if (onGesture && frameCount < MAX_FRAMECOUNT) {
switch (extendedFingers)
{
case 1:
{
std::string command = commands.getCommand("FING3");
std::cout << command << std::endl;
break;
}
case 2:
{
break;
}
case 3:
{
break;
}
default:
{
break;
}
}
frameCount++;
const GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g]; //need to move finger detection in here too
switch (gesture.type()) {
case Gesture::TYPE_CIRCLE:
{
CircleGesture circle = gesture;
std::string clockwiseness; //probably simplfy to a bool
if (circle.pointable().direction().angleTo(circle.normal()) <= PI/4)
{
clockwiseness = "clockwise";
std::cout << "CIRCLE CLOCKWISE" << std::endl;
}
else
{
clockwiseness = "counterclockwise";
std::cout << "CIRCLE COUNTERCLOCKWISE" << std::endl;
}
break;
}
case Gesture::TYPE_SWIPE:
{
SwipeGesture swipe = gesture;
std::cout << "SWIPE" << std::endl;
break;
}
case Gesture::TYPE_KEY_TAP:
{
KeyTapGesture tap = gesture;
std::cout << "KEY TAP" << std::endl;
break;
}
case Gesture::TYPE_SCREEN_TAP:
{
ScreenTapGesture screentap = gesture;
std::cout << "SCREEN TAP" << std::endl;
break;
}
default:
{
std::cout << std::string(2, ' ') << "Unknown gesture type." << std::endl;
break;
}
}
float seconds = gesture.durationSeconds();
//.........这里部分代码省略.........
示例2: ParangusGestureLogic
void QTVS_Leap::ParangusGestureLogic()
{
if (ui.checkBox_PalmForSwipes->isChecked())
{
Leap::Vector palmPosition = controller.frame(3).hands()[0].palmPosition();
float previousPalmYPosAndDifference = palmPosition.y;
float previousPalmXPosAndDifference = palmPosition.x;
previousPalmYPosAndDifference = hand.palmPosition().y - previousPalmYPosAndDifference;
previousPalmXPosAndDifference = hand.palmPosition().x - previousPalmXPosAndDifference;
// std::cout << previousFingerXPosAndDifference << "\n";
if (previousPalmYPosAndDifference < -2.5 && handCache.bGestureToggle)
{
std::cout << "down \n";
handCache.bGestureToggle = false;
QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, NULL, swipe_Down);
}
if (previousPalmYPosAndDifference > 2.5 && handCache.bGestureToggle)
{
std::cout << "swipe_Up \n";
handCache.bGestureToggle = false;
QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, NULL, swipe_Up);
}
if (previousPalmXPosAndDifference < -2.5 && handCache.bGestureToggle)
{
std::cout << "swipe_Left \n";
handCache.bGestureToggle = false;
QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, NULL, swipe_Left);
}
if (previousPalmXPosAndDifference > 2.5 && handCache.bGestureToggle)
{
std::cout << "swipe_Right \n";
handCache.bGestureToggle = false;
QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, NULL, swipe_Right);
}
if (!handCache.bGestureToggle &&
abs(previousPalmYPosAndDifference) <= 0.5 &&
abs(previousPalmXPosAndDifference) <= 0.5 )
handCache.bGestureToggle = true;
return;
}
// if palm for swipes isn't checked, we go for fingers instead:
for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl)
{
const Finger finger = *fl;
//To simplify things down the road
int leapFingerIndex = finger.type();
if (finger.isExtended())
{
Leap::Vector fingerPosition = controller.frame(3).fingers()[leapFingerIndex].stabilizedTipPosition();
float previousFingerYPosAndDifference = fingerPosition.y;
float previousFingerXPosAndDifference = fingerPosition.x;
previousFingerYPosAndDifference = finger.stabilizedTipPosition().y - previousFingerYPosAndDifference;
previousFingerXPosAndDifference = finger.stabilizedTipPosition().x - previousFingerXPosAndDifference;
// std::cout << previousFingerXPosAndDifference << "\n";
if (previousFingerYPosAndDifference < -10 && handCache.fingers_p[leapFingerIndex].bGestureToggle)
{
handCache.fingers_p[leapFingerIndex].bGestureToggle = false;
QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, leapFingerIndex, swipe_Down);
}
if (previousFingerYPosAndDifference > 10 && handCache.fingers_p[leapFingerIndex].bGestureToggle)
{
handCache.fingers_p[leapFingerIndex].bGestureToggle = false;
QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, leapFingerIndex, swipe_Up);
}
if (previousFingerXPosAndDifference < -10 && handCache.fingers_p[leapFingerIndex].bGestureToggle)
{
handCache.fingers_p[leapFingerIndex].bGestureToggle = false;
QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, leapFingerIndex, swipe_Left);
}
if (previousFingerXPosAndDifference > 10 && handCache.fingers_p[leapFingerIndex].bGestureToggle)
{
handCache.fingers_p[leapFingerIndex].bGestureToggle = false;
QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, leapFingerIndex, swipe_Right);
}
if (!handCache.fingers_p[leapFingerIndex].bGestureToggle &&
abs(previousFingerYPosAndDifference) <= 0.1 &&
abs(previousFingerXPosAndDifference) <= 0.1 )
handCache.fingers_p[leapFingerIndex].bGestureToggle = true;
//.........这里部分代码省略.........