本文整理汇总了C++中Gesture::state方法的典型用法代码示例。如果您正苦于以下问题:C++ Gesture::state方法的具体用法?C++ Gesture::state怎么用?C++ Gesture::state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gesture
的用法示例。
在下文中一共展示了Gesture::state方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
//.........这里部分代码省略.........
示例2: onFrame
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:
//.........这里部分代码省略.........
示例3: m_bang
//.........这里部分代码省略.........
SETSYMBOL(&fingerInfo[3], gensym("direction"));
SETFLOAT(&fingerInfo[4], finger.direction().x);
SETFLOAT(&fingerInfo[5], finger.direction().y);
SETFLOAT(&fingerInfo[6], finger.direction().z);
ToOutAnything(1, gensym("hand"), 7, fingerInfo);
}
if(fingers_position_flag){
SETFLOAT(&fingerInfo[0], i); // index
SETSYMBOL(&fingerInfo[1], gensym("fingers"));
SETFLOAT(&fingerInfo[2], j);
SETSYMBOL(&fingerInfo[3], gensym("position"));
SETFLOAT(&fingerInfo[4], finger.tipPosition().x);
SETFLOAT(&fingerInfo[5], finger.tipPosition().y);
SETFLOAT(&fingerInfo[6], finger.tipPosition().z);
ToOutAnything(1, gensym("hand"), 7, fingerInfo);
}
if(fingers_velocity_flag){
SETFLOAT(&fingerInfo[0], i); // index
SETSYMBOL(&fingerInfo[1], gensym("fingers"));
SETFLOAT(&fingerInfo[2], j);
SETSYMBOL(&fingerInfo[3], gensym("velocity"));
SETFLOAT(&fingerInfo[4], finger.tipVelocity().x);
SETFLOAT(&fingerInfo[5], finger.tipVelocity().y);
SETFLOAT(&fingerInfo[6], finger.tipVelocity().z);
ToOutAnything(1, gensym("hand"), 7, fingerInfo);
}
if(fingers_size_flag){
SETFLOAT(&fingerInfo[0], i); // index
SETSYMBOL(&fingerInfo[1], gensym("fingers"));
SETFLOAT(&fingerInfo[2], j);
SETSYMBOL(&fingerInfo[3], gensym("size"));
SETFLOAT(&fingerInfo[4], finger.width());
SETFLOAT(&fingerInfo[5], finger.length());
ToOutAnything(1, gensym("hand"), 6, fingerInfo);
}
}
}
t_atom gestureCountInfo[1];
for(int i = 0;i < num_gestures; i++){
Gesture gesture;
gesture = frame.gestures()[i];
//type
t_atom gestureTypeInfo[3];
SETFLOAT(&gestureTypeInfo[0], i);
SETSYMBOL(&gestureTypeInfo[1], gensym("type"));
switch(gesture.type())
{
case Gesture::TYPE_INVALID:
SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_INVALID"));
break;
case Gesture::TYPE_SWIPE:
SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_SWIPE"));
break;
case Gesture::TYPE_CIRCLE:
SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_CIRCLE"));
break;
case Gesture::TYPE_SCREEN_TAP:
SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_SCREEN_TAP"));
break;
case Gesture::TYPE_KEY_TAP:
SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_KEY_TAP"));
break;
}
ToOutList(2, 3, gestureTypeInfo);
//state
t_atom gestureStateInfo[3];
SETFLOAT(&gestureStateInfo[0], i);
SETSYMBOL(&gestureStateInfo[1], gensym("state"));
switch(gesture.state())
{
case Gesture::STATE_INVALID:
SETSYMBOL(&gestureStateInfo[2], gensym("STATE_INVALID"));
break;
case Gesture::STATE_START:
SETSYMBOL(&gestureStateInfo[2], gensym("TYPE_START"));
break;
case Gesture::STATE_UPDATE:
SETSYMBOL(&gestureStateInfo[2], gensym("STATE_UPDATE"));
break;
case Gesture::STATE_STOP:
SETSYMBOL(&gestureStateInfo[2], gensym("TYPE_STOP"));
break;
}
ToOutList(2, 3, gestureStateInfo);
t_atom gestureDurationInfo[3];
SETFLOAT(&gestureDurationInfo[0], i);
SETSYMBOL(&gestureDurationInfo[1], gensym("duration"));
SETFLOAT(&gestureDurationInfo[2], gesture.duration());
ToOutList(2, 3, gestureDurationInfo);
t_atom gestureIdInfo[3];
SETFLOAT(&gestureIdInfo[0], i);
SETSYMBOL(&gestureIdInfo[1], gensym("id"));
SETFLOAT(&gestureIdInfo[2], gesture.id());
ToOutList(2, 3, gestureIdInfo);
}
}
示例4: sendGesture
/*----------------------------------------------------------------------------------------------------*/
void Gestures::sendGesture(const Gesture& pGesture) {
if ( !pGesture.isValid() ) {
return;
}
Gesture::Type type = pGesture.type();
Gesture::State state = pGesture.state();
int64_t duration = pGesture.duration();
Leap::Vector position;
Leap::Vector direction;
float progress = 0;
float speed = 0;
float radius = 0;
std::string typeKey;
std::string stateName;
////
if ( type == Gesture::TYPE_CIRCLE ) {
CircleGesture circle = (CircleGesture)pGesture;
position = circle.center();
progress = circle.progress();
radius = circle.radius();
typeKey = GestureKey::Circle;
}
else if ( type == Gesture::TYPE_SWIPE ) {
SwipeGesture swipe = (SwipeGesture)pGesture;
position = swipe.startPosition();
direction = swipe.direction();
speed = swipe.speed();
typeKey = GestureKey::Swipe;
}
else if ( type == Gesture::TYPE_KEY_TAP ) {
KeyTapGesture keyTap = (KeyTapGesture)pGesture;
position = keyTap.position();
direction = keyTap.direction();
progress = keyTap.progress();
typeKey = GestureKey::KeyTap;
}
else if ( type == Gesture::TYPE_SCREEN_TAP ) {
ScreenTapGesture screenTap = (ScreenTapGesture)pGesture;
position = screenTap.position();
direction = screenTap.direction();
progress = screenTap.progress();
typeKey = GestureKey::ScreenTap;
}
else {
std::cout << "[LEAP] Unsupported gesture type: " << type << std::endl;
return;
}
////
switch ( state ) {
case Gesture::STATE_INVALID:
stateName = "Invalid";
break;
case Gesture::STATE_START:
stateName = "Start";
break;
case Gesture::STATE_UPDATE:
stateName = "Update";
break;
case Gesture::STATE_STOP:
stateName = "Stop";
break;
default:
std::cout << "[LEAP] Unsupported state type: " << state << std::endl;
return;
}
////
std::cout << "GESTURE MESSAGE" <<
"\n - type: " << type << " (" << typeKey << ")" <<
"\n - stat: " << state << " (" << stateName << ")" <<
"\n - dura: " << duration <<
"\n - pos: " << position <<
"\n - dir: " << direction <<
"\n - prog: " << progress <<
"\n - radi: " << radius <<
"\n - spd: " << speed <<
"\n" << std::endl;
}
示例5: onFrame
void QLeapEventListener::onFrame(const Controller & controller)
{
const Frame frame = controller.frame();
// 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;
onSwipe(swipe);
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:
std::cout << "Unknown gesture type." << std::endl;
break;
}
}
}
示例6: onFrame
//.........这里部分代码省略.........
bundle.addMessage(m);
alive.addIntArg(fingers[i].id()); // add blob to list of ALL active IDs
}
}
}
#ifdef INIT_BBOX
std::cout << "min: " << bboxMin << std::endl;
std::cout << "max: " << bboxMax << std::endl;
#endif
}
#if 0
// Get the hand's sphere radius and palm position
std::cout << "Hand sphere radius: " << hand.sphereRadius()
<< " mm, palm position: " << hand.palmPosition() << std::endl;
#endif
// Get the hand's normal vector and direction
const Vector normal = hand.palmNormal();
const Vector direction = hand.direction();
#if 0
// 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;
#endif
}
bundle.addMessage(alive);
bundle.addMessage(fseq);
tuioSender.sendBundle(bundle);
// Get 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:
std::cout << "Unknown gesture type." << std::endl;
break;
}
}
#if 0
if (!hands.empty() || !gestures.empty()) {
std::cout << std::endl;
}
#endif
}
示例7: getFrame
//.........这里部分代码省略.........
} else {
FREGetObjectProperty(freHand, (const uint8_t*) "fingers", &freSpecificHandPointables, NULL);
}
uint32_t numSpecificHandTools;
FREGetArrayLength(freSpecificHandPointables, &numSpecificHandTools);
FRESetArrayElementAt(freSpecificHandPointables, numSpecificHandTools, frePointable);
}
//push it in current frame
FRESetArrayElementAt(frePointables, i, frePointable);
//specific
FREObject freSpecificPointables;
if(pointable.isTool()) {
FREGetObjectProperty(freCurrentFrame, (const uint8_t*) "tools", &freSpecificPointables, NULL);
} else {
FREGetObjectProperty(freCurrentFrame, (const uint8_t*) "fingers", &freSpecificPointables, NULL);
}
uint32_t numSpecificTools;
FREGetArrayLength(freSpecificPointables, &numSpecificTools);
FRESetArrayElementAt(freSpecificPointables, numSpecificTools, frePointable);
frePointablesMap[pointable.id()] = frePointable;
}
}
if(!frame.gestures().empty()) {
FREObject freGestures;
FREGetObjectProperty(freCurrentFrame, (const uint8_t*) "gesturesVector", &freGestures, NULL);
for(int i = 0; i < frame.gestures().count(); i++) {
const Gesture gesture = frame.gestures()[i];
int state;
switch (gesture.state()) {
case Gesture::STATE_INVALID:
state = 0;
break;
case Gesture::STATE_START:
state = 1;
break;
case Gesture::STATE_UPDATE:
state = 2;
break;
case Gesture::STATE_STOP:
state = 3;
break;
default:
break;
}
int type;
FREObject freGesture;
switch (gesture.type()) {
case Gesture::TYPE_SWIPE:
{
type = 5;
SwipeGesture swipe = gesture;
FRENewObject( (const uint8_t*) "com.leapmotion.leap.SwipeGesture", 0, NULL, &freGesture, NULL);
FRESetObjectProperty(freGesture, (const uint8_t*) "direction", createVector3(swipe.direction().x, swipe.direction().y, swipe.direction().z), NULL);
FRESetObjectProperty(freGesture, (const uint8_t*) "position", createVector3(swipe.position().x, swipe.position().y, swipe.position().z), NULL);
FRESetObjectProperty(freGesture, (const uint8_t*) "startPosition", createVector3(swipe.startPosition().x, swipe.startPosition().y, swipe.startPosition().z), NULL);
示例8: onFrame
void LeapInput::onFrame(const Controller& controller)
{
Frame frame = controller.frame();
HandList hands = frame.hands();
this->hands = hands.count();
if(hands.count() == 2)
{
Hand leftHand = hands.leftmost();
Hand rightHand = hands.rightmost();
leftHandY = leftHand.palmPosition().y;
rightHandY = rightHand.palmPosition().y;
leftFingers = leftHand.fingers().count();
rightFingers = rightHand.fingers().count();
float threshold = tanf(5* 3.141592f / 180.0f);
float maxTan = tanf(45 * 3.141592f / 180.0f);
if(leftHand.palmPosition().x != rightHand.palmPosition().x){
float tanValue = fabs((leftHand.palmPosition().y - rightHand.palmPosition().y) / (leftHand.palmPosition().x - rightHand.palmPosition().x));
if(tanValue > threshold){
curve = tanValue / maxTan;
if(curve > 1)
curve = 1;
}else
curve = 0;
}else
curve = 0;
}
else
{
leftHandY = rightHandY = 0;
}
boost = false;
GestureList gestureList = frame.gestures();
for(GestureList::const_iterator i = gestureList.begin(); i != gestureList.end(); ++i)
{
Gesture gesture = *i;
if(gesture.state() != Gesture::State::STATE_INVALID)
{
switch(gesture.type())
{
case Gesture::Type::TYPE_SCREEN_TAP:
boost = true;
break;
}
}
}
back = false;
if(hands.count() == 2 && leftFingers == 1 && rightFingers == 1 &&
hands.leftmost().fingers()[0].direction().z > 0 &&
hands.rightmost().fingers()[0].direction().z > 0)
{
back = true;
}
//accelGesture = brakeGesture = false;
//GestureList gestureList = frame.gestures();
//for(GestureList::const_iterator i = gestureList.begin(); i != gestureList.end(); ++i)
//{
// Gesture gesture = *i;
// if(gesture.state() != Gesture::State::STATE_INVALID)
// {
// if(typeid(gesture) == typeid(MyGesture))
// {
// accelGesture = true;
// }
//
// }
//}
}
示例9: LeapGestureLogic
void QTVS_Leap::LeapGestureLogic()
{
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g];
switch (gesture.type()) {
case Gesture::TYPE_CIRCLE:
{
// emit Listener_Gesture(gesture, gesture.type());
CircleGesture circle = gesture;
std::string clockwiseness;
if (circle.pointable().direction().angleTo(circle.normal()) <= PI / 2) {
clockwiseness = "clockwise";
// MouseKeyboardEmulation::MouseWheelDown(5);
} else {
clockwiseness = "counterclockwise";
// MouseKeyboardEmulation::MouseWheelUp(5);
}
// 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;
// debugDisplayString = "";
// debugDisplayString.append("Swipe id: " + QString::number(gesture.id()));
// debugDisplayString.append( ", state: " + QString(stateNames[gesture.state()].data()));
// debugDisplayString.append( ", direction: " + QString(swipe.direction().toString().data()));
// debugDisplayString.append( ", speed: " + QString::number(swipe.speed()));
std::cout << std::string(2, ' ')
<< "Swipe id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", direction: " << swipe.direction()
<< ", speed: " << swipe.speed() << std::endl;
break;
}
case Gesture::TYPE_KEY_TAP:
{
KeyTapGesture tap = gesture;
// std::cout << std::string(2, ' ')
//debugDisplayString = "";
// debugDisplayString.append("Key Tap id: " + QString::number(gesture.id()));
// debugDisplayString.append( ", state: " + QString(stateNames[gesture.state()].data()));
//debugDisplayString.append( ", position: " + QString(tap.position().toString().data()));
// debugDisplayString.append( ", direction: " + QString(tap.direction().toString().data()));
break;
}
case Gesture::TYPE_SCREEN_TAP:
{
ScreenTapGesture screentap = gesture;
std::cout << std::string(2, ' ')
<< "Screen Tap id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", position: " << screentap.position()
<< ", direction: " << screentap.direction() << std::endl;
break;
}
default:
std::cout << std::string(2, ' ') << "Unknown gesture type." << std::endl;
break;
}
}
if (!frame.hands().isEmpty() || !gestures.isEmpty()) {
std::cout << std::endl;
}
}