Skip to content

Commit

Permalink
Merge pull request #401 from nizar-sallem/several_coordinate_system
Browse files Browse the repository at this point in the history
Add: ability to add/remove several coordinate systems
  • Loading branch information
jspricke committed Jan 21, 2014
2 parents 376d3d4 + bbf0ae6 commit 6bf4b81
Show file tree
Hide file tree
Showing 29 changed files with 117 additions and 51 deletions.
2 changes: 1 addition & 1 deletion apps/src/face_detection/filesystem_face_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void run(pcl::RFFaceDetectorTrainer & fdrf, typename pcl::PointCloud<PointInT>::
vis.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 14, "votes_cloud");
}

vis.addCoordinateSystem (0.1);
vis.addCoordinateSystem (0.1, "global");

std::vector<Eigen::VectorXf> heads;
fdrf.getDetectedFaces (heads);
Expand Down
2 changes: 1 addition & 1 deletion apps/src/face_detection/openni_face_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void run(pcl::RFFaceDetectorTrainer & fdrf, bool heat_map = false, bool show_vot
OpenNIFrameSource::PointCloudPtr scene_vis;

pcl::visualization::PCLVisualizer vis ("Face dection");
vis.addCoordinateSystem (0.1);
vis.addCoordinateSystem (0.1, "global");

//keyboard callback to stop getting frames and finalize application
boost::function<void(const pcl::visualization::KeyboardEvent&)> keyboard_cb = boost::bind (&OpenNIFrameSource::OpenNIFrameSource::onKeyboardEvent, &camera,
Expand Down
2 changes: 1 addition & 1 deletion apps/src/openni_organized_edge_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class OpenNIOrganizedEdgeDetection
viewer->setSize (640, 480);
viewer->addPointCloud<PointT> (cloud, "cloud");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud");
viewer->addCoordinateSystem (0.2f);
viewer->addCoordinateSystem (0.2f, "global");
viewer->initCameraParameters ();
viewer->registerKeyboardCallback (&OpenNIOrganizedEdgeDetection::keyboard_callback, *this);
viewer->resetCameraViewpoint ("cloud");
Expand Down
2 changes: 1 addition & 1 deletion apps/src/openni_organized_multi_plane_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class OpenNIOrganizedMultiPlaneSegmentation
viewer->addPointCloud<PointT> (cloud, single_color, "cloud");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 0.15, "cloud");
viewer->addCoordinateSystem (1.0);
viewer->addCoordinateSystem (1.0, "global");
viewer->initCameraParameters ();
return (viewer);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/src/pcd_organized_edge_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ compute (const pcl::PCLPointCloud2::ConstPtr &input, pcl::PCLPointCloud2 &output

// Display edges in PCLVisualizer
viewer.setSize (640, 480);
viewer.addCoordinateSystem (0.2f);
viewer.addCoordinateSystem (0.2f, "global");
viewer.addPointCloud (cloud, "original point cloud");
viewer.registerKeyboardCallback(&keyboard_callback);

Expand Down
2 changes: 1 addition & 1 deletion apps/src/pcd_organized_multi_plane_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class PCDOrganizedMultiPlaneSegmentation
viewer.setBackgroundColor (0, 0, 0);
//viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "cloud");
//viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY, 0.15, "cloud");
viewer.addCoordinateSystem (1.0);
viewer.addCoordinateSystem (1.0, "global");
viewer.initCameraParameters ();
viewer.registerKeyboardCallback(&PCDOrganizedMultiPlaneSegmentation::keyboard_callback, *this, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/src/pcd_select_object_plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ class ObjectSelection

cloud_viewer_->addPointCloud (cloud_, "scene");
cloud_viewer_->resetCameraViewpoint ("scene");
cloud_viewer_->addCoordinateSystem (0.1, 0, 0, 0);
cloud_viewer_->addCoordinateSystem (0.1, 0, 0, 0, "global");
}

/////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion apps/src/stereo_ground_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class HRCSSegmentation

// Set up a 3D viewer
viewer->setBackgroundColor (0, 0, 0);
viewer->addCoordinateSystem (1.0);
viewer->addCoordinateSystem (1.0, "global");
viewer->initCameraParameters ();
viewer->registerKeyboardCallback (&HRCSSegmentation::keyboardCallback, *this, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ main (int argc, char** argv)
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointWithRange> range_image_color_handler (range_image_ptr, 0, 0, 0);
viewer.addPointCloud (range_image_ptr, range_image_color_handler, "range image");
viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "range image");
//viewer.addCoordinateSystem (1.0f);
//viewer.addCoordinateSystem (1.0f, "global");
//PointCloudColorHandlerCustom<PointType> point_cloud_color_handler (point_cloud_ptr, 150, 150, 150);
//viewer.addPointCloud (point_cloud_ptr, point_cloud_color_handler, "original point cloud");
viewer.initCameraParameters ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ main (int argc, char** argv)
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointWithRange> range_image_color_handler (range_image_ptr, 0, 0, 0);
viewer.addPointCloud (range_image_ptr, range_image_color_handler, "range image");
viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "range image");
//viewer.addCoordinateSystem (1.0f);
//viewer.addCoordinateSystem (1.0f, "global");
//PointCloudColorHandlerCustom<PointType> point_cloud_color_handler (point_cloud_ptr, 150, 150, 150);
//viewer.addPointCloud (point_cloud_ptr, point_cloud_color_handler, "original point cloud");
viewer.initCameraParameters ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ main (int argc, char** argv)
1, "output cloud");

