本文整理汇总了C++中leap::Frame::id方法的典型用法代码示例。如果您正苦于以下问题:C++ Frame::id方法的具体用法?C++ Frame::id怎么用?C++ Frame::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leap::Frame
的用法示例。
在下文中一共展示了Frame::id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyFromFrame
void LeapMotionFrame::copyFromFrame(const Leap::Frame& frame, const F32& maxHandAxisRadius)
{
// This also resets all counters
clear();
// Retrieve frame information
mFrameValid = frame.isValid();
mFrameId = frame.id();
mFrameTimeStamp = frame.timestamp();
mFrameInternalId = smNextInternalFrameId;
++smNextInternalFrameId;
mFrameSimTime = Sim::getCurrentTime();
mFrameRealTime = Platform::getRealMilliseconds();
if(!mFrameValid)
{
return;
}
// Retrieve hand information
mHandCount = frame.hands().count();
if(mHandCount > 0)
{
copyFromFrameHands(frame.hands(), maxHandAxisRadius);
}
// Retrieve pointable information
mPointableCount = frame.pointables().count();
if(mPointableCount > 0)
{
copyFromFramePointables(frame.pointables());
}
}
示例2: frame_id
static VALUE frame_id(VALUE self)
{
Leap::Frame * f;
Data_Get_Struct(self, Leap::Frame, f);
return INT2NUM(f->id());
}
示例3: main
int main(int argc, char *argv[])
{
Leap::Controller controller = Leap::Controller();
LeapRecorder recorder;
if (argc != 2) {
std::cerr << "usage: play <filename>" << std::endl;
return 1;
} else {
if(!recorder.Load(argv[1])) {
return 2;
}
recorder.Play();
while (recorder.get_state() != LeapRecorder::STATE_IDLE) {
Leap::Frame frame = recorder.GetCurrentFrame();
std::cout << "Got frame id #" << frame.id() << std::endl;
usleep(13000);
}
}
return 0;
}
示例4: update
//--------------------------------------------------------------
void testApp::update(){
Leap::Vector pNormal;
Leap::Frame frame = leapController.frame();
Leap::HandList hands = frame.hands();
Leap::Vector pt0;
Leap::Vector pt1;
if (!hands.isEmpty()) {
fingerPos.clear();
sphereSize.clear();
sphereNorm.clear();
spherePos.clear();
//ofLogNotice("hand detected");
//----------------------------------- data collection -------------------------------------------------------------
for (int i = 0; i<hands.count(); i++) {
if (i>1) break;
Leap::Hand tempHand = hands[i];
Leap::FingerList tempfinger = tempHand.fingers();
for (int j = 0; j <= tempfinger.count(); j++) {
ofVec3f pt;
Leap::Finger finger = hands[i].fingers()[j];
Leap::Vector tempPT=finger.tipPosition();
pt.x=tempPT.x;pt.y=tempPT.y;pt.z=tempPT.z;
fingerPos.push_back(pt);
}
pt0 = tempHand.palmNormal();
Leap::Vector center = tempHand.sphereCenter();
ofVec3f sp; sp.x = center.x; sp.y = center.y; sp.z = center.z;
float r = tempHand.sphereRadius();
spherePos.push_back(sp);
sphereSize.push_back(r);
sphereNorm.push_back(pt0);
ofLogNotice("hand " +ofToString(i) + "normal", ofToString(pt0.x) + " " + ofToString(pt0.y) + " " + ofToString(pt0.z));
ofLogNotice("hand " + ofToString(i) + "center ", ofToString(sp.x) + " " + ofToString(sp.y) + " " + ofToString(sp.z));
}
//---------------------------------- state machine ------------------------------------------------------------------
if(phase1==true && phase2 == false && phase3==false && phase4 == false && phase5==false && phase6 == false && phase7 == false && (!fingerPos.empty()))
{
phase2 = true;
state = 1;
}
if (phase2 == true && (sphereNorm.size()>=2)) {
pt0 = sphereNorm[0];
pt1 = sphereNorm[1];
if (abs(abs(pt0.x)-abs(pt1.x))<0.04 && abs(abs(pt0.y)-abs(pt1.y))<0.04) {
phase3 = true;
phase2 = false;
}
}
}
// ofLogNotice("phase1: ", ofToString(phase1));
// ofLogNotice("phase2: ", ofToString(phase2));
// ofLogNotice("phase3: ", ofToString(phase3));
// ofLogNotice("phase4: ", ofToString(phase4));
// ofLogNotice("phase5: ", ofToString(phase5));
// ofLogNotice("phase6: ", ofToString(phase6));
// ofLogNotice("phase7: ", ofToString(phase7));
oldFrame = frame;
preId = frame.id();
}
示例5: onFrame
void SampleListener::onFrame(const Leap::Controller& controller) {
// Get the most recent frame and report some basic information
const Leap::Frame frame = controller.frame();
const std::vector<Leap::Hand>& hands = frame.hands();
const size_t numHands = hands.size();
std::cout << "Frame id: " << frame.id()
<< ", timestamp: " << frame.timestamp()
<< ", hands: " << numHands << std::endl;
if (numHands >= 1) {
// Get the first hand
const Leap::Hand& hand = hands[0];
// Check if the hand has any fingers
const std::vector<Leap::Finger>& fingers = hand.fingers();
const size_t numFingers = fingers.size();
if (numFingers >= 1) {
// Calculate the hand's average finger tip position
Leap::Vector pos(0, 0, 0);
for (size_t i = 0; i < numFingers; ++i) {
const Leap::Finger& finger = fingers[i];
const Leap::Ray& tip = finger.tip();
pos.x += tip.position.x;
pos.y += tip.position.y;
pos.z += tip.position.z;
}
pos = Leap::Vector(pos.x/numFingers, pos.y/numFingers, pos.z/numFingers);
std::cout << "Hand has " << numFingers << " fingers with average tip position"
<< " (" << pos.x << ", " << pos.y << ", " << pos.z << ")" << std::endl;
}
// Check if the hand has a palm
const Leap::Ray* palmRay = hand.palm();
if (palmRay != NULL) {
// Get the palm position and wrist direction
const Leap::Vector palm = palmRay->position;
const Leap::Vector wrist = palmRay->direction;
std::cout << "Palm position: ("
<< palm.x << ", " << palm.y << ", " << palm.z << ")" << std::endl;
// Check if the hand has a normal vector
const Leap::Vector* normal = hand.normal();
if (normal != NULL) {
// Calculate the hand's pitch, roll, and yaw angles
double pitchAngle = atan2(normal->z, normal->y) * 180/M_PI + 180;
double rollAngle = atan2(normal->x, normal->y) * 180/M_PI + 180;
double yawAngle = atan2(wrist.z, wrist.x) * 180/M_PI - 90;
// Ensure the angles are between -180 and +180 degrees
if (pitchAngle > 180) pitchAngle -= 360;
if (rollAngle > 180) rollAngle -= 360;
if (yawAngle > 180) yawAngle -= 360;
std::cout << "Pitch: " << pitchAngle << " degrees, "
<< "roll: " << rollAngle << " degrees, "
<< "yaw: " << yawAngle << " degrees" << std::endl;
}
}
// Check if the hand has a ball
const Leap::Ball* ball = hand.ball();
if (ball != NULL) {
std::cout << "Hand curvature radius: " << ball->radius << " mm" << std::endl;
}
}
}
示例6: oleap_bang
void oleap_bang(t_oleap *x)
{
const Leap::Frame frame = x->leap->frame();
const int64_t frame_id = frame.id();
Leap::Controller controller;
// ignore the same frame
if (frame_id == x->frame_id_save) return;
x->frame_id_save = frame_id;
//outlet_anything(x->outlet, gensym("frame_start"), 0, nil);
char buff[128];
const Leap::HandList hands = frame.hands();
const size_t numHands = hands.count();
const Leap::Hand leftmost = hands.leftmost();
const Leap::Hand rightmost = hands.rightmost();
t_osc_bundle_u *bundle = osc_bundle_u_alloc();//alloc creates memory for and initializes the bundle
controller.enableGesture(Leap::Gesture::TYPE_CIRCLE);
controller.enableGesture(Leap::Gesture::TYPE_KEY_TAP);
controller.enableGesture(Leap::Gesture::TYPE_SCREEN_TAP);
controller.enableGesture(Leap::Gesture::TYPE_SWIPE);
// 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;
sprintf(buff,"/gesture/circle/center/x");
oleap_bundleMessage(bundle,buff,circle.center().x);
sprintf(buff,"/gesture/circle/center/y");
oleap_bundleMessage(bundle,buff,circle.center().y);
sprintf(buff,"/gesture/circle/center/z");
oleap_bundleMessage(bundle,buff,circle.center().z);
sprintf(buff,"/gesture/circle/pitch");
oleap_bundleMessage(bundle,buff,circle.center().pitch());
sprintf(buff,"/gesture/circle/yaw");
oleap_bundleMessage(bundle,buff,circle.center().yaw());
sprintf(buff,"/gesture/circle/roll");
oleap_bundleMessage(bundle,buff,circle.center().roll());
sprintf(buff,"/gesture/circle/radius");
oleap_bundleMessage(bundle,buff,circle.radius());
sprintf(buff,"/gesture/circle/duration");
oleap_bundleMessage(bundle,buff,circle.duration());
if (circle.pointable().direction().angleTo(circle.normal()) <= Leap::PI/4) {
clockwiseness = "clockwise";
sprintf(buff,"/gesture/circle/clockwiseness/");
oleap_bundleMessage(bundle,buff,1);
} else {
clockwiseness = "counterclockwise";
sprintf(buff,"/gesture/circle/clockwiseness/");
oleap_bundleMessage(bundle,buff,-1);
}
// 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;
sprintf(buff,"/gesture/circle/angle/sweep");
oleap_bundleMessage(bundle,buff,sweptAngle);
}
}
case Leap::Gesture::TYPE_SWIPE:
{
Leap::SwipeGesture swipe = gesture;
int swipe_id = gesture.id();
int gesture_state = gesture.state();
Leap::Vector swipe_direction = swipe.direction();
float swipe_speed = swipe.speed();
////////////////////////////////Swipe data
//.........这里部分代码省略.........
示例7: frame
void LeapHander::frame(pugi::xml_node &frameNode){
Leap::Frame currentFrame = m_sampleListener.frame();
m_lock.lock();
frameNode.append_attribute("id").set_value(currentFrame.id());
pugi::xml_node handList = frameNode.append_child("hands");
HandList hands = currentFrame.hands();
for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
// Get the first hand
const Hand hand = *hl;
pugi::xml_node handNode = handList.append_child("hand");
handNode.append_attribute("id").set_value(hand.id());
std::string handType;
if (hand.isLeft()) {
handType = "Left";
}
else {
handType = "Right";
}
handNode.append_attribute("type").set_value(handType.c_str());
pugi::xml_node positionNode = handNode.append_child("position");
positionToXml(positionNode, hand.palmPosition());
/*pugi::xml_node normalNode = handNode.append_child("normal");
positionToXml(normalNode, hand.palmNormal());
pugi::xml_node directionNode = handNode.append_child("direction");
positionToXml(directionNode, hand.direction());
pugi::xml_node rotationNode = handNode.append_child("basis");
rotationToXml(rotationNode, hand.basis());*/
//// Get fingers
pugi::xml_node fingerList = handNode.append_child("fingers");
const FingerList fingers = hand.fingers();
for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
const Finger finger = *fl;
pugi::xml_node fingerNode = fingerList.append_child("finger");
fingerNode.append_attribute("id").set_value(finger.id());
fingerNode.append_attribute("name").set_value(fingerNames[finger.type()].c_str());
pugi::xml_node boneList = fingerNode.append_child("bones");
// Get finger bones
for (int b = 0; b < 4; ++b) {
Bone::Type boneType = static_cast<Bone::Type>(b);
Bone bone = finger.bone(boneType);
pugi::xml_node boneNode = boneList.append_child("bone");
boneNode.append_attribute("length").set_value(bone.length());
boneNode.append_attribute("name").set_value(boneNames[boneType].c_str());
pugi::xml_node prevJoint = boneNode.append_child("prevJoint");
positionToXml(prevJoint, bone.prevJoint());
pugi::xml_node nextJoint = boneNode.append_child("nextJoint");
positionToXml(nextJoint, bone.nextJoint());
/*pugi::xml_node rotation = boneNode.append_child("basis");
rotationToXml(rotation, bone.basis());*/
}
}
}
m_lock.unlock();
}
示例8: 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()]
//.........这里部分代码省略.........