本文整理汇总了C++中leap::Controller::enableGesture方法的典型用法代码示例。如果您正苦于以下问题:C++ Controller::enableGesture方法的具体用法?C++ Controller::enableGesture怎么用?C++ Controller::enableGesture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leap::Controller
的用法示例。
在下文中一共展示了Controller::enableGesture方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Setup
void LeapController::Setup()
{
resetInitParams();
if (leapDevice && leapDevice->isConnected()) return;
leapDevice = Device::create();
leapDevice->connectEventHandler( &LeapController::onFrame, this );
// Enable all gesture types
Leap::Controller* controller = leapDevice->getController();
controller->enableGesture( Leap::Gesture::Type::TYPE_SWIPE );
controller->enableGesture( Leap::Gesture::Type::TYPE_CIRCLE );
// Write gesture config to console
Leap::Config config = controller->config();
// Update config to make gestures easier
config.setFloat( "Gesture.Swipe.MinLength", 30.0f );
config.setFloat( "Gesture.Swipe.MinVelocity", 100.0f );
config.save();
App::get()->getSignalShutdown().connect(bind(&LeapController::Shutdown, this));
App::get()->getSignalUpdate().connect(bind(&LeapController::Update, this));
}
示例2: enableGest
void LeapMotionHandler::enableGest(Leap::Controller controller)
{
controller.enableGesture(Leap::Gesture::TYPE_SWIPE);
controller.enableGesture(Leap::Gesture::TYPE_CIRCLE);
controller.enableGesture(Leap::Gesture::TYPE_SCREEN_TAP);
controller.enableGesture(Leap::Gesture::TYPE_KEY_TAP);
}
示例3: onConnect
void LeapListener::onConnect(const Leap::Controller& controller) {
std::cout << "Connected";
controller.enableGesture(Leap::Gesture::TYPE_CIRCLE);
controller.enableGesture(Leap::Gesture::TYPE_KEY_TAP);
controller.enableGesture(Leap::Gesture::TYPE_SCREEN_TAP);
controller.enableGesture(Leap::Gesture::TYPE_SWIPE);
}
示例4: onConnect
void LeapMotionListener::onConnect(const Leap::Controller & controller)
{
qDebug()<<"Connected Leap Motion";
controller.enableGesture(Leap::Gesture::TYPE_CIRCLE);
controller.enableGesture(Leap::Gesture::TYPE_KEY_TAP);
controller.enableGesture(Leap::Gesture::TYPE_SCREEN_TAP);
controller.enableGesture(Leap::Gesture::TYPE_SWIPE);
}
示例5: bounds
GestureApp::GestureApp()
{
mBackgroundBrightness = 0.0f;
mBackgroundColor = Colorf( 0.0f, 0.1f, 0.2f );
mCircleResolution = 32;
mDialBrightness = 0.0f;
mDialPosition = vec2( 155.0f, 230.0f );
mDialRadius = 120.0f;
mDialSpeed = 0.21f;
mDialValue = 0.0f;
mDialValueDest = mDialValue;
mDotRadius = 3.0f;
mDotSpacing = mDotRadius * 3.0f;
mFadeSpeed = 0.95f;
mKeySpacing = 25.0f;
mKeyRect = Rectf( mKeySpacing, 360.0f + mKeySpacing, 600.0f, 600.0f );
mKeySize = 60.0f;
mPointableRadius = 15.0f;
mSwipeBrightness = 0.0f;
mSwipePos = 0.0f;
mSwipePosDest = mSwipePos;
mSwipePosSpeed = 0.33f;
mSwipeRect = Rectf( 310.0f, 100.0f, 595.0f, 360.0f );
mSwipeStep = 0.033f;
resize();
// Lay out keys
float spacing = mKeySize + mKeySpacing;
for ( float y = mKeyRect.y1; y < mKeyRect.y2; y += spacing ) {
for ( float x = mKeyRect.x1; x < mKeyRect.x2; x += spacing ) {
Rectf bounds( x, y, x + mKeySize, y + mKeySize );
Key key( bounds );
mKeys.push_back( key );
}
}
mDevice = Device::create();
mDevice->connectEventHandler( [ & ]( Leap::Frame frame )
{
mFrame = frame;
} );
// Enable gesture types
Leap::Controller* controller = mDevice->getController();
controller->enableGesture( Leap::Gesture::Type::TYPE_CIRCLE );
controller->enableGesture( Leap::Gesture::Type::TYPE_KEY_TAP );
controller->enableGesture( Leap::Gesture::Type::TYPE_SCREEN_TAP );
controller->enableGesture( Leap::Gesture::Type::TYPE_SWIPE );
// Write gesture config to console
Leap::Config config = controller->config();
console() << "Gesture.Circle.MinRadius: " << config.getFloat( "Gesture.Circle.MinRadius" ) << endl;
console() << "Gesture.Circle.MinArc: " << config.getFloat( "Gesture.Circle.MinArc" ) << endl;
console() << "Gesture.Swipe.MinLength: " << config.getFloat( "Gesture.Swipe.MinLength" ) << endl;
console() << "Gesture.Swipe.MinVelocity: " << config.getFloat( "Gesture.Swipe.MinVelocity" ) << endl;
console() << "Gesture.KeyTap.MinDownVelocity: " << config.getFloat( "Gesture.KeyTap.MinDownVelocity" ) << endl;
console() << "Gesture.KeyTap.HistorySeconds: " << config.getFloat( "Gesture.KeyTap.HistorySeconds" ) << endl;
console() << "Gesture.KeyTap.MinDistance: " << config.getFloat( "Gesture.KeyTap.MinDistance" ) << endl;
console() << "Gesture.ScreenTap.MinForwardVelocity: " << config.getFloat( "Gesture.ScreenTap.MinForwardVelocity" ) << endl;
console() << "Gesture.ScreenTap.HistorySeconds: " << config.getFloat( "Gesture.ScreenTap.HistorySeconds" ) << endl;
console() << "Gesture.ScreenTap.MinDistance: " << config.getFloat( "Gesture.ScreenTap.MinDistance" ) << endl;
// Update config to make gestures easier
config.setFloat( "Gesture.Circle.MinRadius", 2.5f );
config.setFloat( "Gesture.Circle.MinArc", 3.0f );
config.setFloat( "Gesture.Swipe.MinLength", 75.0f );
config.setFloat( "Gesture.Swipe.MinVelocity", 500.0f );
config.setFloat( "Gesture.KeyTap.MinDownVelocity", 25.0f );
// Allows app to run in background
controller->setPolicyFlags( Leap::Controller::PolicyFlag::POLICY_BACKGROUND_FRAMES );
mFrameRate = 0.0f;
mFullScreen = false;
mParams = params::InterfaceGl::create( "Params", ivec2( 200, 105 ) );
mParams->addParam( "Frame rate", &mFrameRate, "", true );
mParams->addParam( "Full screen", &mFullScreen ).key( "f" );
mParams->addButton( "Screen shot", [ & ]() { screenShot(); }, "key=space" );
mParams->addButton( "Quit", [ & ]() { quit(); }, "key=q" );
gl::enableVerticalSync();
}
示例6: oleap_bang
void oleap_bang(t_oleap *x)
{
const Leap::Frame frame = x->leap->frame();
const int64_t frame_id = frame.id();
Leap::Controller controller;
// ignore the same frame
if (frame_id == x->frame_id_save) return;
x->frame_id_save = frame_id;
//outlet_anything(x->outlet, gensym("frame_start"), 0, nil);
char buff[128];
const Leap::HandList hands = frame.hands();
const size_t numHands = hands.count();
const Leap::Hand leftmost = hands.leftmost();
const Leap::Hand rightmost = hands.rightmost();
t_osc_bundle_u *bundle = osc_bundle_u_alloc();//alloc creates memory for and initializes the bundle
controller.enableGesture(Leap::Gesture::TYPE_CIRCLE);
controller.enableGesture(Leap::Gesture::TYPE_KEY_TAP);
controller.enableGesture(Leap::Gesture::TYPE_SCREEN_TAP);
controller.enableGesture(Leap::Gesture::TYPE_SWIPE);
// Get gestures
const Leap::GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Leap::Gesture gesture = gestures[g];
switch (gesture.type()) {
case Leap::Gesture::TYPE_CIRCLE:
{
Leap::CircleGesture circle = gesture;
std::string clockwiseness;
sprintf(buff,"/gesture/circle/center/x");
oleap_bundleMessage(bundle,buff,circle.center().x);
sprintf(buff,"/gesture/circle/center/y");
oleap_bundleMessage(bundle,buff,circle.center().y);
sprintf(buff,"/gesture/circle/center/z");
oleap_bundleMessage(bundle,buff,circle.center().z);
sprintf(buff,"/gesture/circle/pitch");
oleap_bundleMessage(bundle,buff,circle.center().pitch());
sprintf(buff,"/gesture/circle/yaw");
oleap_bundleMessage(bundle,buff,circle.center().yaw());
sprintf(buff,"/gesture/circle/roll");
oleap_bundleMessage(bundle,buff,circle.center().roll());
sprintf(buff,"/gesture/circle/radius");
oleap_bundleMessage(bundle,buff,circle.radius());
sprintf(buff,"/gesture/circle/duration");
oleap_bundleMessage(bundle,buff,circle.duration());
if (circle.pointable().direction().angleTo(circle.normal()) <= Leap::PI/4) {
clockwiseness = "clockwise";
sprintf(buff,"/gesture/circle/clockwiseness/");
oleap_bundleMessage(bundle,buff,1);
} else {
clockwiseness = "counterclockwise";
sprintf(buff,"/gesture/circle/clockwiseness/");
oleap_bundleMessage(bundle,buff,-1);
}
// Calculate angle swept since last frame
float sweptAngle = 0;
if (circle.state() != Leap::Gesture::STATE_START) {
Leap::CircleGesture previousUpdate = Leap::CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * Leap::PI;
sprintf(buff,"/gesture/circle/angle/sweep");
oleap_bundleMessage(bundle,buff,sweptAngle);
}
}
case Leap::Gesture::TYPE_SWIPE:
{
Leap::SwipeGesture swipe = gesture;
int swipe_id = gesture.id();
int gesture_state = gesture.state();
Leap::Vector swipe_direction = swipe.direction();
float swipe_speed = swipe.speed();
////////////////////////////////Swipe data
//.........这里部分代码省略.........
示例7: onInit
virtual void onInit( const Leap::Controller& leap )
{
leap.enableGesture( Leap::Gesture::TYPE_SWIPE );
leap.enableGesture( Leap::Gesture::TYPE_SCREEN_TAP );
leap.enableGesture( Leap::Gesture::TYPE_KEY_TAP );
}