Beispiel #1
0
void SimpleOpenNIViewer::keyboard_callback (const pcl::visualization::KeyboardEvent& event, void* cookie)
{

	unsigned char key = 0;
	

	string* message = (string*)cookie;
	cout << (*message) << " :: ";
	if (event.getKeyCode())
	{
		key = event.getKeyCode();
		//cout << "the key \'" << event.getKeyCode() << "\' (" << (int)event.getKeyCode() << ") was";
	}
	else
		;//cout << "the special key \'" << event.getKeySym() << "\' was";


	if (event.keyDown())
		;//cout << " pressed" << endl;
	else
	{
		if(key )
		{
			proc_key(key);

			//cout << " released" << endl;
			
		}

		
		

		
	}
}
Beispiel #2
0
void Visualizer::keyboardEventCloudViewer(const pcl::visualization::KeyboardEvent &event, void *)
{
  if(event.keyUp())
  {
    if(event.getKeySym() == "Left")
    {
      nextAnnotator();
    }
    else if(event.getKeySym() == "Right")
    {
      prevAnnotator();
    }
    else if(event.getKeySym() == "Escape")
    {
      shutdown();
    }
    else if(event.getKeySym() == "Insert")
    {
      save = true;
    }
    else if(event.getKeyCode() > 0)
    {
      callbackKeyHandler(event.getKeyCode(), DrawingAnnotator::CLOUD_VIEWER);
    }
  }
}
Beispiel #3
0
    void 
    keyboard_callback (const pcl::visualization::KeyboardEvent& event, void* cookie)
    {
      AGASTDemo* obj = static_cast<AGASTDemo*> (cookie);
      
      if (event.getKeyCode ())
      {
        std::stringstream ss; ss << event.getKeyCode ();
        obj->detector_type_ = atoi (ss.str ().c_str ());
        return;
      }

      if (event.getKeySym () == "Up")
      {
        if (obj->threshold_ <= 0.9)
        {
          PCL_INFO ("[keyboard_callback] Increase AGAST threshold from %f to %f.\n", obj->threshold_, obj->threshold_ + 0.01);
          obj->threshold_ += 0.01;
          return;
        }
        PCL_INFO ("[keyboard_callback] Increase AGAST threshold from %f to %f.\n", obj->threshold_, obj->threshold_ + 1);
        obj->threshold_ += 1;
        return;
      }

      if (event.getKeySym () == "Down")
      {
        if (obj->threshold_ <= 0)
          return;
        if (obj->threshold_ <= 1)
        {
          PCL_INFO ("[keyboard_callback] Decrease AGAST threshold from %f to %f.\n", obj->threshold_, obj->threshold_ - 0.01);
          obj->threshold_ -= 0.01;
          return;
        }
        PCL_INFO ("[keyboard_callback] Decrease AGAST threshold from %f to %f.\n", obj->threshold_, obj->threshold_ - 1);
        obj->threshold_ -= 1;
        return;
      }

      if (event.getKeySym () == "Right")
      {
        PCL_INFO ("[keyboard_callback] Increase AGAST BMAX from %f to %f.\n", obj->bmax_, obj->bmax_ + 1);
        obj->bmax_ += 1;
        return;
      }

      if (event.getKeySym () == "Left")
      {
        if (obj->bmax_ <= 0)
          return;
        PCL_INFO ("[keyboard_callback] Decrease AGAST BMAX from %f to %f.\n", obj->bmax_, obj->bmax_ - 1);
        obj->bmax_ -= 1;
        return;
      }
    }
Beispiel #4
0
 void
 keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
 {
   if (event.getKeyCode ())
     cout << "the key \'" << event.getKeyCode () << "\' (" << event.getKeyCode () << ") was";
   else
     cout << "the special key \'" << event.getKeySym () << "\' was";
   if (event.keyDown ())
     cout << " pressed" << endl;
   else
     cout << " released" << endl;
 }
Beispiel #5
0
 void
 keyboard_callback (const pcl::visualization::KeyboardEvent& event, void* cookie)
 {
     string* message = static_cast<string*> (cookie);
     cout << (*message) << " :: ";
     if (event.getKeyCode ())
         cout << "the key \'" << event.getKeyCode () << "\' (" << event.getKeyCode () << ") was";
     else
         cout << "the special key \'" << event.getKeySym () << "\' was";
     if (event.keyDown ())
         cout << " pressed" << endl;
     else
         cout << " released" << endl;
 }
