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


C++ Finger::type方法代码示例

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


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

示例1: drawBone

//--------------------------------------------------------------
void LeapVisualizer::drawBone (const Finger & finger, Bone & bone,ofxLeapMotion & leap){
	
	Finger::Type fingerType = finger.type();
	Bone::Type   boneType   = bone.type();
	
	// The Leap returns data in millimeters.
	ofPoint bonePt0 = leap.getofPoint ( bone.prevJoint());
	ofPoint bonePt1 = leap.getofPoint ( bone.nextJoint());
	float boneThickness = bone.width();
	
	// ofPoint bonePtC = leap.getofPoint ( bone.center()); // works, but:
	ofPoint bonePtC = (bonePt0 + bonePt1)/2.0;
	
	if (bDrawSimple){
		// Draw a simple white skeleton.
		ofSetColor(ofColor::white);
		ofLine(bonePt0, bonePt1);
		ofDrawSphere(bonePt0, boneThickness * 0.15);
		ofDrawSphere(bonePt1, boneThickness * 0.15);
		ofDrawSphere(bonePtC, boneThickness * 0.05);
		
	} else {
		// Draw a colored cylinder with double-sphere caps.
		setColorByFinger (fingerType, boneType);
		drawOrientedCylinder (bonePt0, bonePt1, boneThickness/2.0);
		ofDrawSphere(bonePt0, boneThickness/2.0);
		ofDrawSphere(bonePt1, boneThickness/2.0);
	}
}
开发者ID:Julien-Dr,项目名称:digital_art_2014,代码行数:30,代码来源:LeapVisualizer.cpp

示例2: recordBoneXML

//--------------------------------------------------------------
void testApp::recordBoneXML (const Finger & finger, Bone & bone){
	
	if (bRecordingThisFrame){
		
		Finger::Type fingerType = finger.type();
		Bone::Type   boneType   = bone.type();
		
		// The Leap returns data in millimeters.
		ofPoint bonePt0 = leap.getofPoint ( bone.prevJoint());
		ofPoint bonePt1 = leap.getofPoint ( bone.nextJoint());
		float boneThickness = bone.width();
		
		int boneTagNum = XML.addTag("B");
		if( XML.pushTag("B", boneTagNum) ){
			XML.setValue("TYPE", (int)boneType, boneTagNum);
			
			if ((boneType == 0) || ((fingerType == 0) && (boneType == 1))) {
				// bone points are redundant, so only use the P point.
				// except for bone 0, which gets both Q and P.
				int p0TagNum = XML.addTag("Q");
				XML.setValue("Q:X", bonePt0.x, p0TagNum);
				XML.setValue("Q:Y", bonePt0.y, p0TagNum);
				XML.setValue("Q:Z", bonePt0.z, p0TagNum);
			}
			
			int p1TagNum = XML.addTag("P");
			XML.setValue("P:X", bonePt1.x, p1TagNum);
			XML.setValue("P:Y", bonePt1.y, p1TagNum);
			XML.setValue("P:Z", bonePt1.z, p1TagNum);
			
			XML.popTag(); // pop B(ONE)
		}
	}
}
开发者ID:ahork,项目名称:digital_art_2014,代码行数:35,代码来源:recordXML.cpp

示例3: sample

void AirwritingListener::sample(const Finger &finger, unsigned long long timestamp) {
    if (finger.type() == FINGER_INDEX) {
        if ((sampling) && (timestamp - lastTimestamp > GESTURE_TAP_MIN_TIMESTAMP_DELTA)) {
            float x = finger.tipPosition().x;
            float y = finger.tipPosition().y;
            float z = finger.tipPosition().z;
            if ((y > FINGER_Y_MIN) && (y < FINGER_Y_MAX)) {
                if ((fabs(x) < FINGER_X_MAX) && (fabs(z) < FINGER_Z_MAX)) {
                    Canvas::getInstance()->setPixel(x / FINGER_X_MAX, z / FINGER_Z_MAX, y / 10);
                }
            }
        }
    }
}
开发者ID:xwj95,项目名称:Airwriting,代码行数:14,代码来源:AirwritingListener.cpp

示例4: recordFingerXML

