1 #include <pcl/io/pcd_io.h> 2 #include <pcl/point_types.h> 3 #include <pcl/visualization/cloud_viewer.h> 4 #include <vtkRenderWindow.h> 5 #include <vtkRendererCollection.h> 8 std::vector<pcl::PointCloud<pcl::PointXYZRGB>::Ptr>
clouds;
14 pcl::visualization::PCLVisualizer *
viewer =
static_cast<pcl::visualization::PCLVisualizer *
> (viewer_void);
16 if (event.getKeySym () ==
"n" &&
rank+1 <
clouds.size()){
18 viewer->removePointCloud(
"test");
20 }
else if (event.getKeySym() ==
"p" &&
rank-1 >= 0){
22 viewer->removePointCloud(
"test");
24 }
else if (event.getKeySym() ==
"r"){
25 viewer->setCameraPosition(0,10,0,0,0,0,0,0,1);
28 std::cout <<
rank+1 <<
"/" <<
clouds.size() << std::endl;
32 int main(
int argc,
char *argv[])
35 std::cerr <<
"Usage:" << argv[0] <<
"[point cloud log file]" << std::endl;
39 std::ifstream
ifs(argv[1]);
41 std::cerr <<
"can't open " << argv[1] << std::endl;
46 int w,
h, npoint, r=255,g=255,
b=255;
52 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
54 ifs >> w >> h >> type >> npoint;
55 cloud->points.resize(npoint);
56 for (
int i=0;
i<npoint;
i++){
58 if (type ==
"xyzrgb"){
61 cloud->points[
i].x =
x;
62 cloud->points[
i].y =
y;
63 cloud->points[
i].z =
z;
64 cloud->points[
i].r = r;
65 cloud->points[
i].g = g;
66 cloud->points[
i].b =
b;
71 if (
clouds.size()==0)
return 3;
73 pcl::visualization::PCLVisualizer
viewer(
"Cloud Viewer");
74 viewer.getRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetParallelProjection(1);
76 viewer.setCameraPosition(0, 10, 0, 0, 0, 0, 0, 0, 1);
77 viewer.setCameraClipDistances(1, 100);
78 viewer.addPointCloud(
clouds[0],
"test");
80 while (!viewer.wasStopped ()){
81 viewer.spinOnce (100);
82 boost::this_thread::sleep (boost::posix_time::microseconds (100000));
std::vector< pcl::PointCloud< pcl::PointXYZRGB >::Ptr > clouds
png_infop png_charp png_int_32 png_int_32 int * type
int main(int argc, char *argv[])
void keyboardEventOccurred(const pcl::visualization::KeyboardEvent &event, void *viewer_void)