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); }
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; }
//Inherited from Cinder - post-graphics initalization setup steps. Loads our particle texture & sets up the Leap controller. void GesturesDemo::setup() { ci::gl::Texture* particleTexture = new ci::gl::Texture(ci::loadImage(ci::app::loadResource(RES_PARTICLE))); ci::gl::disableVerticalSync(); //required for higher than 60fps field.SetParticleTexture(particleTexture); mouseIsDown = false; lastMousePos.set(0, 0); controller.addListener( listener ); }
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; }
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); }
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; }
void LeapCinderRainApp::setup() { m_LeapController.addListener( m_LeapListener ); /** timing data */ m_fLastTime = getElapsedSeconds(); m_fFrameTime = 0; /** background image */ /** vector field */ m_Rain = new RainController(); }
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 ); }
void LeapFishyApp::setup() { m_LeapController.addListener( m_LeapListener ); /** timing data */ m_fLastTime = getElapsedSeconds(); m_fFrameTime = 0; /** player setup */ m_pPlayer = new PlayerFish(); /** enemy fish setup */ m_pEnemyFishes = new std::list<EnemyFish*>(); m_nMinNumFishes = 10; SpawnEnemyFish( m_nMinNumFishes ); }
int main() { // create instance of our Listener subclass Quickstart listener; // create generic Controller to interface with the Leap device Leap::Controller controller; // tell the Controller to start sending events to our Listener controller.addListener(listener); // run until user presses a key cin.get(); // clean up controller.removeListener(listener); return 0; }
int main(int argc, char **argv){ Leap::Listener *leaplistener = new FracListener(); fracListener = ((FracListener *) (leaplistener)); Leap::Controller controller; controller.addListener(*leaplistener); sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "SFML works!", sf::Style::Fullscreen); std::vector<Effect*> effects; Quaternion quaternion; effects.push_back(&quaternion); for (std::size_t i = 0; i < effects.size(); ++i) effects[i]->load(); window.setVerticalSyncEnabled(true); while (window.isOpen()){ sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); if(event.type == sf::Event::KeyPressed) { if(event.key.code == sf::Keyboard::Escape) window.close(); } } float mult = 1; if(sf::Keyboard::isKeyPressed(sf::Keyboard::LShift)) mult = -1; else mult = 1; if(sf::Keyboard::isKeyPressed(sf::Keyboard::A)) fracListener->a -= mult * 0.05; if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) fracListener->b += mult * 0.05; if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)) fracListener->c += mult * 0.05; if(sf::Keyboard::isKeyPressed(sf::Keyboard::F)) fracListener->d += mult * 0.05; if(sf::Keyboard::isKeyPressed(sf::Keyboard::R)){ fracListener->a = .5f; fracListener->b = .5f; fracListener->c = .5f; fracListener->d = .5f; } window.clear(); for (int i = 0; i < effects.size(); ++i){ effects[i]->update(); } for (int i = 0; i < effects.size(); ++i){ window.draw(*(effects[i])); } window.display(); } return 0; }
int main(int argc, char* argv[]) { // Verify input arguments if (argc != 2) { std::cout << "Usage: " << argv[0] << " Filename(.vtk) as structured points." << std::endl; return EXIT_FAILURE; } std::string inputFilename = argv[1]; vtkSmartPointer<vtkNIFTIImageReader> reader1 = vtkSmartPointer<vtkNIFTIImageReader>::New(); reader1->SetFileName(inputFilename.c_str()); reader1->Update(); vtkSmartPointer<vtkImageToStructuredPoints> reader = vtkSmartPointer<vtkImageToStructuredPoints>::New(); reader->SetInputConnection(reader1->GetOutputPort()); reader->Update(); std::string outputName; cout << "Please enter a name for the output segmentation:" << endl; cin >> outputName; cout << "OK." << endl; // Create a leap listener and controller SlicerLeapListener listener; Leap::Controller controller; //selection layer vtkSmartPointer<vtkStructuredPoints> selection = vtkSmartPointer<vtkStructuredPoints>::New(); //reader->GetOutput()->CopyStructure(selection); selection->SetExtent(reader->GetOutput()->GetExtent()); selection->SetSpacing(reader->GetOutput()->GetSpacing()); selection->SetOrigin(reader->GetOutput()->GetOrigin()); // Setup the colors array for crosshair vtkSmartPointer<vtkUnsignedShortArray> selection_colors = vtkSmartPointer<vtkUnsignedShortArray>::New(); //selection_colors->SetNumberOfComponents(1);//4 selection->AllocateScalars(VTK_UNSIGNED_SHORT, 1); cout << selection->GetNumberOfCells() << endl; // Add the colors we created to the colors array selection_colors->SetNumberOfTuples(selection->GetNumberOfPoints()); selection_colors->SetName("selection_colors"); selection->GetPointData()->SetScalars(selection_colors); //crosshair CrosshairFactory* crossFac = CrosshairFactory::getInstance(); // get window's size for crosshair creation and update vtkSmartPointer<vtkActor> crosshair = crossFac->makeCrosshair(reader->GetOutput()->GetBounds());//createCrosshair(reader->GetOutput()->GetBounds()); crosshair->GetMapper()->Update(); crosshair->SetPickable(false); // Visualize //viewer vtkSmartPointer<vtkImageViewer2>viewer = vtkSmartPointer<vtkImageViewer2>::New(); //interaction vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New(); vtkSmartPointer<myVtkInteractorStyleImage> myInteractorStyle = vtkSmartPointer<myVtkInteractorStyleImage>::New(); vtkSmartPointer<vtkImageMapToColors> mapperSel = vtkSmartPointer<vtkImageMapToColors>::New(); //intiaite the points to be non-active vtkUnsignedShortArray* point = (vtkUnsignedShortArray*)selection->GetPointData()->GetScalars(); for (int i = 0; i < selection->GetNumberOfPoints(); i++){ point->SetValue(i, NOT_ACTIVE); } /*for (int i = 0; i < 20000; i++){ point->SetValue(i, ACTIVE); }*/ //Dimensions of selection can be overwritten by the CT dimensions. int* inputDims = selection->GetDimensions(); std::cout << "Dims: " << " x: " << inputDims[0] << " y: " << inputDims[1] << " z: " << inputDims[2] << std::endl; std::cout << "Number of points: " << selection->GetNumberOfPoints() << std::endl; std::cout << "Number of cells: " << selection->GetNumberOfCells() << std::endl; //getting the extent, update it and set it to the extractedVOI int* extent = reader->GetOutput()->GetExtent(); vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); lut->SetNumberOfTableValues(3); lut->SetRange(0, 2); lut->SetTableValue((vtkIdType)NOT_ACTIVE, 0, 0, 0, 0.0); lut->SetTableValue((vtkIdType)FOREGROUND, 1, 0, 0, 0.5); lut->SetTableValue((vtkIdType)BACKGROUND, 0, 0, 1, 0.3); lut->Build(); mapperSel->SetLookupTable(lut); mapperSel->SetInputData(selection); mapperSel->Update(); vtkSmartPointer<vtkImageGaussianSmooth> smoothed = vtkSmartPointer<vtkImageGaussianSmooth>::New(); smoothed->SetInputConnection(reader->GetOutputPort()); smoothed->SetDimensionality(3); smoothed->SetRadiusFactors(SMOOTHING_FACTOR_XY, SMOOTHING_FACTOR_XY, SMOOTHING_FACTOR_Z); //smoothed->SetStandardDeviations(0.0,0.0,0.0); smoothed->Update(); //First of all set the input for the viewer! viewer->SetInputConnection(reader->GetOutputPort()); // make imageviewer2 and sliceTextMapper visible to our interactorstyle // to enable slice status message updates when scrolling through the slices vtkSmartPointer<vtkImageActor> selectionA = vtkSmartPointer<vtkImageActor>::New(); selectionA->GetMapper()->SetInputConnection(mapperSel->GetOutputPort()); selectionA->InterpolateOff(); // slice status message vtkSmartPointer<vtkTextProperty> sliceTextProp = vtkSmartPointer<vtkTextProperty>::New(); sliceTextProp->SetFontFamilyToCourier(); sliceTextProp->SetFontSize(20); sliceTextProp->SetVerticalJustificationToBottom(); sliceTextProp->SetJustificationToLeft(); vtkSmartPointer<vtkTextMapper> sliceTextMapper = vtkSmartPointer<vtkTextMapper>::New(); std::string msg = StatusMessage::Format(viewer->GetSliceMin(), viewer->GetSliceMax(), viewer->GetSliceOrientation()); sliceTextMapper->SetInput(msg.c_str()); sliceTextMapper->SetTextProperty(sliceTextProp); vtkSmartPointer<vtkActor2D> sliceTextActor = vtkSmartPointer<vtkActor2D>::New(); sliceTextActor->SetMapper(sliceTextMapper); sliceTextActor->SetPosition(15, 10); // usage hint message vtkSmartPointer<vtkTextProperty> usageTextProp = vtkSmartPointer<vtkTextProperty>::New(); usageTextProp->SetFontFamilyToCourier(); usageTextProp->SetFontSize(14); usageTextProp->SetVerticalJustificationToTop(); usageTextProp->SetJustificationToLeft(); vtkSmartPointer<vtkTextMapper> usageTextMapper = vtkSmartPointer<vtkTextMapper>::New(); usageTextMapper->SetInput("Options:\n - Hold Shift to scroll between slices.\n - Hold Ctrl" " to draw segmentation.\n - Hold Alt to mark background.\n\n -- Press '1' and '2' to change" " brush's size\n -- Press 'o' to toggle orientation\n -- Press 's' to save segmentation\n --" " Press 'l' to load segmentation\n -- Press 'r' to reset selection\n -- Press 'h' for hands-free mode."); usageTextMapper->SetTextProperty(usageTextProp); vtkSmartPointer<vtkActor2D> usageTextActor = vtkSmartPointer<vtkActor2D>::New(); usageTextActor->SetMapper(usageTextMapper); usageTextActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedDisplay(); usageTextActor->GetPositionCoordinate()->SetValue(0.05, 0.95); //Segmenter //Segmenter* _segmenter = new Segmenter((vtkStructuredPoints*)(((vtkImageMapToColors*)selectionA->GetMapper()->GetInputAlgorithm()))->GetInput(), reader->GetOutput()); myInteractorStyle->SetImageViewer(viewer, outputName, inputFilename, selectionA, (vtkStructuredPoints*)smoothed->GetOutput()/*reader->GetOutput()*/); myInteractorStyle->SetStatusMapper(sliceTextMapper); viewer->SetupInteractor(renderWindowInteractor); //mapperSel->SetScalarModeToUseCellData(); // make the interactor use our own interactorstyle // cause SetupInteractor() is defining it's own default interatorstyle // this must be called after SetupInteractor() renderWindowInteractor->Initialize(); renderWindowInteractor->SetInteractorStyle(myInteractorStyle); renderWindowInteractor->CreateRepeatingTimer(UPDATE_SLICE_TIMER); viewer->GetRenderer()->AddActor2D(sliceTextActor); viewer->GetRenderer()->AddActor2D(usageTextActor); viewer->GetRenderer()->AddActor(selectionA); viewer->GetRenderer()->AddActor(crosshair); int displayExtent[6]; viewer->GetImageActor()->GetDisplayExtent(displayExtent); selectionA->SetDisplayExtent(displayExtent); viewer->GetRenderWindow()->SetPosition(0, 0); viewer->GetRenderWindow()->SetSize(viewer->GetRenderWindow()->GetScreenSize()[0] / 2, viewer->GetRenderWindow()->GetScreenSize()[1]-50); viewer->GetRenderWindow()->SetWindowName("Slicer"); // Have the sample listener receive events from the controller cout << "passed all creations " << endl; controller.addListener(listener); LeapAbstractionLayer* lal = LeapAbstractionLayer::getInstance(); listener.SetInterface(lal); cout << "set viewer on listener" << endl; viewer->Render(); viewer->GetRenderer()->ResetCamera(); cout << "Camera reset" << endl; viewer->Render(); //set focus SetForegroundWindow(FindWindow(NULL, "Slicer")); renderWindowInteractor->Start(); controller.removeListener(listener); return EXIT_SUCCESS; }
Impl() { m_Controller.addListener(*this); }