本文整理汇总了C++中leap::Controller类的典型用法代码示例。如果您正苦于以下问题:C++ Controller类的具体用法?C++ Controller怎么用?C++ Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Controller类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:theJenix,项目名称:leap-high-five,代码行数:35,代码来源:leap_high_five.cpp
示例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);
}
开发者ID:RobDeBagel,项目名称:fadecandy,代码行数:32,代码来源:simple.cpp
示例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));
}
开发者ID:20SecondsToSun,项目名称:Funces,代码行数:27,代码来源:LeapController.cpp
示例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);
}
开发者ID:circlingthesun,项目名称:Masters,代码行数:7,代码来源:leaplistener.cpp
示例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);
}
开发者ID:revmischa,项目名称:leapmouse,代码行数:35,代码来源:main.cpp
示例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);
}
开发者ID:jnone001,项目名称:InteractivePaint,代码行数:7,代码来源:LeapMotionHandler.cpp
示例7: SetPolicyStatus
//LeapControllerPrivate
void LeapControllerPrivate::SetPolicyStatus(Leap::Controller::PolicyFlag flag, bool status)
{
if (status)
leap.setPolicy(flag);
else
leap.clearPolicy(flag);
}
开发者ID:77stone,项目名称:leap-ue4,代码行数:8,代码来源:LeapController.cpp
示例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);
}
开发者ID:crf1111,项目名称:LeapMotion_Slicer,代码行数:9,代码来源:leapmotionlistener.cpp
示例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;
}
开发者ID:revmischa,项目名称:leapmouse,代码行数:12,代码来源:main.cpp
示例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);
}
开发者ID:CityU-MBE,项目名称:leap_motion_ros,代码行数:12,代码来源:tool_control.cpp
示例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;
}
开发者ID:emdeha,项目名称:random-code,代码行数:53,代码来源:framework.cpp
示例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;
}
开发者ID:beijingkaka,项目名称:OSVR-Leap-Motion,代码行数:16,代码来源:HardwareDetection.cpp
示例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 );
}
开发者ID:LeapBookCpp,项目名称:LeapBookCpp,代码行数:15,代码来源:main.cpp
示例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;
}
}
开发者ID:revmischa,项目名称:leapbook,代码行数:32,代码来源:quickstart.cpp
示例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;
}
}
开发者ID:Belial2010,项目名称:leapbook,代码行数:7,代码来源:quickstart.cpp
示例16: onControlUpdated
void Listener::onControlUpdated(const Leap::Controller &controller, GesturePtr gesture, ControlPtr control) {
midi_control_index ctrlIdx = control->controlIndex();
midi_control_value ctrlVal = control->mappedValue();
//
// cout << "Recognized control index " << ctrlIdx
// << " (" << control->description() << ")"
// << ", raw value: "
// << control->rawValue() << " mapped value: " << ctrlVal << endl;
if (frameCount <= 10) return;
// control latency
struct timeval tv;
gettimeofday(&tv, NULL);
double elapsedTime = (tv.tv_sec - control->timestamp().tv_sec) * 1000.0; // sec to ms
elapsedTime += (tv.tv_usec - control->timestamp().tv_usec) / 1000.0; // us to ms
// frame latency
double absoluteTimeOffset = tv_to_usec(tv) - tv_to_usec(firstFrameAbs);
// cout << "absolute time offset: " << absoluteTimeOffset << endl;
int64_t curFrameTime = controller.frame().timestamp();
int64_t frameOffset = curFrameTime - firstFrameLeap;
int64_t frameLatency = absoluteTimeOffset - frameOffset;
// cout << "frame: " << curFrameTime << ", absolute offset: " << (absoluteTimeOffset / 1000) << ", frameOffset: " << (frameOffset / 1000) << ", diff: " << (frameLatency / 1000) << endl;
if (minLatency == 0 || frameLatency < minLatency)
minLatency = frameLatency;
if (frameLatency > maxLatency)
maxLatency = frameLatency;
controlCount++;
totalLatency += frameLatency;
if (elapsedTime > 3)
cout << "frame latency: " << (frameLatency / 1000) << ", control output latency: " << elapsedTime << endl;
}
开发者ID:SteveClement,项目名称:leapmidi,代码行数:35,代码来源:MIDIListener.cpp
示例17: onFrame
void Listener::onFrame(const Leap::Controller &controller) {
Leap::Frame curFrame = controller.frame();
if (firstFrameLeap == 0 && ++frameCount > 10) {
gettimeofday(&firstFrameAbs, NULL);
firstFrameLeap = curFrame.timestamp();
cout << "First frame clock time: " << tv_to_usec(firstFrameAbs) << endl;
cout << "First frame leap time: " << firstFrameLeap << endl;
}
// use current active gesture recognizers to locate gestures
// and then trigger appropriate note/controls
// feed frames to recognizers
vector<GesturePtr> recognizers = gestureRecognizers();
for (vector<GesturePtr>::iterator it = recognizers.begin(); it != recognizers.end(); ++it) {
// get controls recognized from gestures
GesturePtr gesture = *it;
std::vector<ControlPtr> gestureControls; // controls from this gesture
gesture->recognizedControls(controller, gestureControls);
if (! gestureControls.size())
continue;
// call gesture recognized callback
onGestureRecognized(controller, gesture);
for (vector<ControlPtr>::iterator ctl = gestureControls.begin(); ctl != gestureControls.end(); ++ctl) {
ControlPtr control = *ctl;
onControlUpdated(controller, gesture, control);
}
}
}
开发者ID:SteveClement,项目名称:leapmidi,代码行数:32,代码来源:MIDIListener.cpp
示例18: processGesture
void LeapFishyApp::processGesture()
{
Leap::Frame frame = m_LeapController.frame();
if( m_LastFrame == frame )
return;
Leap::GestureList gestures = m_LastFrame.isValid() ?
frame.gestures( m_LastFrame ) :
frame.gestures();
m_LastFrame = frame;
for( int i = 0; i < gestures.count(); i++ )
{
if( gestures[i].type() == Leap::Gesture::TYPE_SWIPE )
{
Leap::SwipeGesture swipe = gestures[i];
Leap::Vector diff = 0.006f*(swipe.position() - swipe.startPosition());
Vec2f curSwipe(diff.x, -diff.y);
m_pPlayer->AddVelocity( curSwipe );
}
else if( gestures[i].type() == Leap::Gesture::TYPE_KEY_TAP ||
gestures[i].type() == Leap::Gesture::TYPE_SCREEN_TAP )
{
m_pPlayer->KillVelocity();
}
}
}
开发者ID:seanfoo73,项目名称:LeapExperiments,代码行数:29,代码来源:LeapFishyApp.cpp
示例19: onFrame
void LeapMotionListener::onFrame( const Leap::Controller& controller )
{
// get least frame
frame = controller.frame( 0 );
}
开发者ID:hhyuga201515,项目名称:MiraiMotion,代码行数:7,代码来源:LeapMotionListener.cpp
示例20: main
int main()
{
control.setPolicyFlags(Leap::Controller::POLICY_BACKGROUND_FRAMES);
pipe = CreateFile(PNAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
atexit(fin);
//tenfingers = (float*)malloc(sizeof(float)*10*4);
printf("connected\n");
//get fist positions as well
DWORD word = 0;
while(1)
{
fdata ret = get_finger_positions();
WriteFile(pipe, (char*)&ret, sizeof(fdata), &word, NULL);
Sleep(1);
}
//CloseHandle(pipe);
}
开发者ID:Michaelangel007,项目名称:openclamdrenderer,代码行数:27,代码来源:main.cpp
注:本文中的leap::Controller类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论