//--------------------------------------------------------------
void testApp::recordFingerXML (const Finger & finger){
	
	if (bRecordingThisFrame){
		if (finger.isValid()){
			Finger::Type fingerType = finger.type();
			
			int fingerTagNum = XML.addTag("F");
			if( XML.pushTag("F", fingerTagNum) ){
				XML.setValue("TYPE", (int)fingerType, fingerTagNum);
				XML.setValue("WIDTH", finger.width(), fingerTagNum);
				
				// Add in the fingerTip point as its own point.
				ofPoint fingerTipPt = leap.getofPoint ( finger.tipPosition() );
				int tipTagNum = XML.addTag("T");
				XML.setValue("T:X", fingerTipPt.x, tipTagNum);
				XML.setValue("T:Y", fingerTipPt.y, tipTagNum);
				XML.setValue("T:Z", fingerTipPt.z, tipTagNum);
				
				// For every bone (i.e. phalange) in the finger,
				for (int b=0; b<4; b++) {
					
					// Get each bone;
					Bone::Type boneType = static_cast<Bone::Type>(b);
					Bone bone = finger.bone(boneType);
					if (bone.isValid()){
						
						// Don't consider zero-length bones, such as the Thumb's metacarpal.
						if (bone.length() > 0){
							recordBoneXML (finger, bone);
							
						} // end if boneLength
					} // end if bone isValid()
				} // end for each bone
				
				
				XML.popTag(); // pop F(INGER)
			}
		} //end if finger isValid()
	}
}
开发者ID:ahork,项目名称:digital_art_2014,代码行数:41,代码来源:recordXML.cpp

示例5: updateCursorLocation

void LeapBrowser::updateCursorLocation()
{
	bool is_index_found = false;

	Frame frame = leap_controller.frame();	
	HandList hands = frame.hands();
	for( int h=0; h < hands.count(); h++ )
	{
		Hand hand = hands[h];
		FingerList fingers = hand.fingers();
		for( int f=0; f < fingers.count(); f++ )
		{
			Finger finger = fingers[f];
			if( finger.type() == Finger::Type::TYPE_INDEX )
			{
				is_index_found = true;

				Vector position = finger.tipPosition();
				cursor_location = math::position(position.x, position.y, position.z) * leap_transform;

				break;
			}
		}
		if( is_index_found )
		{
			break;
		}
	}

	if( !is_index_found )
	{
		cursor_location = math::position(0,0,0);
		is_cursor_located = false;
	}
	else
	{
		is_cursor_located = true;
	}
}
开发者ID:lumigraph,项目名称:MotionOrbits,代码行数:39,代码来源:LeapBrowser.cpp

示例6: onFrame