// Starting visualizer
viewer_final->addCoordinateSystem (1.0);
viewer_final->addCoordinateSystem (1.0, "global");
viewer_final->initCameraParameters ();

// Wait until visualizer window is closed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int main (int argc, char** argv)
pcl::visualization::RangeImageVisualizer range_image_widget ("Range Image");

pcl::visualization::PCLVisualizer viewer ("3D Viewer");
viewer.addCoordinateSystem (1.0f);
viewer.addCoordinateSystem (1.0f, "global");
viewer.setBackgroundColor (1, 1, 1);

viewer.initCameraParameters ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main (int argc, char** argv)
pcl::visualization::RangeImageVisualizer range_image_widget ("Range Image");

pcl::visualization::PCLVisualizer viewer ("3D Viewer");
viewer.addCoordinateSystem (1.0f);
viewer.addCoordinateSystem (1.0f, "global");
viewer.setBackgroundColor (1, 1, 1);

// Set the viewing pose so that the openni cloud is visible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ boost::shared_ptr<pcl::visualization::PCLVisualizer> simpleVis (pcl::PointCloud<
viewer->setBackgroundColor (0, 0, 0);
viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
viewer->addCoordinateSystem (1.0);
viewer->addCoordinateSystem (1.0, "global");
viewer->initCameraParameters ();
return (viewer);
}
Expand All @@ -56,7 +56,7 @@ boost::shared_ptr<pcl::visualization::PCLVisualizer> rgbVis (pcl::PointCloud<pcl
pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(cloud);
viewer->addPointCloud<pcl::PointXYZRGB> (cloud, rgb, "sample cloud");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud");
viewer->addCoordinateSystem (1.0);
viewer->addCoordinateSystem (1.0, "global");
viewer->initCameraParameters ();
return (viewer);
}
Expand All @@ -72,7 +72,7 @@ boost::shared_ptr<pcl::visualization::PCLVisualizer> customColourVis (pcl::Point
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> single_color(cloud, 0, 255, 0);
viewer->addPointCloud<pcl::PointXYZ> (cloud, single_color, "sample cloud");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud");
viewer->addCoordinateSystem (1.0);
viewer->addCoordinateSystem (1.0, "global");
viewer->initCameraParameters ();
return (viewer);
}
Expand All @@ -90,7 +90,7 @@ boost::shared_ptr<pcl::visualization::PCLVisualizer> normalsVis (
viewer->addPointCloud<pcl::PointXYZRGB> (cloud, rgb, "sample cloud");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud");
viewer->addPointCloudNormals<pcl::PointXYZRGB, pcl::Normal> (cloud, normals, 10, 0.05, "normals");
viewer->addCoordinateSystem (1.0);
viewer->addCoordinateSystem (1.0, "global");
viewer->initCameraParameters ();
return (viewer);
}
Expand All @@ -106,7 +106,7 @@ boost::shared_ptr<pcl::visualization::PCLVisualizer> shapesVis (pcl::PointCloud<
pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(cloud);
viewer->addPointCloud<pcl::PointXYZRGB> (cloud, rgb, "sample cloud");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud");
viewer->addCoordinateSystem (1.0);
viewer->addCoordinateSystem (1.0, "global");
viewer->initCameraParameters ();

//------------------------------------
Expand Down Expand Up @@ -164,7 +164,7 @@ boost::shared_ptr<pcl::visualization::PCLVisualizer> viewportsVis (

viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud1");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud2");
viewer->addCoordinateSystem (1.0);
viewer->addCoordinateSystem (1.0, "global");

viewer->addPointCloudNormals<pcl::PointXYZRGB, pcl::Normal> (cloud, normals1, 10, 0.05, "normals1", v1);
viewer->addPointCloudNormals<pcl::PointXYZRGB, pcl::Normal> (cloud, normals2, 10, 0.05, "normals2", v2);
Expand Down Expand Up @@ -211,7 +211,7 @@ boost::shared_ptr<pcl::visualization::PCLVisualizer> interactionCustomizationVis
{
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
viewer->setBackgroundColor (0, 0, 0);
viewer->addCoordinateSystem (1.0);
viewer->addCoordinateSystem (1.0, "global");

viewer->registerKeyboardCallback (keyboardEventOccurred, (void*)&viewer);
viewer->registerMouseCallback (mouseEventOccurred, (void*)&viewer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ simpleVis (pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud)
viewer->setBackgroundColor (0, 0, 0);
viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud");
//viewer->addCoordinateSystem (1.0);
//viewer->addCoordinateSystem (1.0, "global");
viewer->initCameraParameters ();
return (viewer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ main (int argc, char** argv)
// --------------------------------------------
pcl::visualization::PCLVisualizer viewer ("3D Viewer");
viewer.setBackgroundColor (1, 1, 1);
viewer.addCoordinateSystem (1.0f);
viewer.addCoordinateSystem (1.0f, "global");
pcl::visualization::PointCloudColorHandlerCustom<PointType> point_cloud_color_handler (point_cloud_ptr, 0, 0, 0);
viewer.addPointCloud (point_cloud_ptr, point_cloud_color_handler, "original point cloud");
//PointCloudColorHandlerCustom<pcl::PointWithRange> range_image_color_handler (range_image_ptr, 150, 150, 150);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ main (int argc, char** argv)
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointWithRange> range_image_color_handler (range_image_ptr, 0, 0, 0);
viewer.addPointCloud (range_image_ptr, range_image_color_handler, "range image");
viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "range image");
//viewer.addCoordinateSystem (1.0f);
//viewer.addCoordinateSystem (1.0f, "global");
//PointCloudColorHandlerCustom<PointType> point_cloud_color_handler (point_cloud_ptr, 150, 150, 150);
//viewer.addPointCloud (point_cloud_ptr, point_cloud_color_handler, "original point cloud");
viewer.initCameraParameters ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ main (int argc, char** argv)
p.addText (cloud_name, 20, 10, cloud_name, viewport);
}
// Add coordianate systems to all viewports
p.addCoordinateSystem (0.1, 0);
p.addCoordinateSystem (0.1, "global", 0);

p.spin ();
return (0);
Expand Down
2 changes: 1 addition & 1 deletion tools/obj_rec_ransac_hash_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ visualize (const ModelLibrary::HashTable& hash_table)
}
}

