#include <pcl/visualization/cloud_viewer.h>
#include <iostream>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
#include <fstream>
#include <sstream>
#include <string>
#include<vector>
using namespace std;
using namespace pcl;
int main()
{
ifstream myfile("lasercam_000200.txt");
vector<vector<double> > pts;
string line;
int ptNum1=0;
while(getline(myfile,line))
{
istringstream is(line);
vector<double> tmp(3);
is>>tmp[0]>>tmp[1]>>tmp[2];
pts.push_back(tmp);
ptNum1++;
}
myfile.close();
ifstream myfile2("raytrace_000200.txt");
while(getline(myfile2,line))
{
istringstream is(line);
vector<double> tmp(3);
is>>tmp[0]>>tmp[1]>>tmp[2];
pts.push_back(tmp);
}
myfile2.close();
cout<<pts.size()<<endl;
pcl::PointCloud<pcl::PointXYZRGB> cloud;
cloud.is_dense = true;
cloud.points.resize (pts.size());
for (size_t i = 0; i < cloud.points.size (); ++i)
{
cloud.points[i].x = pts[i][0];
cloud.points[i].y = pts[i][1];
cloud.points[i].z = pts[i][2];
uint8_t r,g,b;
if(i<ptNum1)
{
r=255;
g=0;
b=0;
}
else
{
r=255;
g=255;
b=255;
}
uint32_t rgb = ((uint32_t)r << 16 | (uint32_t)g << 8 | (uint32_t)b);
cloud.points[i].rgb=*reinterpret_cast<float*>(&rgb);
}
pcl::visualization::CloudViewer viewer ("Simple Cloud Viewer");
pcl::PointCloud<pcl::PointXYZRGB>::Ptr ptrCloud(&cloud);
viewer.showCloud (ptrCloud);
while (!viewer.wasStopped ())
{
}
return (0);
}
Wednesday, July 23, 2014
An example of using PCL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment