当前位置: 首页>>代码示例>>C++>>正文


C++ leap::Frame类代码示例

本文整理汇总了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();
		}
	}
}
开发者ID:seanfoo73,项目名称:LeapExperiments,代码行数:29,代码来源:LeapFishyApp.cpp

示例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);
        }
    }
}
开发者ID:SteveClement,项目名称:leapmidi,代码行数:32,代码来源:MIDIListener.cpp

示例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;
}
开发者ID:joemasterjohn,项目名称:medleap,代码行数:7,代码来源:MenuController.cpp

示例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;
    }
}
开发者ID:revmischa,项目名称:leapbook,代码行数:32,代码来源:quickstart.cpp

示例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();
}
开发者ID:gauntalt,项目名称:MagneticMesh,代码行数:26,代码来源:HandController.cpp

示例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();
		}
开发者ID:CaseyraeStarfinder,项目名称:Firestorm-Viewer,代码行数:7,代码来源:fsleapexampletool.cpp

示例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;
            }
        }
    }
}
开发者ID:kalineh,项目名称:FunkEngine-Public,代码行数:59,代码来源:LeapController.cpp

示例8: frame_timestamp

static VALUE frame_timestamp(VALUE self)
{
  Leap::Frame * f;

  Data_Get_Struct(self, Leap::Frame, f);

  return INT2NUM(f->timestamp());
}
开发者ID:cpb,项目名称:leap_motion,代码行数:8,代码来源:frame.cpp

示例9: frame_id

static VALUE frame_id(VALUE self)
{
  Leap::Frame * f;

  Data_Get_Struct(self, Leap::Frame, f);

  return INT2NUM(f->id());
}
开发者ID:cpb,项目名称:leap_motion,代码行数:8,代码来源:frame.cpp

示例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);
}
开发者ID:cpb,项目名称:leap_motion,代码行数:10,代码来源:frame.cpp

示例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);
}
开发者ID:cpb,项目名称:leap_motion,代码行数:11,代码来源:frame.cpp

示例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);
}
开发者ID:cpb,项目名称:leap_motion,代码行数:11,代码来源:frame.cpp

示例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;
		}
开发者ID:CaseyraeStarfinder,项目名称:Firestorm-Viewer,代码行数:54,代码来源:fsleapmaniptool.cpp

示例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;
}
开发者ID:Michaelangel007,项目名称:openclamdrenderer,代码行数:54,代码来源:main.cpp

示例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;
}
开发者ID:cpb,项目名称:leap_motion,代码行数:12,代码来源:frame.cpp


注:本文中的leap::Frame类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。