vis.addCoordinateSystem(1.5);
vis.addCoordinateSystem(1.5, "global");
vis.resetCamera ();

// Enter the main loop
Expand Down
3 changes: 2 additions & 1 deletion visualization/include/pcl/visualization/common/actor_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ namespace pcl
typedef boost::unordered_map<std::string, vtkSmartPointer<vtkProp> > ShapeActorMap;
typedef boost::shared_ptr<ShapeActorMap> ShapeActorMapPtr;

typedef std::map<int, vtkSmartPointer<vtkProp> > CoordinateActorMap;
typedef boost::unordered_map<std::string, vtkSmartPointer<vtkProp> > CoordinateActorMap;
typedef boost::shared_ptr<CoordinateActorMap> CoordinateActorMapPtr;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pcl::RegistrationVisualizer<PointSource, PointTarget>::runDisplay ()
size_t correspondeces_old_size = 0;

// Add coordinate system to both ports
viewer_->addCoordinateSystem (1.0);
viewer_->addCoordinateSystem (1.0, "global");

// The root name of correspondence lines
std::string line_root_ = "line";
Expand Down
50 changes: 45 additions & 5 deletions visualization/include/pcl/visualization/pcl_visualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,23 +278,55 @@ namespace pcl
* \param[in] scale the scale of the axes (default: 1)
* \param[in] viewport the view port where the 3D axes should be added (default: all)
*/
PCL_DEPRECATED (void addCoordinateSystem (double scale, int viewport = 0),
"addCoordinateSystem (scale, viewport) is deprecated, please use function "
"addCoordinateSystem (scale, id, viewport) with id a unique string identifier.");

