本文整理汇总了C++中leap::Frame::tools方法的典型用法代码示例。如果您正苦于以下问题:C++ Frame::tools方法的具体用法?C++ Frame::tools怎么用?C++ Frame::tools使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leap::Frame
的用法示例。
在下文中一共展示了Frame::tools方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_finger_positions
fdata get_finger_positions()
{
Leap::Frame frame = control.frame();
Leap::FingerList fingers = frame.fingers();
Leap::ToolList tools = frame.tools();
Leap::HandList hands = frame.hands();
//std::vector<std::pair<cl_float4, int>> positions;
fdata hand_data;
int p = 0;
for(int i=0; i<40; i++)
{
hand_data.fingers[i] = 0.0f;
}
///will explode if more than 2
for(int i=0; i<hands.count(); i++)
{
const Leap::Hand hand = hands[i];
Leap::FingerList h_fingers = hand.fingers();
float grab_strength = hand.grabStrength();
hand_data.grab_confidence[i] = grab_strength;
for(int j=0; j<h_fingers.count(); j++)
{
const Leap::Finger finger = h_fingers[j];
float mfingerposx = finger.tipPosition().x;
float mfingerposy = finger.tipPosition().y;
float mfingerposz = finger.tipPosition().z;
//cl_float4 ps = {mfingerposx, mfingerposy, mfingerposz, 0.0f};
//cl_float4 ps = {mfingerposx, mfingerposy, mfingerposz, 0.0f};
int id = finger.id();
hand_data.fingers[p++] = mfingerposx;
hand_data.fingers[p++] = mfingerposy;
hand_data.fingers[p++] = mfingerposz;
hand_data.fingers[p++] = 0.0f;
//positions.push_back(std::pair<cl_float4, int>(ps, id));
}
}
return hand_data;
}
示例2: pointables
static Leap::ToolList pointables(const Leap::Frame &frame) {
return frame.tools();
}
示例3: onFrame
void SampleListener::onFrame(const Leap::Controller& controller) {
// Get the most recent frame and report some basic information
const Leap::Frame frame = controller.frame();
std::cout << "Frame id: " << frame.id()
<< ", timestamp: " << frame.timestamp()
<< ", hands: " << frame.hands().count()
<< ", extended fingers: " << frame.fingers().extended().count()
<< ", tools: " << frame.tools().count()
<< ", gestures: " << frame.gestures().count() << std::endl;
Leap::HandList hands = frame.hands();
for (Leap::HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
// Get the first hand
const Leap::Hand hand = *hl;
std::string handType = hand.isLeft() ? "Left hand" : "Right hand";
std::cout << std::string(2, ' ') << handType << ", id: " << hand.id()
<< ", palm position: " << hand.palmPosition() << std::endl;
// Get the hand's normal vector and direction
const Leap::Vector normal = hand.palmNormal();
const Leap::Vector direction = hand.direction();
// Calculate the hand's pitch, roll, and yaw angles
std::cout << std::string(2, ' ') << "pitch: " << direction.pitch() * Leap::RAD_TO_DEG << " degrees, "
<< "roll: " << normal.roll() * Leap::RAD_TO_DEG << " degrees, "
<< "yaw: " << direction.yaw() * Leap::RAD_TO_DEG << " degrees" << std::endl;
// Get the Arm bone
Leap::Arm arm = hand.arm();
std::cout << std::string(2, ' ') << "Arm direction: " << arm.direction()
<< " wrist position: " << arm.wristPosition()
<< " elbow position: " << arm.elbowPosition() << std::endl;
// Get fingers
const Leap::FingerList fingers = hand.fingers();
for (Leap::FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
const Leap::Finger finger = *fl;
std::cout << std::string(4, ' ') << fingerNames[finger.type()]
<< " finger, id: " << finger.id()
<< ", length: " << finger.length()
<< "mm, width: " << finger.width() << std::endl;
// Get finger bones
for (int b = 0; b < 4; ++b) {
Leap::Bone::Type boneType = static_cast<Leap::Bone::Type>(b);
Leap::Bone bone = finger.bone(boneType);
std::cout << std::string(6, ' ') << boneNames[boneType]
<< " bone, start: " << bone.prevJoint()
<< ", end: " << bone.nextJoint()
<< ", direction: " << bone.direction() << std::endl;
}
}
}
// Get tools
const Leap::ToolList tools = frame.tools();
for (Leap::ToolList::const_iterator tl = tools.begin(); tl != tools.end(); ++tl) {
const Leap::Tool tool = *tl;
std::cout << std::string(2, ' ') << "Tool, id: " << tool.id()
<< ", position: " << tool.tipPosition()
<< ", direction: " << tool.direction() << std::endl;
}
// Get gestures
const Leap::GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Leap::Gesture gesture = gestures[g];
switch (gesture.type()) {
case Leap::Gesture::TYPE_CIRCLE:
{
Leap::CircleGesture circle = gesture;
std::string clockwiseness;
if (circle.pointable().direction().angleTo(circle.normal()) <= Leap::PI/2) {
clockwiseness = "clockwise";
} else {
clockwiseness = "counterclockwise";
}
// Calculate angle swept since last frame
float sweptAngle = 0;
if (circle.state() != Leap::Gesture::STATE_START) {
Leap::CircleGesture previousUpdate = Leap::CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * Leap::PI;
}
std::cout << std::string(2, ' ')
<< "Circle id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", progress: " << circle.progress()
<< ", radius: " << circle.radius()
<< ", angle " << sweptAngle * Leap::RAD_TO_DEG
<< ", " << clockwiseness << std::endl;
break;
}
case Leap::Gesture::TYPE_SWIPE:
{
Leap::SwipeGesture swipe = gesture;
std::cout << std::string(2, ' ')
<< "Swipe id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
//.........这里部分代码省略.........