Skip to content

Instantly share code, notes, and snippets.

@tejus-gupta
Last active March 24, 2018 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tejus-gupta/35c3f1e96c4ee746639de0ddfe45e733 to your computer and use it in GitHub Desktop.
Save tejus-gupta/35c3f1e96c4ee746639de0ddfe45e733 to your computer and use it in GitHub Desktop.
#include <pcl/visualization/cloud_viewer.h>
boost::shared_ptr<pcl::visualization::PCLVisualizer> cloudVis (pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud)
{
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
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->initCameraParameters ();
return (viewer);
}
int main()
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr (new pcl::PointCloud<pcl::PointXYZ>);
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
for(int k=0;k<10;k++)
{
pcl::PointXYZ point;
point.x = i;
point.y = j;
point.z = k;
cloud_ptr->points.push_back (point);
}
cloud_ptr->width = (int) cloud_ptr->points.size ();
cloud_ptr->height = 1;
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
viewer = cloudVis(cloud_ptr);
while (!viewer->wasStopped ())
{
viewer->spinOnce (100);
boost::this_thread::sleep (boost::posix_time::microseconds (100000));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment