本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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();
}
}
示例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;
}
}
示例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
示例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;
}
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}*/
//.........这里部分代码省略.........
示例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:
//.........这里部分代码省略.........