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


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

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


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

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

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

示例3: modeStreamDataToSL

// This experimental mode sends chat messages into SL on a back channel for LSL scripts
// to intercept with a listen() event.   This is experimental and not sustainable for
// a production feature ... many avatars using this would flood the chat system and
// hurt server performance.   Depending on how useful this proves to be, a better
// mechanism should be designed to stream data from the viewer into SL scripts.
void LLLMImpl::modeStreamDataToSL(Leap::HandList & hands)
{
	S32 numHands = hands.count();
	if (numHands == 1 &&
		mChatMsgTimer.checkExpirationAndReset(LLLEAP_CHAT_MSG_INTERVAL))
	{
		// Get the first (and only) hand
		Leap::Hand hand = hands[0];

		Leap::Vector palm_pos = hand.palmPosition();
		Leap::Vector palm_normal = hand.palmNormal();

		F32 ball_radius = (F32) hand.sphereRadius();
		Leap::Vector ball_center = hand.sphereCenter();

		// Chat message looks like "/2343 LM1,<palm pos>,<palm normal>,<sphere center>,<sphere radius>"
		LLVector3 vec;
		std::stringstream status_chat_msg;
		status_chat_msg << "/2343 LM,";
		status_chat_msg << "<" << palm_pos.x << "," << palm_pos.y << "," << palm_pos.z << ">,";
		status_chat_msg << "<" << palm_normal.x << "," << palm_normal.y << "," << palm_normal.z << ">,";
		status_chat_msg << "<" << ball_center.x << "," << ball_center.y << "," << ball_center.z << ">," << ball_radius;

		FSNearbyChat::instance().sendChatFromViewer(status_chat_msg.str(), CHAT_TYPE_SHOUT, FALSE);
	}
}
开发者ID:CaseyraeStarfinder,项目名称:Firestorm-Viewer,代码行数:31,代码来源:llleapmotioncontroller.cpp

示例4: evaluate

		/**
		  Returns
		  1 if abs(xvel) <= 1/2 abs(yvel)
		  0 otherwise
		*/
		virtual int evaluate(const Leap::Frame &frame,
				const std::string& nodeid) {
			Leap::Hand h = frame.hand(0);
			if (h.isValid()) {
				Leap::Vector vel = h.palmVelocity();
				return (abs(vel.x) <= 0.5 * abs(vel.y))
						? 1 : 0;
			} else
				return 0;
		}
开发者ID:pjromano,项目名称:zoom-ui,代码行数:15,代码来源:static.cpp

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

示例6: handForId

bool handForId(int32 checkId, Leap::HandList hands, Leap::Hand& returnHand)
{
	for (int i = 0; i < hands.count(); i++)
	{
		Leap::Hand hand = hands[i];
		if (checkId == hand.id()){
			returnHand = hand;
			return true;
		}
	}
	return false;
}
开发者ID:77stone,项目名称:leap-ue4,代码行数:12,代码来源:LeapController.cpp

示例7: HandForId

bool FLeapMotionInputDevice::HandForId(int32 CheckId, Leap::HandList Hands, Leap::Hand& ReturnHand)
{
	for (int i = 0; i < Hands.count(); i++)
	{
		Leap::Hand Hand = Hands[i];
		if (CheckId == Hand.id())
		{
			ReturnHand = Hand;
			return true;
		}
	}
	return false;
}
开发者ID:7hny,项目名称:leap-ue4,代码行数:13,代码来源:FLeapMotionInputDevice.cpp

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

示例9:

void jester::LeapMotionImpl::processHand(Leap::Hand hand, LeapHand whichHand) {
	Bone::JointId toSet = (whichHand == LeapHand::LEFT ? Bone::JointId::WRIST_L : Bone::JointId::WRIST_R);
	Bone::BoneId firstFinger = (whichHand == LeapHand::LEFT ? Bone::BoneId::PHALANX_L_1 : Bone::BoneId::PHALANX_R_1);
	JointFusionData wristData;

	wristData.confidence = LeapConfidence;
	wristData.position = glm::vec3(hand.palmPosition()[0] / LeapMeasurmentScalingFactor,
			hand.palmPosition()[1] / LeapMeasurmentScalingFactor,
			hand.palmPosition()[2] / LeapMeasurmentScalingFactor);
	wristData.id = toSet;

	kJointData.insert(std::pair<Bone::JointId, JointFusionData>(toSet, wristData));

	processFingers(hand, firstFinger, whichHand);
}
开发者ID:kevinschapansky,项目名称:Jester,代码行数:15,代码来源:LeapMotionImpl.cpp

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

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

示例12: convertHandRotation

