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


C++ Frame::isValid方法代码示例

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


在下文中一共展示了Frame::isValid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
   }
}
开发者ID:campadrenalin,项目名称:terminal-overload,代码行数:34,代码来源:leapMotionFrame.cpp

示例2: 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

示例3: 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

示例4: 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

示例5: processGestures

//Handle Leap Gesture processing.
//Trigger the corresponding effects in the particle field.
void GesturesDemo::processGestures() {
  Leap::Frame frame = controller.frame();

  if ( lastFrame == frame ) {
    return;
  }

  Leap::GestureList gestures =  lastFrame.isValid()       ?
                                frame.gestures(lastFrame) :
                                frame.gestures();

  lastFrame = frame;

  size_t numGestures = gestures.count();

  for (size_t i=0; i < numGestures; i++) {
    if (gestures[i].type() == Leap::Gesture::TYPE_SCREEN_TAP) {
      printf("screen screen tap gesture");
      Leap::ScreenTapGesture tap = gestures[i];
      ci::Vec3f tapLoc = normalizeCoords(tap.position());
      field.Repel(tap.id(), ci::Vec2f(tapLoc.x, tapLoc.y), 3.0);
    } else if (gestures[i].type() == Leap::Gesture::TYPE_KEY_TAP) {
      printf("screen key tap gesture");
      Leap::KeyTapGesture tap = gestures[i];
      ci::Vec3f tapLoc = normalizeCoords(tap.position());
      field.Repel(tap.id(), ci::Vec2f(tapLoc.x, tapLoc.y), -3.0);
    } else if (gestures[i].type() == Leap::Gesture::TYPE_SWIPE) {
      printf(" swipe  gesture");
      Leap::SwipeGesture swipe = gestures[i];
      Leap::Vector diff = 0.004f*(swipe.position() - swipe.startPosition());
      ci::Vec3f curSwipe(diff.x, -diff.y, diff.z);
      field.Translate(swipe.id(), curSwipe);
    } else if (gestures[i].type() == Leap::Gesture::TYPE_CIRCLE) {
      printf(" circle gesture");
      Leap::CircleGesture circle = gestures[i];
      float progress = circle.progress();
      if (progress >= 1.0f) {
        ci::Vec3f center = normalizeCoords(circle.center());
        ci::Vec3f normal(circle.normal().x, circle.normal().y, circle.normal().z);
        double curAngle = 6.5;
        if (normal.z < 0) {
          curAngle *= -1;
        }
        field.Rotate(circle.id(), ci::Vec2f(center.x, center.y), circle.radius()/250, curAngle);
      }
    }
  }
}
开发者ID:sjokoladevx,项目名称:Black-Nanocopter-Down---Final-Project-Repo,代码行数:50,代码来源:GesturesDemo.cpp

示例6: loadFrame

//function to get a frame and return it in the format acceptable to MATLAB
//ie mxArray
void loadFrame(mxArray *plhs[])
{
    //get current frame
	Leap::Frame frame = controller->frame();
	//DEBUG: check if frame is valid
	if(!frame.isValid()) mexErrMsgTxt("Frame returned was not valid");
    //wait for frame to be valid
	//while(!frame.isValid()) controller->frame();
    
    Leap::HandList hands = frame.hands();
    
    //import variables and create struct
	
	//number of hands
	int numHands = hands.count();
	
	//if there are no hands return a null pointer
	if(!numHands){
		plhs[0] = mxCreateDoubleScalar(0);
		return;
	}
	
	//fields returned to matlab in the struct:
	int numHandFields = 4;    //change number of fields here****
	const char *hand_field_names[] = 
	{
		"position",
		"velocity",
		"direction",
		"pointables"
		//add new hand fields here****
	};
	
	//pointable temp values for a given hand
	int numPointables;
	Leap::PointableList pointList;
	int numPointFields = 3;  	//change number of pointable fields here****
	const char *point_field_names[] = 
	{
		"position",
		"velocity",
		"direction"
		//add new pointable fields here****
	};
	mxArray *p;	
		
	//allocate the structure array to export to matlab
	mxArray *h = mxCreateStructMatrix(1, numHands, numHandFields, hand_field_names);
	
	//put vectors into structure array fields
	int i,j; //iterators
	for(i=0;i<numHands;i++){
		//fill in hand information
		mxSetFieldByNumber(h,i,0,makeVector(hands[i].palmPosition()));
		mxSetFieldByNumber(h,i,1,makeVector(hands[i].palmVelocity()));
		mxSetFieldByNumber(h,i,2,makeVector(hands[i].direction()));
		// add new field information here****
		//create pointable struct for this hand
		pointList = hands[i].pointables();		//get list of pointables for this hand
		numPointables = pointList.count();	    //get number of pointables for this hand
		//build list of pointables
		p = mxCreateStructMatrix(1,numPointables,numPointFields,point_field_names);
		for(j=0;j<numPointables;j++){
			mxSetFieldByNumber(p,j,0,makeVector(pointList[j].tipPosition()));
			mxSetFieldByNumber(p,j,1,makeVector(pointList[j].tipVelocity()));
			mxSetFieldByNumber(p,j,2,makeVector(pointList[j].direction()));
			//add new pointable fields here****
		}
		//put pointable list into hand struct
		mxSetFieldByNumber(h,i,3,p);
	}
    plhs[0] = h;  //set output
    return;
}
开发者ID:holmesco,项目名称:leap2matlab,代码行数:76,代码来源:leap2matlab.cpp


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