本文整理汇总了C++中leap::Controller类的典型用法代码示例。如果您正苦于以下问题:C++ Controller类的具体用法?C++ Controller怎么用?C++ Controller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, const char *argv[]) {
if (argc < 2) {
cout << "Usage: leap_high_five /path/to/serial\n";
return 1;
}
LynxSSC lynx(argv[1], 115200);
// lynx.move(3, 1500, -1, -1);
lynx.move(3, 1500, -1, -1);
sleep(2);
lynx.move(4, 500, -1, 1000);
sleep(2);
lynx.move(
LynxMoveGroup().move(3,1000,-1,500)
.move(4,1500,-1,1000));
return 0;
cout << "Initializing controller";
static Leap::Controller s_controller;
FrameListener listener;
cout << "Adding listener to controller";
s_controller.addListener(listener);
// while (running) {
//
// while (inMotion) {
// Jacobian3 J(armCurrent.q, armLengths);
// }
// }
cin.get();
return 0;
}
示例2: main
int main(int argc, char **argv)
{
EffectRunner r;
// Create a sample listener and controller
SampleListener listener;
Leap::Controller controller;
// Have the sample listener receive events from the controller
controller.addListener(listener);
if (argc > 1 && strcmp(argv[1], "--bg") == 0)
controller.setPolicy(Leap::Controller::POLICY_BACKGROUND_FRAMES);
// Keep this process running until Enter is pressed
//std::cout << "Press Enter to quit..." << std::endl;
//std::cin.get();
// Remove the sample listener when done
//controller.removeListener(listener);
//return 0;
MyEffect e;
r.setEffect(&e);
// Defaults, overridable with command line options
r.setMaxFrameRate(100);
r.setLayout("../layouts/grid32x16z.json");
return r.main(argc, argv);
}
示例3: 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));
}
示例4: 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);
}
示例5: onFrame
void MouseController::onFrame(const Leap::Controller &controller) {
// get list of detected screens
const Leap::ScreenList screens = controller.calibratedScreens();
// make sure we have a detected screen
if (screens.empty()) return;
const Leap::Screen screen = screens[0];
// find the first finger or tool
const Leap::Frame frame = controller.frame();
const Leap::HandList hands = frame.hands();
if (hands.empty()) return;
const Leap::PointableList pointables = hands[0].pointables();
if (pointables.empty()) return;
const Leap::Pointable firstPointable = pointables[0];
// get x, y coordinates on the first screen
const Leap::Vector intersection = screen.intersect(
firstPointable,
true, // normalize
1.0f // clampRatio
);
// if the user is not pointing at the screen all components of
// the returned vector will be Not A Number (NaN)
// isValid() returns true only if all components are finite
if (! intersection.isValid()) return;
unsigned int x = screen.widthPixels() * intersection.x;
// flip y coordinate to standard top-left origin
unsigned int y = screen.heightPixels() * (1.0f - intersection.y);
CGPoint destPoint = CGPointMake(x, y);
CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, destPoint);
}
示例6: 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);
}
示例7: SetPolicyStatus
//LeapControllerPrivate
void LeapControllerPrivate::SetPolicyStatus(Leap::Controller::PolicyFlag flag, bool status)
{
if (status)
leap.setPolicy(flag);
else
leap.clearPolicy(flag);
}
示例8: 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);
}
示例9: main
int main(int argc, const char * argv[]) {
MouseController listener;
Leap::Controller controller;
controller.addListener(listener);
std::cout << "Press any key to exit" << std::endl;
std::cin.get();
controller.removeListener(listener);
return 0;
}
示例10: main
int main(int argc, char **argv){
ros::init(argc, argv, "leap_tool_control");
RosListener listener;
Leap::Controller controller;
controller.addListener(listener);
std::cout <<"Press Enter to quit..."<<std::endl;
std::cin.get();
controller.removeListener(listener);
}
示例11: main
int main(int argc, char** argv)
{
glutInit(&argc, argv);
int width = 500;
int height = 500;
unsigned int displayMode = GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH | GLUT_STENCIL;
displayMode = defaults(displayMode, width, height);
glutInitDisplayMode (displayMode);
glutInitContextVersion (3, 3);
glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
glutInitContextProfile(GLUT_CORE_PROFILE);
#ifdef DEBUG
glutInitContextFlags(GLUT_DEBUG);
#endif
glutInitWindowSize (width, height);
glutInitWindowPosition (300, 200);
int window = glutCreateWindow (argv[0]);
glload::LoadFunctions();
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
if(!glload::IsVersionGEQ(3, 3))
{
printf("Your OpenGL version is %i, %i. You must have at least OpenGL 3.3 to run this tutorial.\n",
glload::GetMajorVersion(), glload::GetMinorVersion());
glutDestroyWindow(window);
return 0;
}
if(glext_ARB_debug_output)
{
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
glDebugMessageCallbackARB(DebugFunc, (void*)15);
}
init();
UserListener listener;
Leap::Controller controller;
controller.addListener(listener);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
controller.removeListener(listener);
return 0;
}
示例12: operator
/*----------------------------------------------------------------------------------------------------*/
OSVR_ReturnCode HardwareDetection::operator()(OSVR_PluginRegContext pContext) {
Leap::Controller controller;
if ( !controller.isConnected() ) {
mFound = false;
return OSVR_RETURN_FAILURE;
}
if ( !mFound ) {
mFound = true;
osvr::pluginkit::registerObjectForDeletion(pContext, new ControllerDevice(pContext));
}
return OSVR_RETURN_SUCCESS;
}
示例13: main
void main()
{
// リスナーを登録する
// リスナーとのやり取りは別スレッドにて行われる
SampleListener listener;
Leap::Controller leap;
leap.addListener( listener );
leap.setPolicyFlags( Leap::Controller::PolicyFlag::POLICY_BACKGROUND_FRAMES );
std::cout << "終了するには何かキーを押してください" << std::endl;
std::cin.get();
leap.removeListener( listener );
}
示例14: onFrame
void Quickstart::onFrame(const Leap::Controller &controller) {
// returns the most recent frame. older frames can be accessed by passing in
// a "history" parameter to retrieve an older frame, up to about 60
// (exact number subject to change)
const Leap::Frame frame = controller.frame();
// do nothing unless hands are detected
if (frame.hands().empty())
return;
// first detected hand
const Leap::Hand firstHand = frame.hands()[0];
// first pointable object (finger or tool)
const Leap::PointableList pointables = firstHand.pointables();
if (pointables.empty()) return;
const Leap::Pointable firstPointable = pointables[0];
// print velocity on the X axis
cout << "Pointable X velocity: " << firstPointable.tipVelocity()[0] << endl;
const Leap::FingerList fingers = firstHand.fingers();
if (fingers.empty()) return;
for (int i = 0; i < fingers.count(); i++) {
const Leap::Finger finger = fingers[i];
std::cout << "Detected finger " << i << " at position (" <<
finger.tipPosition().x << ", " <<
finger.tipPosition().y << ", " <<
finger.tipPosition().z << ")" << std::endl;
}
}
示例15: onInit
void Quickstart::onInit(const Leap::Controller &controller) {
if (! controller.isConnected()) {
// controller is not connected or the driver software is not started.
// give the user a friendly reminder that we can't do anything yet
cout << "Please connect your Leap Motion and run the Leap application" << endl;
}
}