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


C++ Hand::grabStrength方法代码示例

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


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

示例1: onFrame

void MyListener::onFrame(const Controller& controller) 
{
    const Frame frame = controller.frame();
    const GestureList gestures = frame.gestures();
    HandList hands = frame.hands();
    
    for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
        const Hand hand = *hl;
        // Smoothing and stabilization is performed in order to make this 
        // value more suitable for interaction with 2D content. The stabilized 
        // position lags behind the palm position by a variable amount, 
        // depending primarily on the speed of movement.
        Vector position = hand.stabilizedPalmPosition();

        if (m_positionChanged)
            m_positionChanged(position[0], position[1], position[2], 
                              frame.fingers().extended().count(), 
                              hand.direction(),
                              hand.palmVelocity());

        if (m_pinch)
            m_pinch(hand.pinchStrength());

        if (m_grab)
            m_grab(hand.grabStrength());
    }

    for (int g = 0; g < gestures.count(); ++g) {
        Gesture gesture = gestures[g];
        switch (gesture.type()) {
        case Gesture::TYPE_KEY_TAP:
        case Gesture::TYPE_SCREEN_TAP:
            if (m_tapped)
                m_tapped();
            break;
        case Gesture::TYPE_SWIPE:
            break;
        }
    }
}
开发者ID:xiangzhai,项目名称:leap-motion-x11,代码行数:40,代码来源:mylistener.cpp

示例2: paintGL

