本文整理汇总了C++中leap::Frame类的典型用法代码示例。如果您正苦于以下问题:C++ Frame类的具体用法?C++ Frame怎么用?C++ Frame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Frame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processGesture
void LeapFishyApp::processGesture()
{
Leap::Frame frame = m_LeapController.frame();
if( m_LastFrame == frame )
return;
Leap::GestureList gestures = m_LastFrame.isValid() ?
frame.gestures( m_LastFrame ) :
frame.gestures();
m_LastFrame = frame;
for( int i = 0; i < gestures.count(); i++ )
{
if( gestures[i].type() == Leap::Gesture::TYPE_SWIPE )
{
Leap::SwipeGesture swipe = gestures[i];
Leap::Vector diff = 0.006f*(swipe.position() - swipe.startPosition());
Vec2f curSwipe(diff.x, -diff.y);
m_pPlayer->AddVelocity( curSwipe );
}
else if( gestures[i].type() == Leap::Gesture::TYPE_KEY_TAP ||
gestures[i].type() == Leap::Gesture::TYPE_SCREEN_TAP )
{
m_pPlayer->KillVelocity();
}
}
}
示例2: onFrame
void Listener::onFrame(const Leap::Controller &controller) {
Leap::Frame curFrame = controller.frame();
if (firstFrameLeap == 0 && ++frameCount > 10) {
gettimeofday(&firstFrameAbs, NULL);
firstFrameLeap = curFrame.timestamp();
cout << "First frame clock time: " << tv_to_usec(firstFrameAbs) << endl;
cout << "First frame leap time: " << firstFrameLeap << endl;
}
// use current active gesture recognizers to locate gestures
// and then trigger appropriate note/controls
// feed frames to recognizers
vector<GesturePtr> recognizers = gestureRecognizers();
for (vector<GesturePtr>::iterator it = recognizers.begin(); it != recognizers.end(); ++it) {
// get controls recognized from gestures
GesturePtr gesture = *it;
std::vector<ControlPtr> gestureControls; // controls from this gesture
gesture->recognizedControls(controller, gestureControls);
if (! gestureControls.size())
continue;
// call gesture recognized callback
onGestureRecognized(controller, gesture);
for (vector<ControlPtr>::iterator ctl = gestureControls.begin(); ctl != gestureControls.end(); ++ctl) {
ControlPtr control = *ctl;
onControlUpdated(controller, gesture, control);
}
}
}
示例3: updateLeapPointer
void MenuController::updateLeapPointer(const Leap::Controller& controller, const Leap::Frame& frame)
{
pointer_ = frame.fingers().extended().frontmost();
Leap::Vector n = frame.interactionBox().normalizePoint(pointer_.stabilizedTipPosition());
leap.x = n.x * viewport_.width + viewport_.x;
leap.y = n.y * viewport_.height + viewport_.y;
}
示例4: onFrame
void Quickstart::onFrame(const Leap::Controller &controller) {
// returns the most recent frame. older frames can be accessed by passing in
// a "history" parameter to retrieve an older frame, up to about 60
// (exact number subject to change)
const Leap::Frame frame = controller.frame();
// do nothing unless hands are detected
if (frame.hands().empty())
return;
// first detected hand
const Leap::Hand firstHand = frame.hands()[0];
// first pointable object (finger or tool)
const Leap::PointableList pointables = firstHand.pointables();
if (pointables.empty()) return;
const Leap::Pointable firstPointable = pointables[0];
// print velocity on the X axis
cout << "Pointable X velocity: " << firstPointable.tipVelocity()[0] << endl;
const Leap::FingerList fingers = firstHand.fingers();
if (fingers.empty()) return;
for (int i = 0; i < fingers.count(); i++) {
const Leap::Finger finger = fingers[i];
std::cout << "Detected finger " << i << " at position (" <<
finger.tipPosition().x << ", " <<
finger.tipPosition().y << ", " <<
finger.tipPosition().z << ")" << std::endl;
}
}
示例5: drawHands
void HandController::drawHands() {
glPushMatrix();
glTranslatef(translation_);
glScalef(scale_, scale_, scale_);
Leap::Frame frame = controller_.frame();
for (int h = 0; h < frame.hands().count(); ++h) {
Leap::Hand hand = frame.hands()[h];
for (int f = 0; f < hand.fingers().count(); ++f) {
Leap::Finger finger = hand.fingers()[f];
// Draw first joint inside hand.
Leap::Bone mcp = finger.bone(Leap::Bone::Type::TYPE_METACARPAL);
drawJoint(mcp.prevJoint());
for (int b = 0; b < 4; ++b) {
Leap::Bone bone = finger.bone(static_cast<Leap::Bone::Type>(b));
drawJoint(bone.nextJoint());
drawBone(bone);
}
}
}
glPopMatrix();
}
示例6: onLeapFrame
void ExampleTool::onLeapFrame( Leap::Frame const &aFrame )
{
mHands = aFrame.hands().count();
mFingers = 0;
for( int i = 0; i < mHands; ++ i )
mFingers += aFrame.hands()[ i ].fingers().count();
}
示例7: CopyHandsData
void LeapController::CopyHandsData( LeapFrame & a_frame_internal, Leap::Frame & a_frame_external )
{
const Leap::Device & device = m_ctrl.devices()[0];
a_frame_internal.hands.clear();
a_frame_internal.hands.resize(a_frame_external.hands().count());
a_frame_internal.fingers.clear();
for ( int i_hand = 0; i_hand < a_frame_external.hands().count(); ++i_hand )
{
const Leap::Hand & hand_ext = a_frame_external.hands()[i_hand];
// setup hand
LeapHand & hand = a_frame_internal.hands[i_hand];
hand.id = hand_ext.id();
hand.fingers_count = 0;
hand.dir = toV3( hand_ext.direction() );
hand.palm_normal = toV3( hand_ext.palmNormal() );
hand.palm_pos = toV3( hand_ext.palmPosition() ) * LEAP_SCALE;
hand.palm_vel = toV3( hand_ext.palmVelocity() ) * LEAP_SCALE;
hand.sphere_center = toV3( hand_ext.sphereCenter() ) * LEAP_SCALE;
hand.sphere_radius = hand_ext.sphereRadius() * LEAP_SCALE;
hand.age = hand_ext.timeVisible();
hand.dist_to_boundary = device.distanceToBoundary( hand_ext.palmPosition() ) * LEAP_SCALE;
int hand_ext_finger_count = hand_ext.fingers().count();
// clamp the number of fingers if LEAP bugs out and returns hand with more than 5 fingers
hand_ext_finger_count = max( hand_ext_finger_count, LEAP_MAX_NUM_FINGERS_PER_HAND );
//ASSERT( hand_ext_finger_count <= LEAP_MAX_NUM_FINGERS_PER_HAND );
for( int i_finger = 0; i_finger < hand_ext_finger_count; ++i_finger )
{
const Leap::Finger & finger_ext = hand_ext.fingers()[i_finger];
if ( finger_ext.isValid() )
{
// alloc new finger
a_frame_internal.fingers.resize( a_frame_internal.fingers.size()+1 );
LeapFinger &finger = a_frame_internal.fingers.back();
finger.id = finger_ext.id();
finger.hand_id = hand.id;
finger.hand_index = (int)i_hand;
finger.finger_size = v2( finger_ext.width(), finger_ext.length() ) * LEAP_SCALE;
finger.dir = toV3( finger_ext.direction() );
finger.tip_pos = toV3( finger_ext.tipPosition() ) * LEAP_SCALE;
finger.tip_vel = toV3( finger_ext.tipVelocity() ) * LEAP_SCALE;
finger.age = finger_ext.timeVisible();
finger.tip_pos_stabilized = toV3( finger_ext.stabilizedTipPosition() ) * LEAP_SCALE;
finger.dist_to_boundary = device.distanceToBoundary( finger_ext.tipPosition() ) * LEAP_SCALE;
// add finger
hand.fingers_index[hand.fingers_count] = (int)a_frame_internal.fingers.size()-1;
++hand.fingers_count;
}
}
}
}
示例8: frame_timestamp
static VALUE frame_timestamp(VALUE self)
{
Leap::Frame * f;
Data_Get_Struct(self, Leap::Frame, f);
return INT2NUM(f->timestamp());
}
示例9: frame_id
static VALUE frame_id(VALUE self)
{
Leap::Frame * f;
Data_Get_Struct(self, Leap::Frame, f);
return INT2NUM(f->id());
}
示例10: frame_to_s
static VALUE frame_to_s(VALUE self)
{
Leap::Frame * f;
const char * string;
Data_Get_Struct(self, Leap::Frame, f);
string = f->toString().c_str();
return rb_str_new2(string);
}
示例11: frame_hands
static VALUE frame_hands(VALUE self)
{
Leap::Frame * f;
Leap::HandList * list;
Data_Get_Struct(self, Leap::Frame, f);
list = new Leap::HandList(f->hands());
return WrapHandList(list);
}
示例12: frame_invalid
static VALUE frame_invalid(VALUE self)
{
Leap::Frame * f;
Leap::Frame * invalid;
Data_Get_Struct(self, Leap::Frame, f);
invalid = new Leap::Frame(f->invalid());
return Data_Wrap_Struct(cFrame, 0, 0, invalid);
}
示例13: onLeapFrame
void ManipTool::onLeapFrame( Leap::Frame const &aFrame )
{
if( (aFrame.timestamp() - mLastExaminedFrame ) < 16*1000 )
return;
if( aFrame.hands().count() > 2 )
return;
mLastExaminedFrame = aFrame.timestamp();
U16 curFrame = getNextFrameNo( mLastStoredFrame );
Fingers &curFingers = mFingersPerFrame[ curFrame ];
U16 curFinger = 0;
curFingers.clear();
curFingers.mTimestamp = mLastExaminedFrame;
Leap::HandList hands = aFrame.hands();
for( int i = 0; i < hands.count(); ++i )
{
for( int j = 0; j < hands[i].fingers().count(); ++j )
{
Leap::Finger oFinger( hands[i].fingers()[j] );
Finger &oF = curFingers.mFingers[ curFinger++ ];
oF.mId = oFinger.id();
oF.mTimestamp = mLastExaminedFrame;
copy( oFinger.direction(), oF.mDir );
copy( oFinger.tipPosition(), oF.mTip );
oF.mWidth = oFinger.width();
oF.mLength = oFinger.length();
}
}
curFingers.mStoredFingers = curFinger;
if( mTotalStoredFrames > 0 )
{
Fingers &prevFingers = mFingersPerFrame[ mLastStoredFrame ];
for( U16 i = 0; i < curFingers.mStoredFingers; ++i )
{
Finger &curFinger = curFingers.mFingers[i];
Finger const *prevFinger = prevFingers.getFinger( curFinger.mId );
if( !prevFinger )
continue;
subtract( curFinger.mTip, prevFinger->mTip, curFinger.mFromLast );
curFinger.mLenFromLast = normalize( curFinger.mFromLast );
}
}
mLastStoredFrame = curFrame;
++mTotalStoredFrames;
}
示例14: 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;
}
示例15: valid_p
static VALUE valid_p(VALUE self)
{
Leap::Frame * f;
Data_Get_Struct(self, Leap::Frame, f);
if (true == f->isValid()) {
return Qtrue;
}
return Qfalse;
}