• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中leap::Frame的典型用法代码示例。如果您正苦于以下问题:C++ Frame类的具体用法?C++ Frame怎么用?C++ Frame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Frame类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: processFingers

void LeapCinderVectorFieldApp::processFingers()
{
	Leap::Frame frame = m_LeapController.frame();
	Leap::FingerList fingers = frame.fingers();

	m_VectorField->ClearPointTo();

	for( int i = 0; i < fingers.count(); i++ )
	{
		m_VectorField->CheckPointTo( normalizeCoords( fingers[i].tipPosition() ) );
	}
}
开发者ID:seanfoo73,项目名称:LeapExperiments,代码行数:12,代码来源:LeapCinderVectorFieldApp.cpp


示例17: memset

void eleap::eleap_t::impl_t::onFrame(const Leap::Controller& controller)
{
    const Leap::Frame frame = controller.frame();
    if (frame.isValid())
    {
        // send the known hands in this frame, this will handle hands coming and going
        const Leap::HandList hands = frame.hands();
        {
            unsigned long long time_encoded = (0&0xffffffff)<<8 | (DATA_KNOWN_HANDS&0xff);

            float *f;
            unsigned char *dp;
            piw::data_nb_t d = ctx_.allocate_host(time_encoded,INT32_MAX,INT32_MIN,0,BCTVTYPE_INT,sizeof(int32_t),&dp,hands.count(),&f);
            memset(f,0,hands.count()*sizeof(int32_t));
            *dp = 0;

            for(int i = 0; i < hands.count(); ++i)
            {
                const Leap::Hand hand = hands[i];
                if(hand.isValid() && hand.fingers().count() > 1)
                {
                    ((int32_t *)f)[i] = hand.id();
                }
            }
            enqueue_fast(d,1);
        }
        
        // handle the actual data for the detected hands
        for(int i = 0; i < hands.count(); ++i)
        {
            const Leap::Hand hand = hands[i];
            if(hand.isValid() && hand.fingers().count() > 1)
            {
                unsigned long long time_encoded = (hand.id()&0xffffffff)<<8 | (DATA_PALM_POSITION&0xff);

                const Leap::Vector palm_pos = hand.palmPosition();

                float *f;
                unsigned char *dp;
                piw::data_nb_t d = ctx_.allocate_host(time_encoded,600,-600,0,BCTVTYPE_FLOAT,sizeof(float),&dp,3,&f);
                memset(f,0,3*sizeof(float));
                *dp = 0;

                f[0] = piw::normalise(600,-600,0,palm_pos.x);
                f[1] = piw::normalise(600,-600,0,palm_pos.y);
                f[2] = piw::normalise(600,-600,0,palm_pos.z);

                enqueue_fast(d,1);
            }
        }
    }
}
开发者ID:Eigenlabs,项目名称:EigenD-Contrib,代码行数:52,代码来源:eleap.cpp


示例18: frame

    virtual void onFrame        (const Leap::Controller&)
    {
        const Leap::Frame frame(m_Controller.frame(0));
        const Leap::Hand hand(frame.hands().rightmost());
        if (!hand.isValid())
        {
            m_LastNormalizedPos.reset();
            return;
        }

        const Leap::Vector pos(hand.palmPosition());
        m_LastNormalizedPos = frame.interactionBox().normalizePoint(pos);
    }
开发者ID:IrmatDen,项目名称:sfge,代码行数:13,代码来源:controller_leap_metalpad.cpp


示例19: eventShake

int StateKen::eventShake(StateContext& context, const Leap::Controller& controller)
{
    std::cout << "けん\n" << std::endl;
    
    const Leap::Frame frame = controller.frame();
    const Leap::Hand hand = frame.hands()[0];
    
    Leap::Vector position = hand.palmPosition();
    
    JankenApp::getInstance()->setShakeStartPosition(position);
    
    int ret = context.changeState(StatePon::getInstance());
    
    return ret;
}
开发者ID:haraki,项目名称:ConsoleJanken-for-Windows,代码行数:15,代码来源:StateKen.cpp


示例20: getPinches

pinch_list HandController::getPinches() {
  Leap::Frame frame = controller_.frame();
  pinch_list pinches;
  
  for (int i = 0; i < frame.hands().count(); ++i) {
    float pinch_strength = frame.hands()[i].pinchStrength();
    
    Leap::Vector tip = frame.hands()[i].fingers()[1].tipPosition();
    Vec3f transformed_tip = scale_ * ToVec3f(tip) + translation_;
    
    pinches.push_back(std::pair<Vec3f, float>(transformed_tip, pinch_strength));
  }
  
  return pinches;
}
开发者ID:gauntalt,项目名称:MagneticMesh,代码行数:15,代码来源:HandController.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ leap::Hand类代码示例发布时间:2022-05-31
下一篇:
C++ leap::Controller类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap