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


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

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


在下文中一共展示了Frame::timestamp方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

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

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

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

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

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

示例6: ParseEvents

void FLeapMotionInputDevice::ParseEvents()
{
	//Optimization: If we don't have any delegates, skip
	if (EventDelegates.Num() == 0)
	{
		return;
	}

	//Pointers
	Leap::Frame Frame = ControllerData.LeapController.frame();
	Leap::Frame PastFrame = ControllerData.LeapController.frame(1);

	//Calculate HMD Timewarp if valid
	if (GEngine->HMDDevice.IsValid() && ControllerData.bTimeWarpEnabled) {
		LeapHMDSnapshot ThenSnapshot = HMDSamples->HMDSampleClosestToTimestamp(Frame.timestamp());
		LeapHMDSnapshot NowSnapShot = HMDSamples->CurrentHMDSample();

		LeapHMDSnapshot HistorySnapshot = HMDSamples->LastHMDSample();	//reduce jitter
		//ControllerData.TimeWarpSnapshot = NowSnapShot.Difference(ThenSnapshot, ControllerData.TimeWarpFactor);// * ControllerData.TimeWarpFactor;

		FQuat WarpQuat = NowSnapShot.Orientation;//FQuat::Slerp(NowSnapShot.Orientation, HistorySnapshot.Orientation, ControllerData.TimeWarpTween);
		FQuat ThenTweened = FQuat::Slerp(ThenSnapshot.Orientation, HistorySnapshot.Orientation, ControllerData.TimeWarpTween);

		ControllerData.TimeWarpSnapshot.Orientation = (WarpQuat.Inverse() * ControllerData.TimeWarpFactor) * ThenTweened;

		ControllerData.TimeWarpAmountMs = (ControllerData.TimeWarpSnapshot.Timestamp) / 1000.f;
	}

	//-Hands-

	//Hand Count
	int HandCount = Frame.hands().count();

	if (PastState->HandCount != HandCount)
	{
		CallFunctionOnDelegates([&](UObject* EventDelegate)
		{
			ILeapEventInterface::Execute_HandCountChanged(EventDelegate, HandCount);
		});
		//Zero our input mapping orientations (akin to letting go of a joystick)
		if (HandCount == 0)
		{
			EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmPitch, 0, 0, 0);
			EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmYaw, 0, 0, 0);
			EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmRoll, 0, 0, 0);
			EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmPitch, 0, 0, 0);
			EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmYaw, 0, 0, 0);
			EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmRoll, 0, 0, 0);
		}
	}

	//Cycle through each hand
	for (int i = 0; i < HandCount; i++)
	{
		Leap::Hand Hand = Frame.hands()[i];
		LeapHandStateData PastHandState = PastState->StateForId(Hand.id());		//we use a custom class to hold reliable state tracking based on id's

																				//Make a ULeapHand
		if (PEventHand == nullptr)
		{
			PEventHand = NewObject<ULeapHand>();
			PEventHand->AddToRoot();
		}
		PEventHand->SetHand(Hand);

		//Emit hand
		CallFunctionOnDelegates([&](UObject* EventDelegate)
		{
			ILeapEventInterface::Execute_LeapHandMoved(EventDelegate, PEventHand);
		});


		//Left/Right hand forwarding
		if (Hand.isRight())
		{
			CallFunctionOnDelegates([&](UObject* EventDelegate)
			{
				ILeapEventInterface::Execute_LeapRightHandMoved(EventDelegate, PEventHand);
			});

			//Input Mapping
			FRotator PalmOrientation = PEventHand->PalmOrientation;
			EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmPitch, PalmOrientation.Pitch * LEAP_IM_SCALE, 0, 0);
			EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmYaw, PalmOrientation.Yaw * LEAP_IM_SCALE, 0, 0);
			EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmRoll, PalmOrientation.Roll * LEAP_IM_SCALE, 0, 0);
		}
		else if (Hand.isLeft())
		{
			CallFunctionOnDelegates([&](UObject* EventDelegate)
			{
				ILeapEventInterface::Execute_LeapLeftHandMoved(EventDelegate, PEventHand);
			});

			//Input Mapping
			FRotator PalmOrientation = PEventHand->PalmOrientation;
			EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmPitch, PalmOrientation.Pitch * LEAP_IM_SCALE, 0, 0);
			EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmYaw, PalmOrientation.Yaw * LEAP_IM_SCALE, 0, 0);
			EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmRoll, PalmOrientation.Roll * LEAP_IM_SCALE, 0, 0);
		}

//.........这里部分代码省略.........
开发者ID:7hny,项目名称:leap-ue4,代码行数:101,代码来源:FLeapMotionInputDevice.cpp

示例7: oleap_bang


//.........这里部分代码省略.........
                
                sprintf(buff,"/gesture/tap/forward/position/x");
                oleap_bundleMessage(bundle,buff,screentap_position.x);
                
                sprintf(buff,"/gesture/tap/forward/position/y");
                oleap_bundleMessage(bundle,buff,screentap_position.y);
                
                sprintf(buff,"/gesture/tap/forward/position/z");
                oleap_bundleMessage(bundle,buff,screentap_position.z);
                
                sprintf(buff,"/gesture/tap/forward/direction/x");
                oleap_bundleMessage(bundle,buff,screentap_direction.x);
                
                sprintf(buff,"/gesture/tap/forward/direction/y");
                oleap_bundleMessage(bundle,buff,screentap_direction.y);
                
                sprintf(buff,"/gesture/tap/forward/direction/z");
                oleap_bundleMessage(bundle,buff,screentap_direction.z);
                
                sprintf(buff,"/gesture/tap/forward/duration");
                oleap_bundleMessage(bundle,buff,screentap.duration());

              
            }
            default:
                
                break;
        }
    }
    
    

    sprintf(buff,"/timeStamp");
    oleap_bundleMessage(bundle,buff,frame.timestamp());
    
    sprintf(buff,"/Hands");
    oleap_bundleMessage(bundle,buff,numHands);
    
    sprintf(buff,"/hand/leftmost/id");
    oleap_bundleMessage(bundle,buff,leftmost.id());
    
    sprintf(buff,"/hand/leftmost/palm/positiony/x");
    oleap_bundleMessage(bundle,buff,leftmost.palmPosition().x);
    
    sprintf(buff,"/hand/leftmost/palm/positiony/y");
    oleap_bundleMessage(bundle,buff,leftmost.palmPosition().y);
    
    sprintf(buff,"/hand/leftmost/palm/positiony/z");
    oleap_bundleMessage(bundle,buff,leftmost.palmPosition().z);

    sprintf(buff,"/hand/leftmost/direction/x");
    oleap_bundleMessage(bundle,buff,leftmost.direction().x);
    
    sprintf(buff,"/hand/leftmost/direction/y");
    oleap_bundleMessage(bundle,buff,leftmost.direction().y);
    
    sprintf(buff,"/hand/leftmost/direction/z");
    oleap_bundleMessage(bundle,buff,leftmost.direction().z);
    
    sprintf(buff,"/hand/leftmost/pitch");
    oleap_bundleMessage(bundle,buff,leftmost.palmPosition().pitch());
    
    sprintf(buff,"/hand/leftmost/yaw");
    oleap_bundleMessage(bundle,buff,leftmost.palmPosition().yaw());
    
    sprintf(buff,"/hand/leftmost/roll");
开发者ID:KevinGutowski,项目名称:o.io.leap,代码行数:67,代码来源:o.io.leap.cpp

示例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()]
//.........这里部分代码省略.........
开发者ID:RobDeBagel,项目名称:fadecandy,代码行数:101,代码来源:fc_leap.cpp


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