24 #include <pcl/visualization/pcl_visualizer.h> 48 pc_color RED,
GREEN,
BLUE,
PINK,
ORANGE,
WHITE,
PURPLE,
YELLOW,
BROWN,
LIME,
CHERRY,
SKY,
PEACH;
61 ORANGE = { 1, 0.5, 0 };
63 PURPLE = { 0.4, 0, 1 };
64 YELLOW = { 1, 1, 0.3 };
65 BROWN = { 0.7, 0.4, 0.1};
67 CHERRY = { 1, 0, 0.5};
69 PEACH = { 1, 0.8, 0.6};
74 viewer_->setBackgroundColor(0, 0, 0);
75 viewer_->addCoordinateSystem(axis_scale_);
76 viewer_->initCameraParameters();
81 ROS_WARN(
"Press (X) on viewer to continue");
85 boost::this_thread::sleep(boost::posix_time::microseconds(100000));
96 viewer_->removeAllCoordinateSystems();
97 viewer_->removeAllPointClouds();
103 point_size_ = point_size;
108 axis_scale_ = axis_scale;
109 viewer_->addCoordinateSystem(axis_scale_);
114 normals_scale_ = normals_scale;
119 if (event.getKeySym() ==
"space" &&
event.keyDown())
120 pressed_space_ =
true;
128 template <
typename Po
intT>
131 pcl::visualization::PointCloudColorHandlerCustom<PointT> cloud_rgb(cloud, color.
r, color.
g, color.
b);
137 viewer_->updatePointCloud(cloud, cloud_rgb, name);
138 viewer_->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size_, name);
143 viewer_->addPointCloud<PointT>(cloud, cloud_rgb, name);
144 viewer_->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size_, name);
150 template <
typename Po
intT>
151 void addPCToViewer(
typename pcl::PointCloud<PointT>::Ptr cloud,
const std::string& name)
158 viewer_->updatePointCloud(cloud, name);
159 viewer_->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size_, name);
164 viewer_->addPointCloud<PointT>(cloud, name);
165 viewer_->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size_, name);
171 template <
typename Po
intT,
typename CloudT>
173 typename pcl::PointCloud<CloudT>::Ptr normals,
174 const std::string& name)
180 ROS_INFO(
"Update normals in Viewer");
183 viewer_->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size_, name);
189 viewer_->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size_, name);
193 template <
typename Po
intT>
195 typename pcl::PointCloud<PointT>::Ptr target_cloud,
196 pcl::CorrespondencesPtr correspondences)
200 ROS_INFO(
"Add correspondences between clouds in Viewer");
201 viewer_->addCorrespondences<PointT>(source_cloud, target_cloud, *correspondences);
210 ROS_INFO(
"Remove cloud from Viewer");
211 viewer_->removePointCloud(name);
218 ROS_INFO(
"Remove correspondences from Viewer");
219 viewer_->removeCorrespondences();
222 template <
typename Po
intT>
226 new pcl::visualization::PCLVisualizer(
"Pointcloud viewer"));
227 ROS_INFO(
"Display cloud in Viewer");
229 pc_viewer->setBackgroundColor(0, 0, 0);
230 pc_viewer->addPointCloud<PointT>(cloud,
"cloud");
231 pc_viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3);
232 pc_viewer->addCoordinateSystem(1.0);
233 pc_viewer->initCameraParameters();
235 while (!pc_viewer->wasStopped())
237 pc_viewer->spinOnce();
238 boost::this_thread::sleep(boost::posix_time::microseconds(100000));
246 new pcl::visualization::PCLVisualizer(
"Mesh mesh_viewer"));
249 mesh_viewer->setBackgroundColor(0, 0, 0);
250 mesh_viewer->addPolygonMesh(*mesh,
"meshes", 0);
251 mesh_viewer->addCoordinateSystem(1.0);
252 mesh_viewer->initCameraParameters();
254 while (!mesh_viewer->wasStopped())
256 mesh_viewer->spinOnce(100);
257 boost::this_thread::sleep(boost::posix_time::microseconds(100000));
static void visualizeMesh(pcl::PolygonMesh::Ptr mesh)
void setAxisScale(double axis_scale)
pcl::PointCloud< pcl::Normal > PointCloudNormal
void addPCToViewer(typename pcl::PointCloud< PointT >::Ptr cloud, const pc_color &color, const std::string &name)
void setNormalsScale(double normals_scale)
static void visualizePointCloud(typename pcl::PointCloud< PointT >::Ptr cloud)
void addCorrespondencesToViewer(typename pcl::PointCloud< PointT >::Ptr source_cloud, typename pcl::PointCloud< PointT >::Ptr target_cloud, pcl::CorrespondencesPtr correspondences)
void deletePCFromViewer(const std::string &name)
boost::shared_ptr< pcl::visualization::PCLVisualizer > viewer_
void setPointSize(double point_size)
void addPCToViewer(typename pcl::PointCloud< PointT >::Ptr cloud, const std::string &name)
void deleteCorrespondencesFromViewer()
pcl::PointCloud< pcl::PointXYZRGB > PointCloudRGB
pcl::PointCloud< pcl::PointXYZ > PointCloudXYZ
void keyboardCallback(const pcl::visualization::KeyboardEvent &event, void *nothing)
void checkForSpaceKeyPressed()
void addNormalsToViewer(typename pcl::PointCloud< PointT >::Ptr cloud, typename pcl::PointCloud< CloudT >::Ptr normals, const std::string &name)