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


C++ Gesture类代码示例

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


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

示例1: Gesture

void CloudsVisualSystemYellowTail::selfBegin(){

    //MA: changed ofGetWidth() to getCanvasWidth() and ofGetHeight() to getCanvasHeight()
    Gesture *introGesture = new Gesture(getCanvasWidth(), getCanvasHeight());
    introGesture->fromXMLFile( getVisualSystemDataPath() + "strokes/y_stroke.xml" );
    gestures.push_back(introGesture);
}
开发者ID:SethGibson,项目名称:CLOUDS,代码行数:7,代码来源:CloudsVisualSystemYellowTail.cpp

示例2: clearGestures

//--------------------------------------------------------------
void CloudsVisualSystemYellowTail::selfInteractionStarted(CloudsInteractionEventArgs& args){
    int touchId = args.playerId;
	
	/*
	 if (neverTouchedBefore) {
	 clearGestures();
	 neverTouchedBefore = false;
	 }
	 */
	
//    if (touchId%2 == 0){
        mNewGestureStyle = GestureStyleTraveling;
//    } else {
//        mNewGestureStyle = GestureStyleInPlace;
//    } 
    
    //MA: changed ofGetWidth() to getCanvasWidth() and ofGetHeight() to getCanvasHeight()
	Gesture *newGesture = new Gesture(getCanvasWidth(), getCanvasHeight());
	newGesture->clear();
	newGesture->clearPolygons();
	newGesture->addPoint((float)args.position.x, (float)args.position.y);
	newGesture->setStyle(mNewGestureStyle);
    
    potentialGestures.insert(newGesture);
    
    gestureForTouch[touchId] = newGesture;
}
开发者ID:SethGibson,项目名称:CLOUDS,代码行数:28,代码来源:CloudsVisualSystemYellowTail.cpp

示例3: data

vector<double> GestureHMM::train(vector< Gesture* > train_set, int max_iter) {

	this->_trainset = train_set;

	field<rowvec> data(train_set.size(),1);
	vector< Gesture* >::const_iterator iter;
	int r = 0;
	for ( iter = train_set.begin(); iter != train_set.end(); ++iter ) {
		Gesture * g = *iter;
		vector<int> x = g->labels();
		data(r++,0) = conv_to< rowvec >::from(g->labels());
	}

	return HMM::train(data, max_iter);
}
开发者ID:nkint,项目名称:GestureRecognizer,代码行数:15,代码来源:GestureHMM.cpp

示例4: selfInteractionDragged

//--------------------------------------------------------------
void CloudsVisualSystemYellowTail::selfInteractionDragged(CloudsInteractionEventArgs& args){
    int touchId = args.playerId;
	
    map<int,Gesture *>::iterator G = gestureForTouch.find(touchId);
	//JG removed asserts as they are a stability problem
//    assert(G != gestureForTouch.end());
	if(G == gestureForTouch.end()){
		return;
	}
    Gesture *gesture = G->second;
    
    if (gesture->distanceToLastPoint((float)args.position.x, (float)args.position.y) > minimumTravelForNewPoint) {
        
        float distanceThresholdForAdding = minimumTravelForNewPoint * 8.0;
        if (gesture->pointCount > 10){ distanceThresholdForAdding = minimumTravelForNewPoint * 2.0;}
        gesture->addPointAndHalfwayPoint((float)args.position.x, (float)args.position.y, distanceThresholdForAdding);
        
        gesture->smooth(22.0);
        gesture->compile();
    }
}
开发者ID:SethGibson,项目名称:CLOUDS,代码行数:22,代码来源:CloudsVisualSystemYellowTail.cpp

示例5: selfInteractionEnded

