forked from rachillesf/seg_pcd_visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud_viewer.cpp
More file actions
42 lines (37 loc) · 1.34 KB
/
Copy pathcloud_viewer.cpp
File metadata and controls
42 lines (37 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include "boost/filesystem.hpp"
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
using namespace boost::filesystem;
int main()
{
//point cloud object
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
//visualizator object
pcl::visualization::PCLVisualizer viewer;
//reader object
pcl::PCDReader reader;
//assuming the segmented clouds are at the current directory
path p (".");
directory_iterator end_itr;
// cycle through the directory
for (directory_iterator itr(p); itr != end_itr; ++itr){
// assign current file name to current_file and echo it out to the console.
std::string file = itr->path().string();
std::cout << file << std::endl;
boost::filesystem::path fe = itr->path().extension();
if(fe.string()==".pcd"){
std::cout << fe.string() << std::endl;
//set random colors to the colors vector
int c1 = rand() % 256;
int c2 = rand() % 256;
int c3 = rand() % 256;
reader.read (file, *cloud);
viewer.addPointCloud<pcl::PointXYZ>(cloud,
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ>(cloud,c1,c2,c3),
file);
}
}
viewer.spin();
}