void LeapListener::onFrame(const Controller & controller) {
    // Get the most recent frame and report some basic information
    const 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;

    HandList hands = frame.hands();
    for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
        // Get the first hand
        const 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 Vector normal = hand.palmNormal();
        const Vector direction = hand.direction();

        // Calculate the hand's pitch, roll, and yaw angles
        std::cout << std::string(2, ' ') <<  "pitch: " << direction.pitch() * RAD_TO_DEG << " degrees, "
        << "roll: " << normal.roll() * RAD_TO_DEG << " degrees, "
        << "yaw: " << direction.yaw() * RAD_TO_DEG << " degrees" << std::endl;

        // Get the Arm bone
        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 FingerList fingers = hand.fingers();
        for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
            const 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) {
                Bone::Type boneType = static_cast<Bone::Type>(b);
                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 ToolList tools = frame.tools();
    for (ToolList::const_iterator tl = tools.begin(); tl != tools.end(); ++tl) {
        const Tool tool = *tl;
        std::cout << std::string(2, ' ') <<  "Tool, id: " << tool.id()
        << ", position: " << tool.tipPosition()
        << ", direction: " << tool.direction() << std::endl;
    }

    // Get gestures
    const GestureList gestures = frame.gestures();
    for (int g = 0; g < gestures.count(); ++g) {
        Gesture gesture = gestures[g];

        switch (gesture.type()) {
            case Gesture::TYPE_CIRCLE: {
                CircleGesture circle = gesture;
                std::string clockwiseness;

                if (circle.pointable().direction().angleTo(circle.normal()) <= PI/2) {
                    clockwiseness = "clockwise";
                } else {
                    clockwiseness = "counterclockwise";
                }

                // Calculate angle swept since last frame
                float sweptAngle = 0;
                if (circle.state() != Gesture::STATE_START) {
                    CircleGesture previousUpdate = CircleGesture(controller.frame(1).gesture(circle.id()));
                    sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * PI;
                }
                std::cout << std::string(2, ' ')
                << "Circle id: " << gesture.id()
                << ", state: " << stateNames[gesture.state()]
                << ", progress: " << circle.progress()
                << ", radius: " << circle.radius()
                << ", angle " << sweptAngle * RAD_TO_DEG
                <<  ", " << clockwiseness << std::endl;
                break;
            }
            case Gesture::TYPE_SWIPE: {
                SwipeGesture swipe = gesture;
                std::cout << std::string(2, ' ')
                << "Swipe id: " << gesture.id()
                << ", state: " << stateNames[gesture.state()]
                << ", direction: " << swipe.direction()
                << ", speed: " << swipe.speed() << std::endl;
//.........这里部分代码省略.........
开发者ID:quantum0813,项目名称:Erics3DEngine,代码行数:101,代码来源:LeapListener.cpp

示例7: onFrame

void SampleListener::onFrame(const Controller& controller)
{
    bool thand, index = false;

    // Get the most recent frame and report some basic information
    const Frame frame = controller.frame();

    // Receive Hand List
    HandList hands = frame.hands();

    // For all hands
    for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl)
    {
        // Get the first hand
        const Hand hand         = *hl;

        // Only for right hand
        if( hand.isRight() )
        {
            // Get fingers
            const FingerList fingers = hand.fingers();
            // For all fingers in the list
            for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl)
            {
                      Bone      bone;
                const Finger    finger = *fl;

                // If thamb or Index finger
                if( finger.type() == Finger::TYPE_THUMB )
                {
                    // Receive nided bone
                    bone        = finger.bone(Bone::TYPE_DISTAL);
                    m_vThand    = bone.center();

                    thand = true;
                }
                else if( finger.type() == Finger::TYPE_INDEX )
                {
                    // Receive nided bone
                    bone        = finger.bone(Bone::TYPE_DISTAL);
                    m_vIndex    = bone.center();

                    index = true;
                }
            }
        }
    }

    bool newState;
    if( !thand || !index )
    {
        newState = false;
    }
    else
    {
        float distance = m_vThand.distanceTo(m_vIndex);
        qDebug () << "Distance: " << distance;

        if( distance < 40 )
        {
            newState = true;
        }
        else
        {
            newState = false;
        }
    }

    if( newState != m_bLastState )
    {
        Q_EMIT releySignal( newState );
        m_bLastState = newState;
    }
}
开发者ID:SergTrip,项目名称:Leap_node,代码行数:74,代码来源:simplelistener.cpp

示例8: frame

void LeapHander::frame(pugi::xml_node &frameNode){
	Leap::Frame currentFrame = m_sampleListener.frame();
	m_lock.lock();
	frameNode.append_attribute("id").set_value(currentFrame.id());
	pugi::xml_node handList = frameNode.append_child("hands");
	HandList hands = currentFrame.hands();
	
	for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
		// Get the first hand
		const Hand hand = *hl;
		pugi::xml_node handNode = handList.append_child("hand");
		handNode.append_attribute("id").set_value(hand.id());
		std::string handType;
		if (hand.isLeft()) {
			handType = "Left";
		}
		else {
			handType = "Right";
		}
		handNode.append_attribute("type").set_value(handType.c_str());
		
		pugi::xml_node positionNode = handNode.append_child("position");
		positionToXml(positionNode, hand.palmPosition());
		
		/*pugi::xml_node normalNode = handNode.append_child("normal");
		positionToXml(normalNode, hand.palmNormal());

		pugi::xml_node directionNode = handNode.append_child("direction");
		positionToXml(directionNode, hand.direction());

		pugi::xml_node rotationNode = handNode.append_child("basis");
		rotationToXml(rotationNode, hand.basis());*/
		//// Get fingers
		pugi::xml_node fingerList = handNode.append_child("fingers");
		const FingerList fingers = hand.fingers();
		for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
			const Finger finger = *fl;
			pugi::xml_node fingerNode = fingerList.append_child("finger");
			fingerNode.append_attribute("id").set_value(finger.id());
			fingerNode.append_attribute("name").set_value(fingerNames[finger.type()].c_str());
			pugi::xml_node boneList = fingerNode.append_child("bones");
			

			// Get finger bones
			for (int b = 0; b < 4; ++b) {
				Bone::Type boneType = static_cast<Bone::Type>(b);
				Bone bone = finger.bone(boneType);
				pugi::xml_node boneNode = boneList.append_child("bone");
				boneNode.append_attribute("length").set_value(bone.length());
				boneNode.append_attribute("name").set_value(boneNames[boneType].c_str());

				pugi::xml_node prevJoint = boneNode.append_child("prevJoint");
				positionToXml(prevJoint, bone.prevJoint());

				pugi::xml_node nextJoint = boneNode.append_child("nextJoint");
				positionToXml(nextJoint, bone.nextJoint());

				/*pugi::xml_node rotation = boneNode.append_child("basis");
				rotationToXml(rotation, bone.basis());*/
			}
		}
	}
	m_lock.unlock();
}
开发者ID:Lucklyric,项目名称:EM-Leap,代码行数:64,代码来源:leaphander.cpp