//--------------------------------------------------------------
void CloudsVisualSystemYellowTail::selfInteractionEnded(CloudsInteractionEventArgs& args){
    int touchId = args.playerId;
	
    map<int,Gesture *>::iterator G = gestureForTouch.find(touchId);
    	//JG removed asserts as they are a stability problem
	//assert(G != gestureForTouch.end());
	if(G == gestureForTouch.end()){
		return;
	}
    
	Gesture *gesture = G->second;
    
    gestureForTouch.erase(G);
    potentialGestures.erase(find(potentialGestures.begin(), potentialGestures.end(), gesture));
    
    if (gesture->isValid()) {
        gestures.push_back(gesture);
    } else {
        delete gesture;
    }
}
开发者ID:SethGibson,项目名称:CLOUDS,代码行数:22,代码来源:CloudsVisualSystemYellowTail.cpp

示例6: if

void Parser::sGesture() {
    if (m_reader.isEndElement() && m_reader.name() == "gesture") {
        state.removeLast();
        return;
    } else if (m_reader.isStartElement() && m_reader.name() == "action") {
        state.append("ACTION");
        auto attrs = m_reader.attributes();
        if (!attrs.hasAttribute("type"))
            throw(err("Attribute 'type' expected."));

        Group *g = Memory::getGroup(appKey);
        g->addGest(ges->num, Lists::gT(ges->type), Lists::gD(ges->direction));
        Gesture *gest = g->getGest(ges->num, Lists::gT(ges->type), Lists::gD(ges->direction));
        gest->setAction(Lists::aT(attrs.value("type").toString()));
        //sAction(g->getGest(ges->num, Lists::gT(ges->type), Lists::gD(ges->direction))->getAction());->setAction(Lists::aT(attrs.value("type").toString()))
        QStringList params = m_reader.readElementText().split(":");
        foreach(const QString &p, params)
            gest->getAction()->addParam(p.section("=",0,0),p.section("=",1));

        state.removeLast();
    } else
开发者ID:f3r,项目名称:Touchegg-gce,代码行数:21,代码来源:parser.cpp

示例7: m_positionChanged

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

示例8: save

// TODO : move to an external class (kind of serialization factory)
void GestureHMM::save(string filename) {
	Gesture *g;
	stringstream ss;
	fix_stream(ss);
	ofxXmlSettings XML;

	XML.clear();

	XML.addValue("name", name);

	XML.addValue("alphabet", alphabet);
	XML.addValue("hiddenStates", hiddenStates);

	XML.addValue( "prior", matrix_to_string(prior) );
	XML.addValue( "transmat", matrix_to_string(transmat) );
	XML.addValue( "obsmat", matrix_to_string(obsmat) );

	XML.addTag("gestures");
	XML.pushTag("gestures");

	int trainset_size = _trainset.size();
	for (int i = 0; i < trainset_size; ++i) {
		g = _trainset[i];

		XML.addTag("train_gestures");
		XML.addAttribute("train_gestures","num",i, i);

		XML.pushTag("train_gestures", i);
		{
			XML.addValue("labeled", to_string(g->labels()));
			XML.addValue("raw", to_string( g->points()) );
		}
		XML.popTag();
	}
	XML.popTag();

	XML.saveFile(filename);
}
开发者ID:nkint,项目名称:GestureRecognizer,代码行数:39,代码来源:GestureHMM.cpp

示例9: main

int main()
{
  GestureDB db("gesture_data.db");
  db.load();

  //cout<<*db<<endl;
  /// fetch the 7th gesture
  Gesture* gesture = db[7];
  cout<<*gesture<<endl;
  cout<<gesture->numPoint();

  gesture->filter();
  //cout<<gesture->numPoint();

  gesture->sample(17);
  cout<<*gesture<<endl;

  cout<<"similarity score"<<smith_waterman(gesture, gesture)<<endl;

  //db.save();

  return 0;
}
开发者ID:darthsuogles,项目名称:GestureUI,代码行数:23,代码来源:test.cpp

示例10: sin

void Quantizer2::init(Gesture gesture){

    radius = (gesture.getMaxacc() + gesture.getMinacc()) / 2;

    double pi = M_PI;

    // inizializza i centroidi
    centroids[0] = Sample_3d(radius, 0, 0);
    centroids[1] = Sample_3d(cos(pi/4)*radius, 0, sin(pi/4)*radius);
    centroids[2] = Sample_3d(0, 0, radius);
    centroids[3] = Sample_3d(cos(pi*3/4)*radius, 0, sin(pi*3/4)*radius);
    centroids[4] = Sample_3d(-radius, 0, 0);
    centroids[5] = Sample_3d(cos(pi*5/4)*radius, 0, sin(pi*5/4)*radius);
    centroids[6] = Sample_3d(0, 0, -radius);
    centroids[7] = Sample_3d(cos(pi*7/4)*radius, 0, sin(pi*7/4)*radius);
    centroids[8] = Sample_3d(0, radius, 0);
    centroids[9] = Sample_3d(0, cos(pi/4)*radius, sin(pi/4)*radius);
    centroids[10] = Sample_3d(0, cos(pi*3/4)*radius, sin(pi*3/4)*radius);
    centroids[11] = Sample_3d(0, -radius, 0);
    centroids[12] = Sample_3d(0, cos(pi*5/4)*radius, sin(pi*5/4)*radius);
    centroids[13] = Sample_3d(0, cos(pi*7/4)*radius, sin(pi*7/4)*radius);

}
开发者ID:valdar,项目名称:wiigesture,代码行数:23,代码来源:quantizer2.cpp

示例11: noDetect

std::string& DTWRecognizer::decideGesture(std::vector<Recognition *>& recognitionArray, std::vector<Ogre::Vector3>& inputPattern)
{
  float minDistance = numeric_limits<float>::max();
  Recognition *minRecog = NULL;
  int minNumSamples;
  static std::string noDetect("NO_DETECT");

  std::vector<Recognition *>::iterator itr1 = recognitionArray.begin();


  for ( ; itr1 != recognitionArray.end(); itr1++)
  {
      Recognition *dataRecog = *itr1;
      std::vector<Gesture *>::iterator itr2 = dataRecog->getGestureArray().begin();
      for ( ; itr2 != dataRecog->getGestureArray().end(); itr2++)
      {
          Gesture *dataGesture = *itr2;
          SimpleDTW<Ogre::Vector3>  dtw(inputPattern, dataGesture->getLocalAccelerationArray(), ptr_fun(ogreVectorLength));
          float result = dtw.calculateDistance();
          PRINTF("(%10s(%2d)<-->Input(%2d) : %f", 
              dataRecog->getName().c_str(), dataGesture->getLocalAccelerationArray().size(),
              inputPattern.size(), result);
          if (result < minDistance) 
          {
              minDistance = result;
              minRecog = dataRecog;
              minNumSamples = dataGesture->getLocalAccelerationArray().size();
          }
      }
  }

  PRINTF("DECISION: %10s(%2d, %2d)(distance:%5.1f)", minRecog->getName().c_str(), minNumSamples, inputPattern.size(), minDistance);

  return minRecog->getName();

  return (minDistance < 256.0f ? minRecog->getName() : noDetect);
}
开发者ID:parkkeunhyeok,项目名称:OGRE3D-1,代码行数:37,代码来源:DTWRecognizer.cpp

示例12: distance

std::vector<int> Quantizer2::getDiscreteSequence(Gesture& gesture){

    this->init(gesture);
    std::vector<Sample_3d> data = gesture.getData();
    int size = data.size();

    // associazioni (componente della gesture) <-> centroide
    std::vector<int> assoc;
    for(int i=0; i<size; i++)
        assoc.push_back(-1);

    // n° vettori associati a ciascun centroide
    int numVectPerCentroid[n_centroids];
    for(int i=0; i<n_centroids; i++ )
        numVectPerCentroid[i] = 0;


    // determina centroide a distanza minima per ogni vettore
    for(int i=0; i<size; i++){

        // minima distanza finora riscontrata
        double min_dist = std::numeric_limits<double>::max();
        // centroide a minima distanza
        int centroid_count = -1;

        for(int j=0; j<n_centroids; j++){

            // calcola la distanza dell'elemento dal centroide corrente
            double d = distance(data.at(i), centroids[j]);

            // se la nuova distanza è minore della minima finora riscontrata,
            // allora il centroide è il più vicino
            if(d < min_dist){
                min_dist = d;
                centroid_count = j;
            }

        }//j

        // associa il sample al centroide più vicino
        if(assoc.at(i) != centroid_count){
            assoc.at(i) = centroid_count;
        }
    }//i

    return assoc;

}
开发者ID:valdar,项目名称:wiigesture,代码行数:48,代码来源:quantizer2.cpp

示例13: qDebug

Gesture *GestureHandler::createGesture(const QString &type, int id, const QHash<QString, QVariant>& attrs,
    bool isComposedGesture) const
{
    // Creamos el gesto sin su acción
    Gesture *ret;
    if (isComposedGesture)
        ret = this->gestureFact->createComposedGesture(type, id, attrs);
    else
        ret = this->gestureFact->createSimpleGesture(type, id, attrs);

    if (ret == NULL)
        return NULL;

    // Vemos sobre que ventana se ha ejecutado
    Window gestureWindow = this->getGestureWindow(attrs.value(GEIS_GESTURE_ATTRIBUTE_CHILD_WINDOW_ID).toInt());
    if (gestureWindow == None)
        return NULL;
    QString appClass = this->getAppClass(gestureWindow);

    // Creamos y asignamos la acción asociada al gesto
    ActionTypeEnum::ActionType actionType = this->config->getAssociatedAction(appClass, ret->getType(),
            ret->getNumFingers(), ret->getDirection());
    QString actionSettings = this->config->getAssociatedSettings(appClass, ret->getType(), ret->getNumFingers(),
            ret->getDirection());

    ret->setAction(this->actionFact->createAction(actionType, actionSettings, gestureWindow));

    // Mostramos los datos sobre el gesto
    qDebug() << "[+] New gesture:";
    qDebug() << "\tType      -> " << GestureTypeEnum::getValue(ret->getType());
    qDebug() << "\tFingers   -> " << ret->getNumFingers();
    qDebug() << "\tDirection -> " << GestureDirectionEnum::getValue(ret->getDirection());
    qDebug() << "\tAction    -> " << ActionTypeEnum::getValue(actionType);
    qDebug() << "\tApp Class -> " << appClass;

    return ret;
}
开发者ID:WilliamDCLT,项目名称:linux_config,代码行数:37,代码来源:GestureHandler.cpp

示例14: switch

void Leap::LeapListener::onFrame( const Controller& controller )
{
	Frame frame = controller.frame();
	HandList hands = frame.hands();
	Leap::DirectionDetector::Direction direction;
	//bool handExtended;
	Hand leftHand;
	Hand rightHand;

	//jurik
	//takin just first gesture (gestures are defined for each finger)
	Gesture gesture = frame.gestures()[0];


	if ( arMode ) {
		for ( int i=0; i< hands.count(); ++i ) {
			if ( hands[i].isRight() ) {
				rightHand = hands[i];
			}
			else {
				leftHand = hands[i];
			}
		}
		leapActions->updateARHands( leftHand,rightHand );
	}
	else {
		for ( int i=0; i< hands.count(); ++i ) {
			if ( hands[i].isRight() ) {
				direction = Leap::DirectionDetector::getPalmDirection( hands[i] );
				//using cameramanipulator
				//leapActions->changeViewAngle( direction );
				//using pickhandler class
				leapActions->rotateAruco( direction );

				if ( gesture.type() == Gesture::TYPE_KEY_TAP ) {
					leapActions->scaleNodes( true );
				}
			}
			else {
				direction = Leap::DirectionDetector::getPalmDirection( hands[i] );
				//leapActions.changeViewAngle( direction );
				leapActions->scaleEdges( direction );
				if ( gesture.type() == Gesture::TYPE_KEY_TAP ) {
					leapActions->scaleNodes( false );
				}

				/*handExtended = Leap::FingerPositionDetector::isHandExtended( hands[i] );
				if ( handExtended ) {
					leapActions->startMovingForward();
				}
				else {
					leapActions->stopMovingForward();
				}*/
			}
		}
	}

	//std::cout << "id: " << frame.id();
	/*
	    const GestureList gestures = frame.gestures();
	      for (int g = 0; g < gestures.count(); ++g) {
	        Gesture gesture = gestures[g];

	        HandList hands = gesture.hands();
	        Hand firstHand = hands[0];

	        switch (gesture.type()) {
	          case Gesture::TYPE_CIRCLE:
	          {
				leapActions->zoomGraph(gesture);
	            break;
	          }
	          case Gesture::TYPE_SWIPE:
	          {
	            if(firstHand.isRight()){
					if(leapActions->isCameraMoving)
						leapActions->moveCamera(gesture);
	                else
					  leapActions->rotateGraph(gesture);
	            }
	            break;
	          }
	          case Gesture::TYPE_KEY_TAP:
	          {
	            if(firstHand.isLeft())
					leapActions->onKeyTap(gesture);
	            break;
	          }
	          case Gesture::TYPE_SCREEN_TAP:
	          {
				leapActions->onScreenTap(gesture);
	            break;
	          }
	          default:
	            qDebug() << "Unknown gesture type.";
	            break;
	        }
	      }*/


//.........这里部分代码省略.........
开发者ID:kapecp,项目名称:3dsoftviz,代码行数:101,代码来源:LeapListener.cpp

示例15: switch

void SampleListener::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()
            << ", fingers: " << frame.fingers().count()
            << ", tools: " << frame.tools().count()
            << ", gestures: " << frame.gestures().count() << std::endl;

  if (!frame.hands().isEmpty()) {
    // Get the first hand
    const Hand hand = frame.hands()[0];

    // Check if the hand has any fingers
    const FingerList fingers = hand.fingers();
    if (!fingers.isEmpty()) {
      // Calculate the hand's average finger tip position
      Vector avgPos;
      for (int i = 0; i < fingers.count(); ++i) {
        avgPos += fingers[i].tipPosition();
      }
      avgPos /= (float)fingers.count();
      std::cout << "Hand has " << fingers.count()
                << " fingers, average finger tip position" << avgPos << std::endl;
    }

    // Get the hand's sphere radius and palm position
    std::cout << "Hand sphere radius: " << hand.sphereRadius()
              << " mm, 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 << "Hand pitch: " << direction.pitch() * RAD_TO_DEG << " degrees, "
              << "roll: " << normal.roll() * RAD_TO_DEG << " degrees, "
              << "yaw: " << direction.yaw() * RAD_TO_DEG << " degrees" << 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/4) {
          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 << "Circle id: " << gesture.id()
                  << ", state: " << 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 << "Swipe id: " << gesture.id()
          << ", state: " << gesture.state()
          << ", direction: " << swipe.direction()
          << ", speed: " << swipe.speed() << std::endl;
        break;
      }
      case Gesture::TYPE_KEY_TAP:
      {
        KeyTapGesture tap = gesture;
        std::cout << "Key Tap id: " << gesture.id()
          << ", state: " << gesture.state()
          << ", position: " << tap.position()
          << ", direction: " << tap.direction()<< std::endl;
        break;
      }
      case Gesture::TYPE_SCREEN_TAP:
      {
        ScreenTapGesture screentap = gesture;
        std::cout << "Screen Tap id: " << gesture.id()
        << ", state: " << gesture.state()
        << ", position: " << screentap.position()
        << ", direction: " << screentap.direction()<< std::endl;
        break;
      }
      default:
//.........这里部分代码省略.........
开发者ID:Zandrr,项目名称:Leap,代码行数:101,代码来源:Tests.cpp


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