///Keyboard Event Tracking void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* viewer_void) { boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void); if (event.getKeySym () == "c" && event.keyDown ()) { std::cout << "c was pressed => capturing a pointcloud" << std::endl; std::string filename = "KinectCap"; filename.append(boost::lexical_cast<std::string>(cloud_id)); filename.append(".pcd"); pcl::io::savePCDFileASCII (filename, *cloud); cloud_id++; } if (event.getKeySym () == "b" && event.keyDown ()) { std::cout << "b was pressed" << std::endl; if (BackgroundSub == false) { //Start background subtraction if (hasBackground == false) { //Copy over the current cloud as a BG cloud. pcl::copyPointCloud(*cloud, *bgcloud); hasBackground = true; } BackgroundSub = true; } else { //Stop Background Subtraction BackgroundSub = false; } } if (event.getKeySym () == "v" && event.keyDown ()) { std::cout << "v was pressed" << std::endl; Voxelize = !Voxelize; } }
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* viewer_void){ if (event.keyDown () && event.getKeySym () == "Right"){next = true;} }
/* \brief Callback to interact with the keyboard * */ void keyboardEventOccurred(const pcl::visualization::KeyboardEvent &event, void *) { if (event.getKeySym() == "a" && event.keyDown()) { IncrementLevel(); } else if (event.getKeySym() == "z" && event.keyDown()) { DecrementLevel(); } else if (event.getKeySym() == "d" && event.keyDown()) { displayCubes = !displayCubes; update(); } else if (event.getKeySym() == "x" && event.keyDown()) { showPointsWithCubes = !showPointsWithCubes; update(); } else if (event.getKeySym() == "w" && event.keyDown()) { if(!wireframe) wireframe=true; update(); } else if (event.getKeySym() == "s" && event.keyDown()) { if(wireframe) wireframe=false; update(); } }
void simulate_callback (const pcl::visualization::KeyboardEvent &event, void* viewer_void) { boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void); // I choose v for virtual as s for simulate is takwen if (event.getKeySym () == "v" && event.keyDown ()) { std::cout << "v was pressed => simulate cloud" << std::endl; std::vector<pcl::visualization::Camera> cams; viewer->getCameras(cams); if (cams.size() !=1){ std::cout << "n cams not 1 exiting\n"; // for now in case ... return; } // cout << "n cams: " << cams.size() << "\n"; pcl::visualization::Camera cam = cams[0]; Eigen::Affine3f pose; pose = viewer->getViewerPose() ; std::cout << cam.pos[0] << " " << cam.pos[1] << " " << cam.pos[2] << " p\n"; Eigen::Matrix3f m; m =pose.rotation(); //All axies use right hand rule. x=red axis, y=green axis, z=blue axis z direction is point into the screen. z \ \ \ -----------> x | | | | | | y cout << pose(0,0) << " " << pose(0,1) << " " << pose(0,2) << " " << pose(0,3) << " x0\n"; cout << pose(1,0) << " " << pose(1,1) << " " << pose(1,2) << " " << pose(1,3) << " x1\n"; cout << pose(2,0) << " " << pose(2,1) << " " << pose(2,2) << " " << pose(2,3)<< "x2\n"; double yaw,pitch, roll; wRo_to_euler(m,yaw,pitch,roll); printf("RPY: %f %f %f\n", roll*180/M_PI,pitch*180/M_PI,yaw*180/M_PI); // matrix->GetElement(1,0); cout << m(0,0) << " " << m(0,1) << " " << m(0,2) << " " << " x0\n"; cout << m(1,0) << " " << m(1,1) << " " << m(1,2) << " " << " x1\n"; cout << m(2,0) << " " << m(2,1) << " " << m(2,2) << " "<< "x2\n\n"; Eigen::Quaternionf rf; rf = Eigen::Quaternionf(m); Eigen::Quaterniond r(rf.w(),rf.x(),rf.y(),rf.z()); Eigen::Isometry3d init_pose; init_pose.setIdentity(); init_pose.translation() << cam.pos[0], cam.pos[1], cam.pos[2]; //Eigen::Quaterniond m = euler_to_quat(-1.54, 0, 0); init_pose.rotate(r); // std::stringstream ss; print_Isometry3d(init_pose,ss); std::cout << "init_pose: " << ss.str() << "\n"; viewer->addCoordinateSystem (1.0,pose); double tic = getTime(); std::stringstream ss2; ss2.precision(20); ss2 << "simulated_pcl_" << tic << ".pcd"; capture(init_pose,ss2.str()); cout << (getTime() -tic) << " sec\n"; // these three variables determine the position and orientation of // the camera. // double lookat[3]; - focal location // double eye[3]; - my location // double up[3]; - updirection // std::cout << view[0] << "," << view[1] << "," << view[2] // cameras.back ().view[2] = renderer->GetActiveCamera ()->GetOrientationWXYZ()[2]; //ViewTransform->GetOrientationWXYZ(); // Superclass::OnKeyUp (); // vtkSmartPointer<vtkCamera> cam = event.Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->GetActiveCamera (); // double clip[2], focal[3], pos[3], view[3]; // cam->GetClippingRange (clip); /* cam->GetFocalPoint (focal); cam->GetPosition (pos); cam->GetViewUp (view); int *win_pos = Interactor->GetRenderWindow ()->GetPosition (); int *win_size = Interactor->GetRenderWindow ()->GetSize (); std::cerr << clip[0] << "," << clip[1] << "/" << focal[0] << "," << focal[1] << "," << focal[2] << "/" << pos[0] << "," << pos[1] << "," << pos[2] << "/" << view[0] << "," << view[1] << "," << view[2] << "/" << cam->GetViewAngle () / 180.0 * M_PI << "/" << win_size[0] << "," << win_size[1] << "/" << win_pos[0] << "," << win_pos[1] << endl; */ } }
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent& event,void* nothing) { if (event.getKeySym () == "space" && event.keyDown ()) pcl::console::print_highlight ("Got a keyboard event\n"); next_iteration = true; }
void keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*) { if (event.getKeyCode () == '1') show_original = !show_original; if (event.getKeyCode () == '2') show_supervoxels = !show_supervoxels; if (event.getKeyCode () == '3') show_models = !show_models; if (event.getKeyCode () == '4') show_tracks = !show_tracks; if (event.getKeyCode () == '5') show_result = !show_result; if (event.getKeyCode () == '6') show_coloredsv = !show_coloredsv; if (event.getKeyCode () == '7') show_orientation = !show_orientation; if (event.getKeyCode () == '9') show_particles = !show_particles; if (event.getKeyCode () == '0') pause_playback = !pause_playback; if (event.getKeyCode () == '`') resetCamera = true; if (event.getKeyCode () == '8') controlCamera = !controlCamera; }
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* viewer_void) { boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void); static double dd = 0.05; if (event.getKeySym () == "r" && event.keyDown ()) { dd *= 2; printf("doubled dd to %lf\n", dd); } if (event.getKeySym () == "t" && event.keyDown ()) { dd /= 2.0; printf("halved dd to %lf\n", dd); } if (event.getKeySym () == "n" && event.keyDown ()) { printf("Current is 2.\n"); Tc = &T2; } if (event.getKeySym () == "m" && event.keyDown ()) { printf("Current is 3.\n"); Tc = &T3; } if (event.getKeySym () == "k" && event.keyDown ()) { printf("Current is 4.\n"); Tc = &T4; } if (event.getKeySym () == "i" && event.keyDown ()) { printf("All is visualized.\n"); viewAll = !viewAll; } if (event.getKeySym () == "a" && event.keyDown ()) (*Tc)(0,3) += dd; if (event.getKeySym () == "d" && event.keyDown ()) (*Tc)(0,3) -= dd; if (event.getKeySym () == "w" && event.keyDown ()) (*Tc)(1,3) += dd; if (event.getKeySym () == "s" && event.keyDown ()) (*Tc)(1,3) -= dd; if (event.getKeySym () == "j" && event.keyDown ()) (*Tc)(2,3) += dd; if (event.getKeySym () == "l" && event.keyDown ()) (*Tc)(2,3) -= dd; }
void keyboardCallback (const pcl::visualization::KeyboardEvent& event, void*) { if (event.keyDown ()) { if (event.getKeyCode () == 'w' || event.getKeyCode () == 'W') { window_ += event.getKeyCode () == 'w' ? 1 : -1; if (window_ < 1) window_ = 1; pcl::console::print_info ("Temporal filtering window size: "); pcl::console::print_value ("%i\n", window_); grabber_.enableTemporalFiltering (temporal_filtering_, window_); } if (event.getKeyCode () == 't' || event.getKeyCode () == 'T') { threshold_ += event.getKeyCode () == 't' ? 1 : -1; if (threshold_ < 0) threshold_ = 0; if (threshold_ > 15) threshold_ = 15; pcl::console::print_info ("Confidence threshold: "); pcl::console::print_value ("%i\n", threshold_); grabber_.setConfidenceThreshold (threshold_); } if (event.getKeyCode () == 'k') { pcl::console::print_info ("Temporal filtering: "); switch (temporal_filtering_) { case pcl::RealSenseGrabber::RealSense_None: //{ //temporal_filtering_ = pcl::RealSenseGrabber::RealSense_Median; //pcl::console::print_value ("median\n"); //break; //} //case pcl::RealSenseGrabber::RealSense_Median: { temporal_filtering_ = pcl::RealSenseGrabber::RealSense_Average; pcl::console::print_value ("average\n"); break; } case pcl::RealSenseGrabber::RealSense_Average: { temporal_filtering_ = pcl::RealSenseGrabber::RealSense_None; pcl::console::print_value ("none\n"); break; } } grabber_.enableTemporalFiltering (temporal_filtering_, window_); } if (event.getKeyCode () == 'b') { with_bilateral_ = !with_bilateral_; pcl::console::print_info ("Bilateral filtering: "); pcl::console::print_value (with_bilateral_ ? "ON\n" : "OFF\n"); } if (event.getKeyCode () == 'a' || event.getKeyCode () == 'A') { float s = bilateral_.getSigmaS (); s += event.getKeyCode () == 'a' ? 1 : -1; if (s <= 1) s = 1; pcl::console::print_info ("Bilateral filter spatial sigma: "); pcl::console::print_value ("%.0f\n", s); bilateral_.setSigmaS (s); } if (event.getKeyCode () == 'z' || event.getKeyCode () == 'Z') { float r = bilateral_.getSigmaR (); r += event.getKeyCode () == 'z' ? 0.01 : -0.01; if (r <= 0.01) r = 0.01; pcl::console::print_info ("Bilateral filter range sigma: "); pcl::console::print_value ("%.2f\n", r); bilateral_.setSigmaR (r); } if (event.getKeyCode () == 's') { boost::format fmt ("RS_%s_%u.pcd"); std::string fn = boost::str (fmt % grabber_.getDeviceSerialNumber ().c_str () % last_cloud_->header.stamp); pcl::io::savePCDFileBinaryCompressed (fn, *last_cloud_); pcl::console::print_info ("Saved point cloud: "); pcl::console::print_value (fn.c_str ()); pcl::console::print_info ("\n"); } displaySettings (); } }
void keyboardCB (const pcl::visualization::KeyboardEvent &event, void* params_void) { if (event.getKeyCode () == 13 /*enter*/ && event.keyUp ()) update (static_cast<CallbackParameters*> (params_void)); }
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* viewer_void) { boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void); double dd = 0.01; if (event.getKeySym () == "a" && event.keyDown ()) (*T)(0,3) += dd; if (event.getKeySym () == "d" && event.keyDown ()) (*T)(0,3) -= dd; if (event.getKeySym () == "w" && event.keyDown ()) (*T)(1,3) += dd; if (event.getKeySym () == "s" && event.keyDown ()) (*T)(1,3) -= dd; if (event.getKeySym () == "j" && event.keyDown ()) { printf("\nasdf\nasdf\nasdf\n"); (*T)(2,3) += dd; } if (event.getKeySym () == "l" && event.keyDown ()) (*T)(2,3) -= dd; if (event.getKeySym () == "n" && event.keyDown ()) { T = &T1; printf("Working on transform 1\n"); } if (event.getKeySym () == "m" && event.keyDown ()) { T = &T2; printf("Working on transform 2\n"); } if (event.getKeySym () == "k" && event.keyDown ()) { T = &T3; printf("Working on transform 3\n"); } if (event.getKeySym () == "i" && event.keyDown ()) seeAll = !seeAll; }
void simulate_callback (const pcl::visualization::KeyboardEvent &event, void* viewer_void) { pcl::visualization::PCLVisualizer::Ptr viewer = *static_cast<pcl::visualization::PCLVisualizer::Ptr *> (viewer_void); // I choose v for virtual as s for simulate is takwen if (event.getKeySym () == "v" && event.keyDown ()) { std::cout << "v was pressed => simulate cloud" << std::endl; std::vector<pcl::visualization::Camera> cams; viewer->getCameras(cams); if (cams.size() !=1){ std::cout << "n cams not 1 exiting\n"; // for now in case ... return; } // cout << "n cams: " << cams.size() << "\n"; pcl::visualization::Camera cam = cams[0]; Eigen::Affine3f pose; pose = viewer->getViewerPose() ; std::cout << cam.pos[0] << " " << cam.pos[1] << " " << cam.pos[2] << " p\n"; Eigen::Matrix3f m; m =pose.rotation(); //All axies use right hand rule. x=red axis, y=green axis, z=blue axis z direction is point into the screen. z \ \ \ -----------> x | | | | | | y cout << pose(0,0) << " " << pose(0,1) << " " << pose(0,2) << " " << pose(0,3) << " x0\n"; cout << pose(1,0) << " " << pose(1,1) << " " << pose(1,2) << " " << pose(1,3) << " x1\n"; cout << pose(2,0) << " " << pose(2,1) << " " << pose(2,2) << " " << pose(2,3)<< "x2\n"; double yaw,pitch, roll; wRo_to_euler(m,yaw,pitch,roll); printf("RPY: %f %f %f\n", roll*180/M_PI,pitch*180/M_PI,yaw*180/M_PI); // matrix->GetElement(1,0); cout << m(0,0) << " " << m(0,1) << " " << m(0,2) << " " << " x0\n"; cout << m(1,0) << " " << m(1,1) << " " << m(1,2) << " " << " x1\n"; cout << m(2,0) << " " << m(2,1) << " " << m(2,2) << " "<< "x2\n\n"; Eigen::Quaternionf rf; rf = Eigen::Quaternionf(m); Eigen::Quaterniond r(rf.w(),rf.x(),rf.y(),rf.z()); Eigen::Isometry3d init_pose; init_pose.setIdentity(); init_pose.translation() << cam.pos[0], cam.pos[1], cam.pos[2]; //Eigen::Quaterniond m = euler_to_quat(-1.54, 0, 0); init_pose.rotate(r); // std::stringstream ss; print_Isometry3d(init_pose,ss); std::cout << "init_pose: " << ss.str() << "\n"; viewer->addCoordinateSystem (1.0,pose,"reference"); double tic = getTime(); std::stringstream ss2; ss2.precision(20); ss2 << "simulated_pcl_" << tic << ".pcd"; capture(init_pose); cout << (getTime() -tic) << " sec\n"; } }
void keyboardCallback(const pcl::visualization::KeyboardEvent &event, void* view3d_void) { View3D* view3d = (View3D*) view3d_void; std::string keysym = event.getKeySym(); if (event.keyDown()) { /* flags which are checked externaly */ if (keysym == "c") { view3d->flagCaptureFloor = true; } else if (keysym == "t") { view3d->flagExtractTemplate = true; } else if (keysym == "i") { view3d->flagTrack = true; } #ifdef BB_VERBOSE std::cout << "event: " << view3d->state << " " << keysym << std::endl; #endif /* interaction state machine */ switch (view3d->state) { case View3D::START: // start state if (keysym == "v") { view3d->state = View3D::GRAB; } else if (keysym == "b") { view3d->state = View3D::SCALE; } break; case View3D::GRAB: // move the cube if (keysym == "x") { view3d->state = View3D::GRABX; } else if (keysym == "y") { view3d->state = View3D::GRABY; } else if (keysym == "z") { view3d->state = View3D::GRABZ; } break; case View3D::GRABX: if (keysym == "Up") { view3d->moveCube(view3d->edit_stepsize, 0, 0); } else if (keysym == "Down") { view3d->moveCube(-view3d->edit_stepsize, 0, 0); } break; case View3D::GRABY: if (keysym == "Up") { view3d->moveCube(0, view3d->edit_stepsize, 0); } else if (keysym == "Down") { view3d->moveCube(0, -view3d->edit_stepsize, 0); } break; case View3D::GRABZ: if (keysym == "Up") { view3d->moveCube(0, 0, view3d->edit_stepsize); } else if (keysym == "Down") { view3d->moveCube(0, 0, -view3d->edit_stepsize); } break; case View3D::SCALE: if (keysym == "x") { view3d->state = View3D::SCALEX; } else if (keysym == "y") { view3d->state = View3D::SCALEY; } else if (keysym == "z") { view3d->state = View3D::SCALEZ; } break; case View3D::SCALEX: if (keysym == "Up") { view3d->sCube->setSx( view3d->sCube->getSx() + view3d->edit_stepsize); } else if (keysym == "Down") { view3d->sCube->setSx( view3d->sCube->getSx() - +view3d->edit_stepsize); } break; case View3D::SCALEY: if (keysym == "Up") { view3d->sCube->setSy( view3d->sCube->getSy() + view3d->edit_stepsize); } else if (keysym == "Down") { view3d->sCube->setSy( view3d->sCube->getSy() - view3d->edit_stepsize); } break; case View3D::SCALEZ: if (keysym == "Up") { view3d->sCube->setSz( view3d->sCube->getSz() + view3d->edit_stepsize); } else if (keysym == "Down") { view3d->sCube->setSz( view3d->sCube->getSz() - view3d->edit_stepsize); } break; defaul: // if state is not handled break; } /* for all states */ if (keysym == "Escape" || keysym == "Return") { view3d->state = View3D::START; } /**********************/ } }
void keyboardEventOccurred(const pcl::visualization::KeyboardEvent& event, void* nothing) { if (event.getKeySym() == "space" && event.keyDown()) next_iteration = true; }
void KeyboardEventOccurred(const pcl::visualization::KeyboardEvent &event, void * nothing){ if(event.keyDown ()) { //Save point cloud to .pcd file if(event.getKeySym() == "s") { stringstream stream; stream << "inputCloud" << filesSaved << ".pcd"; string filename = stream.str(); if (io::savePCDFileASCII(filename, *cloud) == 0) { filesSaved++; cout << "Saved " << filename << "." << endl; } else PCL_ERROR("Problem saving %s.\n", filename.c_str()); } //Find sphere using ransac and GA else if(event.getKeySym() == "n"){ cout << "Looking for sphere" << endl; test.setData(cloud, 0.05, 0.02); cout << "Data is set" << endl; test.compute(); cout << "Displaying best candidate" << endl; candidate = test.ranSph; newSphere = true; } //Find plane using ransac and GA else if(event.getKeySym() == "p"){ cout << "Looking for plane" << endl; plane.setData(cloud, 0.000005); cout << "Data is set" << endl; plane.compute(); cout << "Displaying best candidate" << endl; candidate = plane.ranPln; newPlane = true; grabNew = false; } //Segment found plane. NB: "p" have to be pressed first else if(event.getKeySym() == "o"){ plane.segmentPlane(); pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_p(new pcl::PointCloud<pcl::PointXYZRGB>); pcl::PointIndices::Ptr inliers (new pcl::PointIndices ()); inliers->indices = plane.indexlist; pcl::ExtractIndices<pcl::PointXYZRGB> extract; extract.setInputCloud (cloud); extract.setIndices (inliers); extract.setNegative (true); extract.filter (*cloud_p); cloud = cloud_p; } //refresh view and grab new frames else if(event.getKeySym() == "r"){ grabNew = true; refresh = true; } } }
void ICCVTutorial<FeatureType>::keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*) { if (event.keyUp()) { switch (event.getKeyCode()) { case '1': if (!visualizer_.removePointCloud("source_points")) { visualizer_.addPointCloud(source_, "source_points"); } break; case '2': if (!visualizer_.removePointCloud("target_points")) { visualizer_.addPointCloud(target_, "target_points"); } break; case '3': if (!visualizer_.removePointCloud("source_segmented")) { visualizer_.addPointCloud(source_segmented_, "source_segmented"); } break; case '4': if (!visualizer_.removePointCloud("target_segmented")) { visualizer_.addPointCloud(target_segmented_, "target_segmented"); } break; case '5': if (!visualizer_.removePointCloud("source_keypoints")) { pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZI> keypoint_color (source_keypoints_, 0, 0, 255); //pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZI> keypoint_color (source_keypoints_, "intensity"); visualizer_.addPointCloud(source_keypoints_, keypoint_color, "source_keypoints"); } break; case '6': if (!visualizer_.removePointCloud("target_keypoints")) { //pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZI> keypoint_color (target_keypoints_, "intensity"); pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZI> keypoint_color (target_keypoints_, 255, 0, 0); visualizer_.addPointCloud(target_keypoints_, keypoint_color, "target_keypoints"); } break; case '7': if (!show_source2target_) visualizer_.addCorrespondences<pcl::PointXYZI>(source_keypoints_, target_keypoints_, source2target_, "source2target"); else visualizer_.removeCorrespondences("source2target"); show_source2target_ = !show_source2target_; break; case '8': if (!show_target2source_) visualizer_.addCorrespondences<pcl::PointXYZI>(target_keypoints_, source_keypoints_, target2source_, "target2source"); else visualizer_.removeCorrespondences("target2source"); show_target2source_ = !show_target2source_; break; case '9': if (!show_correspondences) visualizer_.addCorrespondences<pcl::PointXYZI>(source_keypoints_, target_keypoints_, *correspondences_, "correspondences"); else visualizer_.removeCorrespondences("correspondences"); show_correspondences = !show_correspondences; break; case 'i': case 'I': if (!visualizer_.removePointCloud("transformed")) visualizer_.addPointCloud(source_transformed_, "transformed"); break; case 'r': case 'R': if (!visualizer_.removePointCloud("registered")) visualizer_.addPointCloud(source_registered_, "registered"); break; case 't': case 'T': visualizer_.addPolygonMesh(surface_, "surface"); break; } } }
void Viewer::keyboardEventOccurred( const pcl::visualization::KeyboardEvent &event, void* data ) { if( ( event.getKeySym() == "d" || event.getKeySym() == "D" ) && event.keyDown() ) { if( event.getKeySym() == "d" ) { selectedDepth++; } else { selectedDepth--; if( selectedDepth < 0 ) selectedDepth = 15; } selectedDepth = selectedDepth % 16; std::cout << "Selected Depth " << selectedDepth << "\n"; } if( ( event.getKeySym() == "v" || event.getKeySym() == "V" ) && event.keyDown() ) { if( event.getKeySym() == "v" ) { selectedViewDir++; if( selectedViewDir == 7 ) selectedViewDir = -1; } else { selectedViewDir--; if( selectedViewDir < -1 ) selectedViewDir = 6; } std::cout << "Selected View Dir " << selectedViewDir << "\n"; } if( ( event.getKeySym() == "p" ) && event.keyDown() ) { processFrame = true; } if( ( event.getKeySym() == "s" ) && event.keyDown() ) { displayScene = !displayScene; } if( ( event.getKeySym() == "m" ) && event.keyDown() ) { displayMap = !displayMap; } if( ( event.getKeySym() == "a" ) && event.keyDown() ) { displayAll = !displayAll; } if( ( event.getKeySym() == "c" ) && event.keyDown() ) { displayCorr = !displayCorr; } if( ( event.getKeySym() == "f" ) && event.keyDown() ) { forceRedraw = true; } }
void keyboardCallback (const pcl::visualization::KeyboardEvent& event, void*) { if (event.keyDown ()) { if (event.getKeyCode () == 'w' || event.getKeyCode () == 'W') { window_ += event.getKeyCode () == 'w' ? 1 : -1; if (window_ < 1) window_ = 1; pcl::console::print_info ("Temporal filtering window size: "); pcl::console::print_value ("%i\n", window_); grabber_.enableTemporalFiltering (temporal_filtering_, window_); } if (event.getKeyCode () == 't' || event.getKeyCode () == 'T') { threshold_ += event.getKeyCode () == 't' ? 10 : -10; if (threshold_ < 0) threshold_ = 0; pcl::console::print_info ("Confidence threshold: "); pcl::console::print_value ("%i\n", threshold_); grabber_.setConfidenceThreshold (threshold_); } if (event.getKeyCode () == 'k') { pcl::console::print_info ("Temporal filtering: "); switch (temporal_filtering_) { case pcl::DepthSenseGrabber::DepthSense_None: { temporal_filtering_ = pcl::DepthSenseGrabber::DepthSense_Median; pcl::console::print_value ("median\n"); break; } case pcl::DepthSenseGrabber::DepthSense_Median: { temporal_filtering_ = pcl::DepthSenseGrabber::DepthSense_Average; pcl::console::print_value ("average\n"); break; } case pcl::DepthSenseGrabber::DepthSense_Average: { temporal_filtering_ = pcl::DepthSenseGrabber::DepthSense_None; pcl::console::print_value ("none\n"); break; } } grabber_.enableTemporalFiltering (temporal_filtering_, window_); } if (event.getKeyCode () == 's') { boost::format fmt ("DS_%s_%u.pcd"); std::string fn = boost::str (fmt % grabber_.getDeviceSerialNumber ().c_str () % last_cloud_->header.stamp); pcl::io::savePCDFileBinaryCompressed (fn, *last_cloud_); pcl::console::print_info ("Saved point cloud: "); pcl::console::print_value (fn.c_str ()); pcl::console::print_info ("\n"); } displaySettings (); } }