本文整理汇总了C++中Finger::stabilizedTipPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Finger::stabilizedTipPosition方法的具体用法?C++ Finger::stabilizedTipPosition怎么用?C++ Finger::stabilizedTipPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Finger
的用法示例。
在下文中一共展示了Finger::stabilizedTipPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
Controller controller;
Frame frame;
HandList hands;
Hand h1;
FingerList fingers;
Finger index;
Finger thumb;
PointableList pointables;
float x = 0, y = 0, z = 0;
float pitch = 0, yaw = 0, roll = 0;
_sleep(1000);
while (1)
{
while (controller.isConnected() == true)
{
frame = controller.frame();
hands = frame.hands();
h1 = hands[0];
fingers = frame.fingers();
thumb = fingers[0];
index = fingers[1];
pointables = frame.pointables();
x = h1.palmPosition().x;
y = h1.palmPosition().y;
z = h1.palmPosition().z;
pitch = h1.direction().pitch()*RAD_TO_DEG;
yaw = h1.direction().yaw()*RAD_TO_DEG;
roll = h1.direction().roll()*RAD_TO_DEG;
//std::cout << x << " " << y << " " << z << " " << pitch << " " << yaw << " "<< roll << std::endl;
std::cout << thumb.stabilizedTipPosition() << "\t" << index.stabilizedTipPosition() << std::endl;
_sleep(1000);
}
while (controller.isConnected() == false)
{
printf("No Connection ");
}
}
return 0;
}
示例2: FingerLogic
void QTVS_Leap::FingerLogic(handIndex hIndex)
{
if (ui.checkBox_gesturesParangus->isChecked())
ParangusGestureLogic();
if (ui.checkBox_gesturesLeap->isChecked())
LeapGestureLogic();
//DEBUG: Atm we cancel
// return;
// 0 -> 4 = left hand
// 5 -> 9 = right hand
// So lets use a shift and no redundant code
int iHandToFingerShift = 0;
if (hIndex == handRight)
iHandToFingerShift += 5;
for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
const Finger finger = *fl;
// std::cout << std::string(4, ' ') << fingerNames[finger.type()]
// << " finger, id: " << finger.id()
// << ", length: " << finger.length()
// << "mm, width: " << finger.width() << std::endl;
Leap::Vector position = finger.stabilizedTipPosition();
// Convert Leap::Vector position to Screen Coords
QPoint screenPosition = FingerCursorPosition(position);
// Lerp coords for smoothness if required
int xCoord = lerp(fingerTraces.at(finger.type() + iHandToFingerShift)->geometry().left(), screenPosition.x(), dMouseLerpValue);
int yCoord = lerp(fingerTraces.at(finger.type() + iHandToFingerShift)->geometry().top(), screenPosition.y(), dMouseLerpValue);
// Qt Doesn't allow different threads to overwride gui locations.
// Therefore, the usage of events are well, used.
// This updates visual finger representation to correct location
QMoveEvent *tEvent = new QMoveEvent(QPoint(xCoord, yCoord), fingerTraces.at(finger.type() + iHandToFingerShift)->pos());
QCoreApplication::postEvent(fingerTraces.at(finger.type() + iHandToFingerShift), tEvent);
// Z axis does NOT use stabilized position.
// Stabilized position is generally used for X/Y movement (2D display)
// Therefore Z is updated quite poorely. So we used unStabalized position instead
// Setup position limits (manual testing for values
position = finger.tipPosition();
float zFinger = position.z < 0 ? 0 : position.z > 200 ? 200 : position.z;
// Convert to percentages
// trim lowerend of percentages
zFinger /= 200;
if (zFinger < 0.1) zFinger = 0.1;
if (hIndex == handLeft)
{
if(ui.checkBox_FingerDragsWindows->isChecked())
{
// We're on index finger and its close to screen / center of Z-plane on leap motion
if (finger.type() == leapIndex && zFinger < 0.12)
{
POINT pt;
pt.x = screenPosition.x();
pt.y = screenPosition.y();
// if our rect was reset
// Therefore, we just started to drag
if (debugWindowDrag_Left.left == -1)
{
// Find window under point
// Find window's dimmensions
// Find difference between player's finger coords and window's coords
debugWindowHWND_Left = GetRealParent(WindowFromPoint(pt));
// Set it as active window if need be.
if(debugWindowHWND_Left != GetForegroundWindow() && ui.checkBox_DragSetsActive->isChecked())
{
SetForegroundWindow(debugWindowHWND_Left);
// Backup incase SetForegroundWindow fails
// TODO: Perhaps replace in future? since foreground window DOES faile occasionally.
// SetWindowPos(debugWindowHWND_Left,HWND_TOPMOST,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
}
// Restore window if maximized Section
WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
GetWindowPlacement(debugWindowHWND_Left, &wndpl);
// Determine if window is maximized to begin with
if (wndpl.showCmd == SW_MAXIMIZE)
{
// Setup the restore command and send it
wndpl.showCmd = SW_RESTORE;
SetWindowPlacement(debugWindowHWND_Left, &wndpl);
// Center restored window around player's fingers
int iTempWindowWidth = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
int iTempWindowHeight = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
MoveWindow(debugWindowHWND_Left, pt.x - iTempWindowWidth / 2, pt.y - iTempWindowHeight / 2,
iTempWindowWidth, iTempWindowHeight, true);
}
//.........这里部分代码省略.........
示例3: 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;
//.........这里部分代码省略.........