Beispiel #6
0
void Inspector::keyboardCallback(const pcl::visualization::KeyboardEvent& event, void* cookie)
{
  if(event.keyDown()) {
    if(event.getKeyCode() == 'm') {
      toggleModel();
    }
    else if(event.getKeyCode() == 'c') {
      pcd_vis_.removeAllShapes();
    }
    else if(event.getKeyCode() == 27) {
      quitting_ = true;
    }
  }
}
/** \brief callback function for the PCLvisualizer */
void
keyboard_callback (const pcl::visualization::KeyboardEvent &event, void *cookie)
{
    if (event.keyDown())
    {
        switch (event.getKeyCode())
        {
        case 27:
        case (int)'q':
        case (int)'Q':
        case (int)'e':
        case (int)'E':
            cout << "Exiting program" << endl;
            quit = true;
            break;
        case (int)'s':
        case (int)'S':
            cout << "Saving volume and cloud" << endl;
            save = true;
            break;
        default:
            break;
        }
    }
}
void 
keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
{
  double opacity;
  if (event.keyUp())
  {
    switch (event.getKeyCode())
    {
      case '1':
        viewer.getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "nan boundary edges");
        viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "nan boundary edges");
        break;
      case '2':
        viewer.getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "occluding edges");
        viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "occluding edges");
        break;
      case '3':
        viewer.getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "occluded edges");
        viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "occluded edges");
        break;
      case '4':
        viewer.getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "high curvature edges");
        viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "high curvature edges");
        break;
      case '5':
        viewer.getPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, opacity, "rgb edges");
        viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 1.0-opacity, "rgb edges");
        break;
    }
  }
}
Beispiel #9
0
void 
keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
{
  /// If SPACE is pressed, trigger new cloud callback (only works if framerate is set to 0)
  if (event.getKeyCode() == ' ' && grabber)
    grabber->trigger ();
}
 void keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
 {
   // do stuff and visualize here
   if (event.keyUp ())
   {
     switch (event.getKeyCode ())
     {
       case 'b':
       case 'B':
         if (threshold_ < 0.1f)
           threshold_ += 0.001f;
         process ();
         break;
       case 'v':
       case 'V':
         if (threshold_ > 0.001f)
           threshold_ -= 0.001f;
         process ();
         break;
         
       case 'n':
       case 'N':
         depth_dependent_ = !depth_dependent_;
         process ();
         break;
         
       case 'm':
       case 'M':
         polygon_refinement_ = !polygon_refinement_;
         process ();
         break;
     }
   }
 }
 void keyboardCallback(const pcl::visualization::KeyboardEvent &event, void *) {
     std::string special_key = event.getKeyCode() ? "" : "special ";
     if (event.keyDown())
         Logger::log(Logger::INFO, "The %skey %c was pressed.", special_key.c_str(), event.getKeyCode());
     else
         Logger::log(Logger::INFO, "The %skey %c was released.", special_key.c_str(), event.getKeyCode());
 }
Beispiel #12
0
 void
 keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
 {
   static pcl::PCDWriter writer;
   static std::ostringstream frame;
   if (event.keyUp ())
   {
     if ((event.getKeyCode () == 's') || (event.getKeyCode () == 'S'))
     {
       boost::mutex::scoped_lock lock (cloud_mutex_);
       frame.str ("frame-");
       frame << boost::posix_time::to_iso_string (boost::posix_time::microsec_clock::local_time ()) << ".pcd";
       writer.writeBinaryCompressed (frame.str (), *cloud_);
       PCL_INFO ("Written cloud %s.\n", frame.str ().c_str ());
     }
   }
 }
void
keyboardCB (const pcl::visualization::KeyboardEvent &event, void* params_void)
{
  CallbackParameters* params = static_cast<CallbackParameters*> (params_void);

  if (event.getKeyCode () == 13 /*enter*/ && event.keyUp ())
    update (params);
  else if ( event.getKeyCode () == '1' && event.keyUp () )
  {
    // Switch models visibility
    params->show_models_ = !params->show_models_;

    for ( list<vtkActor*>::iterator it = params->model_actors_.begin () ; it != params->model_actors_.end () ; ++it )
      (*it)->SetVisibility (static_cast<int> (params->show_models_));

    params->viz_.getRenderWindow ()->Render ();
  }
}
Beispiel #14
0
 void 
 keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
 {
   if (event.keyUp ())
   {
     switch (event.getKeyCode ())
     {
       case 27:
       case 'Q':
       case 'q': quit_ = true; visualizer_->close ();
         break;
       case ' ': continuous_ = !continuous_;
         break;
     }
   }
 }
