Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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