示例9: drawHands

void LeapBrowser::drawHands()
{
	Frame frame = leap_controller.frame();

	math::vector trans = leap_transform.translation;
	math::quater rot_quat = leap_transform.rotation;
	math::vector rot_vect = math::ln( rot_quat );
	
	double angle = rot_vect.length() * 2.0;
	math::vector axis = ( angle != 0 ? rot_vect / angle : rot_vect );

	glMatrixMode( GL_MODELVIEW );
	glPushMatrix();
	glTranslatef( trans.x(), trans.y(), trans.z() );
	if( angle != 0 )
	{
		glRotatef( angle * 180.0 / M_PI, axis.x(), axis.y(), axis.z() );
	}

	HandList hands = frame.hands();
	for( HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl )
	{
		const Hand hand = *hl;

		float joint_radius = 5.0f;
		float bone_radius = 4.5f;

		Vector prev_palm_start(0,0,0);
		Vector prev_palm_end(0,0,0);

		int f = 0;
		const FingerList fingers = hand.fingers();
		for( FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl, ++f )
		{
			const Finger finger = *fl;

			Vector curr_palm_start(0,0,0);
			Vector curr_palm_end(0,0,0);

			for( int b=0; b < 4; b++ )
			{
				Bone::Type bone_type = static_cast<Bone::Type>( b );
				Bone bone = finger.bone( bone_type );

				Vector start = bone.prevJoint();
				Vector end = bone.nextJoint();

				math::position p0( start.x, start.y, start.z );
				math::position p1( end.x, end.y, end.z );

				if( is_tracking_pose == true && finger.type() == Finger::Type::TYPE_INDEX && b==3 )
				{
					drawing_tool.setColor( 1, 0, 0, 1 );
				}
				else
				{
					drawing_tool.setColor( 0.5, 0.7, 0.5, 1 );
				}
				drawing_tool.drawSphere( p1, joint_radius );
				
				drawing_tool.setColor( 0.5, 0.7, 0.5, 1 );
				drawing_tool.drawSphere( p0, joint_radius );
				drawing_tool.drawCylinder( p0, p1, bone_radius );

				//
				if( b == 0 && fl != fingers.begin() || b == 1 && fl == fingers.begin() )
				{
					curr_palm_start = start;
					curr_palm_end = end;
				}
			}

			if( f > 1 )	//fl != fingers.begin() )
			{
				drawing_tool.setColor( 0.5, 0.7, 0.5, 1 );
				drawing_tool.applyColor();

				glBegin( GL_QUADS );
				glVertex3f( prev_palm_start.x, prev_palm_start.y, prev_palm_start.z );
				glVertex3f( prev_palm_end.x, prev_palm_end.y, prev_palm_end.z );
				glVertex3f( curr_palm_end.x, curr_palm_end.y, curr_palm_end.z );
				glVertex3f( curr_palm_start.x, curr_palm_start.y, curr_palm_start.z );
				glEnd();
			}

			prev_palm_start = curr_palm_start;
			prev_palm_end = curr_palm_end;
		}
	}

	glPopMatrix();
}
开发者ID:lumigraph,项目名称:MotionOrbits,代码行数:92,代码来源:LeapBrowser.cpp