void
keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* stop_void)
{
  bool *stop;
  char *keyPressed = new char[50];

  // Copy the pressed key inside a var
  sprintf (keyPressed, "%c", event.getKeyCode ());
  stop = static_cast<bool *> (stop_void);

  // Check if 0 is pressed and return the value
  if (strpbrk ("0", keyPressed))
  {
    *stop = 1;
    //std::cout << "found " << *stop << std::endl;
  }
}
 void
     keyboard_callback (const pcl::visualization::KeyboardEvent& event, void *)
     {
       if (event.keyUp ())
       {
         switch (event.getKeyCode())
         {
           case 's':
           case 'S':
             saveCloud = true; // save pcd file
             break;
           case 't':
           case 'T':
             ++toggleView  %= 2; 
             break;
         }
       }	
     }
/** \brief Callback for setting options in the visualizer via keyboard.
 *  \param[in] event Registered keyboard event  */
void 
keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
{
  int key = event.getKeyCode ();
  
  if (event.keyUp ())    
    switch (key)
    {
      case (int)'1': show_voxel_centroids = !show_voxel_centroids; break;
      case (int)'2': show_supervoxels = !show_supervoxels; break;
      case (int)'3': show_graph = !show_graph; break;
      case (int)'4': show_normals = !show_normals; break;
      case (int)'5': show_supervoxel_normals = !show_supervoxel_normals; break;
      case (int)'0': show_refined = !show_refined; break;
      case (int)'h': case (int)'H': show_help = !show_help; break;
      default: break;
    }
    
}
 static void 
 keyboardCallback(const pcl::visualization::KeyboardEvent &e, void *cookie)
 {
   OpenNIShoter* recorder = reinterpret_cast<OpenNIShoter*> (cookie);
   
   int key = e.getKeyCode ();
   
   if (e.keyUp())
   {
     if ((key == 'q') || (key == 'Q'))
     {
       recorder->exit_ = true;
     }
     else if ((key == 's') || (key == 'S'))
     {
       recorder->get_image_ = true;
     }
   }
 }
Beispiel #19
0
void
DataCapture::keyboard_callback (const pcl::visualization::KeyboardEvent &event, void *cookie)
{
  DataCapture* capture = reinterpret_cast<DataCapture*> (cookie);

  if (event.keyDown())
  {
    switch (event.getKeyCode())
    {
      case 27:
      case (int)'q': case (int)'Q':
      case (int)'e': case (int)'E':
        // stop the grabber
        capture->quit_ = true;
        pc::print_info ("Exiting program.\n");
        break;

      case (int)'s': case (int)'S':
        // capture snapshot (if not currently capturing continuously)
        if (!capture->continuous_capture_)
        {
          capture->save_ = true;
          pc::print_highlight ("Recording snapshot.\n");
        }
        break;

      case (int)'t': case (int)'T':
          // start / stop continuous capture
          capture->continuous_capture_ = !capture->continuous_capture_;
          pc::print_highlight ("%s continuous recording of data.\n", (capture->continuous_capture_) ? "Starting" : "Stopping");
          break;

      default:
        break;
    }
  }
}
 void
 keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
 {
   boost::mutex::scoped_lock lock (mtx_);
   switch (event.getKeyCode ())
   {
     case '1':
       ne_.setNormalEstimationMethod (pcl::IntegralImageNormalEstimation<PointType, pcl::Normal>::COVARIANCE_MATRIX);
       std::cout << "switched to COVARIANCE_MATRIX method\n";
       break;
     case '2':
       ne_.setNormalEstimationMethod (pcl::IntegralImageNormalEstimation<PointType, pcl::Normal>::AVERAGE_3D_GRADIENT);
       std::cout << "switched to AVERAGE_3D_GRADIENT method\n";
       break;
     case '3':
       ne_.setNormalEstimationMethod (pcl::IntegralImageNormalEstimation<PointType, pcl::Normal>::AVERAGE_DEPTH_CHANGE);
       std::cout << "switched to AVERAGE_DEPTH_CHANGE method\n";
       break;
     case '4':
       ne_.setNormalEstimationMethod (pcl::IntegralImageNormalEstimation<PointType, pcl::Normal>::SIMPLE_3D_GRADIENT);
       std::cout << "switched to SIMPLE_3D_GRADIENT method\n";
       break;
   }
 }
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;
    }
  }
}
Beispiel #22
0
 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));
}
Beispiel #24
0
 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 ();
   }
 }
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;
}