/** \brief Adds 3D axes describing a coordinate system to screen at 0,0,0.
* \param[in] scale the scale of the axes (default: 1)
* \param[in] id the coordinate system object id (default: reference)
* \param[in] viewport the view port where the 3D axes should be added (default: all)
*/
void
addCoordinateSystem (double scale = 1.0, int viewport = 0);
addCoordinateSystem (double scale = 1.0, const std::string& id = "reference", int viewport = 0);

/** \brief Adds 3D axes describing a coordinate system to screen at x, y, z
* \param[in] scale the scale of the axes (default: 1)
* \param[in] x the X position of the axes
* \param[in] y the Y position of the axes
* \param[in] z the Z position of the axes
* \param[in] viewport the view port where the 3D axes should be added (default: all)
*/
PCL_DEPRECATED (void addCoordinateSystem (double scale, float x, float y, float z, int viewport = 0),
"addCoordinateSystem (scale, x, y, z, viewport) is deprecated, please use function "
"addCoordinateSystem (scale, x, y, z, id, viewport) with id a unique string identifier.");

/** \brief Adds 3D axes describing a coordinate system to screen at x, y, z
* \param[in] scale the scale of the axes (default: 1)
* \param[in] x the X position of the axes
* \param[in] y the Y position of the axes
* \param[in] z the Z position of the axes
* \param[in] id the coordinate system object id (default: reference)
* \param[in] viewport the view port where the 3D axes should be added (default: all)
*/
void
addCoordinateSystem (double scale, float x, float y, float z, int viewport = 0);
addCoordinateSystem (double scale, float x, float y, float z, const std::string &id = "reference", int viewport = 0);

/** \brief Adds 3D axes describing a coordinate system to screen at x, y, z, Roll,Pitch,Yaw
*
* \param[in] scale the scale of the axes (default: 1)
* \param[in] t transformation matrix
* \param[in] viewport the view port where the 3D axes should be added (default: all)
*/
PCL_DEPRECATED (void addCoordinateSystem (double scale, const Eigen::Affine3f& t, int viewport = 0),
"addCoordinateSystem (scale, t, viewport) is deprecated, please use function "
"addCoordinateSystem (scale, t, id, viewport) with id a unique string identifier.");

/** \brief Adds 3D axes describing a coordinate system to screen at x, y, z, Roll,Pitch,Yaw
*
* \param[in] scale the scale of the axes (default: 1)
* \param[in] t transformation matrix
* \param[in] id the coordinate system object id (default: reference)
* \param[in] viewport the view port where the 3D axes should be added (default: all)
*
* RPY Angles
Expand Down Expand Up @@ -323,13 +355,21 @@ namespace pcl
* y
*/
void
addCoordinateSystem (double scale, const Eigen::Affine3f& t, int viewport = 0);
addCoordinateSystem (double scale, const Eigen::Affine3f& t, const std::string &id = "reference", int viewport = 0);

/** \brief Removes a previously added 3D axes (coordinate system)
* \param[in] viewport view port where the 3D axes should be removed from (default: all)
*/
PCL_DEPRECATED (bool removeCoordinateSystem (int viewport = 0),
"removeCoordinateSystem (viewport) is deprecated, please use function "
"addCoordinateSystem (id, viewport) with id a unique string identifier.");

/** \brief Removes a previously added 3D axes (coordinate system)
* \param[in] id the coordinate system object id (default: reference)
* \param[in] viewport view port where the 3D axes should be removed from (default: all)
*/
bool
removeCoordinateSystem (int viewport = 0);
removeCoordinateSystem (const std::string &id = "reference", int viewport = 0);

/** \brief Removes a Point Cloud from screen, based on a given ID.
* \param[in] id the point cloud object id (i.e., given on \a addPointCloud)
Expand Down Expand Up @@ -1769,7 +1809,7 @@ namespace pcl
ShapeActorMapPtr shape_actor_map_;

/** \brief Internal list with actor pointers and viewpoint for coordinates. */
CoordinateActorMap coordinate_actor_map_;
CoordinateActorMapPtr coordinate_actor_map_;

/** \brief Internal pointer to widget which contains a set of axes */
vtkSmartPointer<vtkOrientationMarkerWidget> axes_widget_;
Expand Down
2 changes: 1 addition & 1 deletion visualization/src/cloud_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ struct pcl::visualization::CloudViewer::CloudViewer_impl
viewer_ = boost::shared_ptr<PCLVisualizer>(new PCLVisualizer (window_name_, true));
#endif
viewer_->setBackgroundColor (0.1, 0.1, 0.1);
viewer_->addCoordinateSystem (0.1);
viewer_->addCoordinateSystem (0.1, "global");

while (!quit_)
{
Expand Down
Loading

0 comments on commit 6bf4b81

Please sign in to comment.