示例10: FingerLogic

void QTVS_Leap::FingerLogic(handIndex hIndex)
{

  if (ui.checkBox_gesturesParangus->isChecked())
    ParangusGestureLogic();

  if (ui.checkBox_gesturesLeap->isChecked())
    LeapGestureLogic();

//DEBUG: Atm we cancel
  // return;

  // 0 -> 4 = left hand
  // 5 -> 9 = right hand
  // So lets use a shift and no redundant code
  int iHandToFingerShift = 0;
  if (hIndex == handRight)
    iHandToFingerShift += 5;

  for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
    const Finger finger = *fl;
    // std::cout << std::string(4, ' ') <<  fingerNames[finger.type()]
    //           << " finger, id: " << finger.id()
    //           << ", length: " << finger.length()
    //           << "mm, width: " << finger.width() << std::endl;
    Leap::Vector position = finger.stabilizedTipPosition();

    // Convert Leap::Vector position to Screen Coords
    QPoint screenPosition = FingerCursorPosition(position);


    // Lerp coords for smoothness if required
    int xCoord = lerp(fingerTraces.at(finger.type() + iHandToFingerShift)->geometry().left(), screenPosition.x(), dMouseLerpValue);
    int yCoord = lerp(fingerTraces.at(finger.type() + iHandToFingerShift)->geometry().top(), screenPosition.y(), dMouseLerpValue);

    // Qt Doesn't allow different threads to overwride gui locations.
    // Therefore, the usage of events are well, used.
    // This updates visual finger representation to correct location
    QMoveEvent *tEvent = new QMoveEvent(QPoint(xCoord, yCoord), fingerTraces.at(finger.type() + iHandToFingerShift)->pos());
    QCoreApplication::postEvent(fingerTraces.at(finger.type() + iHandToFingerShift), tEvent);

    // Z axis does NOT use stabilized position.
    // Stabilized position is generally used for X/Y movement (2D display)
    // Therefore Z is updated quite poorely. So we used unStabalized position instead
    // Setup position limits (manual testing for values
    position = finger.tipPosition();
    float zFinger = position.z < 0 ? 0 : position.z > 200 ? 200 : position.z;

    // Convert to percentages
    // trim lowerend of percentages
    zFinger /= 200;
    if (zFinger < 0.1) zFinger = 0.1;

    if (hIndex == handLeft)
    {
        if(ui.checkBox_FingerDragsWindows->isChecked())
        {
      // We're on index finger and its close to screen / center of Z-plane on leap motion
      if (finger.type() == leapIndex && zFinger < 0.12)
      {
        POINT pt;
        pt.x = screenPosition.x();
        pt.y = screenPosition.y();


        // if our rect was reset
        // Therefore, we just started to drag
        if (debugWindowDrag_Left.left == -1)
        {
          // Find window under point
          // Find window's dimmensions
          // Find difference between player's finger coords and window's coords
          debugWindowHWND_Left = GetRealParent(WindowFromPoint(pt));

          // Set it as active window if need be.
          if(debugWindowHWND_Left != GetForegroundWindow() && ui.checkBox_DragSetsActive->isChecked())
          {
            SetForegroundWindow(debugWindowHWND_Left);
            // Backup incase SetForegroundWindow fails
            // TODO: Perhaps replace in future? since foreground window DOES faile occasionally.
            // SetWindowPos(debugWindowHWND_Left,HWND_TOPMOST,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
          }

          // Restore window if maximized Section
          WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
          GetWindowPlacement(debugWindowHWND_Left, &wndpl);

          // Determine if window is maximized to begin with
          if (wndpl.showCmd == SW_MAXIMIZE)
          {
            // Setup the restore command and send it
            wndpl.showCmd = SW_RESTORE;
            SetWindowPlacement(debugWindowHWND_Left, &wndpl);

            // Center restored window around player's fingers
            int iTempWindowWidth = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
            int iTempWindowHeight = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
            MoveWindow(debugWindowHWND_Left, pt.x - iTempWindowWidth / 2, pt.y - iTempWindowHeight / 2,
                       iTempWindowWidth, iTempWindowHeight, true);
          }
//.........这里部分代码省略.........
开发者ID:Inathero,项目名称:QTVS_Leap,代码行数:101,代码来源:qtvs_leap.cpp

示例11: ParangusGestureLogic

void QTVS_Leap::ParangusGestureLogic()
{
  if (ui.checkBox_PalmForSwipes->isChecked())
  {

    Leap::Vector palmPosition = controller.frame(3).hands()[0].palmPosition();

    float previousPalmYPosAndDifference = palmPosition.y;
    float previousPalmXPosAndDifference = palmPosition.x;

    previousPalmYPosAndDifference = hand.palmPosition().y - previousPalmYPosAndDifference;
    previousPalmXPosAndDifference = hand.palmPosition().x - previousPalmXPosAndDifference;

    // std::cout << previousFingerXPosAndDifference << "\n";

    if (previousPalmYPosAndDifference < -2.5 && handCache.bGestureToggle)
    {
      std::cout << "down \n";
      handCache.bGestureToggle = false;
      QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, NULL, swipe_Down);
    }

    if (previousPalmYPosAndDifference > 2.5 && handCache.bGestureToggle)
    {
      std::cout << "swipe_Up \n";
      handCache.bGestureToggle = false;
      QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, NULL, swipe_Up);
    }

    if (previousPalmXPosAndDifference < -2.5 && handCache.bGestureToggle)
    {
      std::cout << "swipe_Left \n";
      handCache.bGestureToggle = false;
      QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, NULL, swipe_Left);
    }

    if (previousPalmXPosAndDifference > 2.5 && handCache.bGestureToggle)
    {
      std::cout << "swipe_Right \n";
      handCache.bGestureToggle = false;
      QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, NULL, swipe_Right);
    }


    if (!handCache.bGestureToggle &&
        abs(previousPalmYPosAndDifference) <= 0.5 &&
        abs(previousPalmXPosAndDifference) <= 0.5 )
      handCache.bGestureToggle = true;
    return;
  }

  // if palm for swipes isn't checked, we go for fingers instead:
  for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl)
  {
    const Finger finger = *fl;

//To simplify things down the road
    int leapFingerIndex = finger.type();

    if (finger.isExtended())
    {
      Leap::Vector fingerPosition = controller.frame(3).fingers()[leapFingerIndex].stabilizedTipPosition();

      float previousFingerYPosAndDifference = fingerPosition.y;
      float previousFingerXPosAndDifference = fingerPosition.x;

      previousFingerYPosAndDifference = finger.stabilizedTipPosition().y - previousFingerYPosAndDifference;
      previousFingerXPosAndDifference = finger.stabilizedTipPosition().x - previousFingerXPosAndDifference;

      // std::cout << previousFingerXPosAndDifference << "\n";

      if (previousFingerYPosAndDifference < -10 && handCache.fingers_p[leapFingerIndex].bGestureToggle)
      {
        handCache.fingers_p[leapFingerIndex].bGestureToggle = false;
        QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, leapFingerIndex, swipe_Down);
      }

      if (previousFingerYPosAndDifference > 10 && handCache.fingers_p[leapFingerIndex].bGestureToggle)
      {
        handCache.fingers_p[leapFingerIndex].bGestureToggle = false;
        QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, leapFingerIndex, swipe_Up);
      }

      if (previousFingerXPosAndDifference < -10 && handCache.fingers_p[leapFingerIndex].bGestureToggle)
      {
        handCache.fingers_p[leapFingerIndex].bGestureToggle = false;
        QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, leapFingerIndex, swipe_Left);
      }

      if (previousFingerXPosAndDifference > 10 && handCache.fingers_p[leapFingerIndex].bGestureToggle)
      {
        handCache.fingers_p[leapFingerIndex].bGestureToggle = false;
        QtConcurrent::run(this, &QTVS_Leap::ParangusGesture, leapFingerIndex, swipe_Right);
      }


      if (!handCache.fingers_p[leapFingerIndex].bGestureToggle &&
          abs(previousFingerYPosAndDifference) <= 0.1 &&
          abs(previousFingerXPosAndDifference) <= 0.1 )
        handCache.fingers_p[leapFingerIndex].bGestureToggle = true;
//.........这里部分代码省略.........
开发者ID:Inathero,项目名称:QTVS_Leap,代码行数:101,代码来源:qtvs_leap.cpp


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