void Window::paintGL()
{
  // Clear
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   //LeapMotion
   bool drawflag = true;
   bool drawflag2 = true;
   if( m_controller.isConnected()) //controller is a Controller object
   {
       Frame frame = m_controller.frame(); //The latest frame
       if (!frame.hands().isEmpty())
       {
           Leap::HandList hands = frame.hands();
           Hand firstHand = hands[0];

           Leap::Vector handCenter = firstHand.palmPosition();
           m_transform.setToIdentity();
           //m_transform.rotate(180,QVector3D(0,0,-1));
           m_transform.translate(QVector3D(-handCenter.x,handCenter.y,handCenter.z));
           float yaw = firstHand.direction().yaw();
           m_transform.rotate(-(yaw/3.14)*180,QVector3D(0,-1,0));
           float roll = firstHand.palmNormal().roll();
           m_transform.rotate((roll/3.14)*180,QVector3D(0,0,-1));
           //Frame previous = controller.frame(1); //The previous frame

           if (firstHand.grabStrength()>0.5) {
               drawflag = false;

           }


           Hand secondHand = hands[1];


           Leap::Vector handCenter2 = secondHand.palmPosition();
           m_righthandtransform.setToIdentity();
           //m_transform.rotate(180,QVector3D(0,0,-1));
           m_righthandtransform.translate(QVector3D(-handCenter2.x,handCenter2.y,handCenter2.z));
           float yaw2 = secondHand.direction().yaw();
           m_righthandtransform.rotate(-(yaw2/3.14)*180,QVector3D(0,-1,0));
           float roll2 = secondHand.palmNormal().roll();
           m_righthandtransform.rotate((roll2/3.14)*180,QVector3D(0,0,-1));
           //Frame previous = controller.frame(1); //The previous frame

           if (secondHand.grabStrength()>0.5) {
               drawflag2 = false;


           }
       }
       else
       {
           m_transform.rotate(2,QVector3D(1,1,0));
           m_transform.rotate(2,QVector3D(0,1,0));
           m_transform.setTranslation(QVector3D(40,150,0));
           //m_transform.setScale(QVector3D(5,5,5));
           m_righthandtransform.rotate(2,QVector3D(0,1,0));
           m_righthandtransform.setTranslation(QVector3D(-30,150,0));
          //m_righthandtransform.setScale(QVector3D(250,250,250));
       }

   }
   else
   {
        m_transform.setTranslation(QVector3D(0,150,0));
   }
   //create dynamic enviroment mapping
   calcuSSBB(m_transform.getMatrix(),m_modelview,m_projection);
   //opencv
   Mat opencv_image = cvQueryFrame(capture);
   Mat dest;
   cvtColor(opencv_image, dest,CV_BGR2RGB);
   QImage image((uchar*)dest.data, dest.cols, dest.rows,QImage::Format_RGB888);


  //m_backTexture->bind(0);
   //m_backTexture->setData(image,QOpenGLTexture::DontGenerateMipMaps);

   //glActiveTexture(GL_TEXTURE0);
    //generate FBO



    // bind a framebuffer object
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_backfbo);
    //glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
    // Set Drawing buffers
    GLuint attachments[1] = {GL_COLOR_ATTACHMENT0};
    glDrawBuffers(1,  attachments);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glViewport(0,0,1280,720);
    //glViewport(0,0,1280*2,720*2);
    m_backTexture->bind();
    m_backTexture->load(image);
    m_backprogram->bind();
    m_backprogram->setUniformValue("ourTexture", 0);
    m_backprogram->setUniformValue(u_worldToCameraFloor, m_camera.getMatrix());
    m_backprogram->setUniformValue(u_cameraToViewFloor, m_backgroundProjection);
    if(m_back!= NULL)
    {
//.........这里部分代码省略.........
开发者ID:maxiaoniu,项目名称:ARCube,代码行数:101,代码来源:window.cpp

示例3: HandLogic

void QTVS_Leap::HandLogic()
{
  //TODO: Fix this
  if (hands.count() == 1)
  {
    int iHandToFingerShift = hand.isLeft() ? 5 : 0;

    for (int iFingerCounter = iHandToFingerShift;
         iFingerCounter <= iHandToFingerShift + 4;
         iFingerCounter ++)
      QCoreApplication::postEvent(fingerTraces.at(iFingerCounter), new QHideEvent());

    iHandToFingerShift = hand.isLeft() ? 0 : 5;

if(ui.checkBox_ShowFingers->isChecked())
{
    for (int iFingerCounter = iHandToFingerShift;
         iFingerCounter <= iHandToFingerShift + 4;
         iFingerCounter ++)
      QCoreApplication::postEvent(fingerTraces.at(iFingerCounter), new QShowEvent());
}

  }
  else if (hands.isEmpty())
  {
    foreach (FingerTraceWindow * fTrace, fingerTraces)
      QCoreApplication::postEvent(fTrace, new QHideEvent());
    // QCoreApplication::postEvent(thumbTrace, new QHideEvent());
    // QCoreApplication::postEvent(indexTrace, new QHideEvent());
    // QCoreApplication::postEvent(middleTrace, new QHideEvent());
    // QCoreApplication::postEvent(ringTrace, new QHideEvent());
    // QCoreApplication::postEvent(pinkieTrace, new QHideEvent());
  }
  else
  {
    if(ui.checkBox_ShowFingers->isChecked())
    {
    foreach (FingerTraceWindow * fTrace, fingerTraces)
      QCoreApplication::postEvent(fTrace, new QShowEvent());      
    }
    // QCoreApplication::postEvent(thumbTrace, new QShowEvent());
    // QCoreApplication::postEvent(indexTrace, new QShowEvent());
    // QCoreApplication::postEvent(middleTrace, new QShowEvent());
    // QCoreApplication::postEvent(ringTrace, new QShowEvent());
    // QCoreApplication::postEvent(pinkieTrace, new QShowEvent());

  }

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

//TODO: Perhaps move this to gestures?
    if (ui.checkBox_Crunch->isChecked())
    {
      if (hands.count() == 2)
      {
        // we check if one hand's dragging and the other's closed
        if (hand.isLeft())
        {
          // if this hand is left, and the other hand (right) is dragging something..
          if (debugWindowDrag_Right.left != -1)
          {
            debugDisplayString = QString::number(hand.grabStrength());
            //pretty much closed
            if (hand.grabStrength() >= 0.7)
            {
              SendMessage(debugWindowHWND_Right, WM_SYSCOMMAND, SC_CLOSE, 0);
              // DestroyWindow();
            }
          }
        }
        else
        {
          // if this hand is left, and the other hand (right) is dragging something..
          if (debugWindowDrag_Left.left != -1)
          {
            //pretty much closed
            if (hand.grabStrength() >= 0.7)
            {
              // DestroyWindow(debugWindowHWND_Left);
              SendMessage(debugWindowHWND_Left, WM_SYSCOMMAND, SC_CLOSE, 0);
            }
          }
        }
      }
    }
    // 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
    // debugDisplayString = QString(", palm position: " + QString(hand.palmPosition().toString().data() ));

    // debugDisplayString = QString::number(hand.palmPosition().x); //20
    // debugDisplayString.append("\n");
//.........这里部分代码省略.........
开发者ID:Inathero,项目名称:QTVS_Leap,代码行数:101,代码来源:qtvs_leap.cpp


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