void convertHandRotation(const Leap::Hand& hand, MatrixF& outRotation)
{
   // We need to convert from Motion coordinates to
   // Torque coordinates.  The conversion is:
   //
   // Motion                       Torque
   // a b c         a  b  c        a -c  b
   // d e f   -->  -g -h -i  -->  -g  i -h
   // g h i         d  e  f        d -f  e
   const Leap::Vector& handToFingers = hand.direction();
   Leap::Vector handFront = -handToFingers;
   const Leap::Vector& handDown = hand.palmNormal();
   Leap::Vector handUp = -handDown;
   Leap::Vector handRight = handUp.cross(handFront);

   outRotation.setColumn(0, Point4F(  handRight.x, -handRight.z,  handRight.y,  0.0f));
   outRotation.setColumn(1, Point4F( -handFront.x,  handFront.z, -handFront.y,  0.0f));
   outRotation.setColumn(2, Point4F(  handUp.x,    -handUp.z,     handUp.y,     0.0f));
   outRotation.setPosition(Point3F::Zero);
}
开发者ID:03050903,项目名称:Torque3D,代码行数:20,代码来源:leapMotionUtil.cpp

示例13: onFrame

void LeapListener::onFrame(const Controller& controller) {
	const Frame frame = controller.frame();
	static int64_t lastFrameID = 0;

	if(frame.id() < lastFrameID+10)
		return;

	Leap::HandList hands = frame.hands();
	Leap::Hand hand = hands[0];

	if(hand.isValid()) {
		float pitch = hand.direction().pitch();
		float yaw = hand.direction().yaw();
		float roll = hand.palmNormal().roll();
		float height = hand.palmPosition().y;

		std::cout << "Pitch: " << RAD_TO_DEG*pitch << " Yaw: " << RAD_TO_DEG*yaw << " Roll: " << RAD_TO_DEG*roll << " Height: " << height << " Frame: " << frame.id() << std::endl;

// 		switch(gest.type()) {
// 			case Gesture::TYPE_CIRCLE:
// 				std::cout << "Takeoff" << std::endl;
// 				if (jakopter_takeoff() < 0)
// 					return;
// 				break;
// 			case Gesture::TYPE_SWIPE:
// 				std::cout << "Land" << std::endl;
// 				if (jakopter_land() < 0)
// 					return;
// 				break;
// 			default:
// 				break;
// 		}

		char c = 's';

		if (height > 300)
			c = 'u';
		else if(height < 75)
			c = 'k';
		else if (height < 150)
			c = 'd';


		if (roll > 0.7)
			c = 'l';
		else if (roll < -0.7)
			c = 'r';

		if (pitch > 0.7)
			c = 'b';
		else if (pitch < -0.7)
			c = 'f';

		FILE *cmd = fopen(CMDFILENAME,"w");
		fprintf(cmd, "%c\n", c);
		fclose(cmd);
	}

	lastFrameID = frame.id();
}
开发者ID:Drone2,项目名称:utils,代码行数:60,代码来源:leap.cpp

示例14: recognizedControls

void BallGesture::recognizedControls(const Leap::Controller &controller, std::vector<ControlPtr> &controls) {
    Leap::Frame frame = controller.frame();
    
    // hands detected?
    if (frame.hands().isEmpty())
        return;
                
    for (int i = 0; i < frame.hands().count(); i++) {
        // gonna assume the user only has two hands. sometimes leap thinks otherwise.
        if (i > 1) break;
        
        Leap::Hand hand = frame.hands()[i];
        double radius = hand.sphereRadius(); // in mm

        if (! radius)
            continue;
                
        BallRadiusPtr bc = make_shared<BallRadius>(radius, i);
        ControlPtr cptr = dynamic_pointer_cast<Control>(bc);
        
        controls.push_back(cptr);
    }
}
开发者ID:SteveClement,项目名称:leapmidi,代码行数:23,代码来源:BallGesture.cpp

示例15: leapMenuClosed

void MenuController::leapMenuClosed(const Leap::Controller& controller, const Leap::Frame& frame)
{
	Leap::GestureList gestures = frame.gestures();
	for (const Leap::Gesture& g : gestures) {
		if (g.type() == Leap::Gesture::TYPE_CIRCLE) {
			Leap::CircleGesture circle(g);

			bool xyPlane = abs(circle.normal().dot(Leap::Vector(0, 0, 1))) > 0.8f;
			if (circle.progress() > 1.0f && xyPlane && circle.radius() > 35.0f) {


				Leap::Hand hand = circle.hands().frontmost();
				Leap::FingerList fingers = hand.fingers();

				if (fingers[1].isValid()) {
					pointer_ = fingers[1];
				} else if (fingers[2].isValid()) {
					pointer_ = fingers[2];
				}

				
				bool main = pointer_.isValid() && fingers.extended().count() <= 2;

				bool secondary = fingers[Leap::Finger::TYPE_INDEX].isExtended() &&
					fingers[Leap::Finger::TYPE_THUMB].isExtended() &&
					fingers[Leap::Finger::TYPE_MIDDLE].isExtended() && fingers.extended().count() == 3;

				if (main) {
					leap_state_ = LeapState::triggered_main;
				} else if (secondary && MainController::getInstance().focusLayer() && MainController::getInstance().focusLayer()->contextMenu()) {
					leap_state_ = LeapState::triggered_context;
				}
			}
		}
	}
}
开发者ID:joemasterjohn,项目名称:medleap,代码行数:36,代码来源:MenuController.cpp


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