Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- #include <sstream>
- #include <pcl/io/pcd_io.h>
- #include <pcl/point_types.h>
- using namespace std;
- int main (int argc, char** argv)
- {
- int r,g,b;
- //if(argc!=3)
- //{
- //fprintf(stderr,"Usage: %s\n(1)Input_XYZ_filename\n(2)Output_PCD_filename\n",argv[0]);
- //exit(1);
- //}
- if(argc != 3)
- {
- cout << "You need to supply one argument to this program."<<endl;
- cout << "(1)Input_XYZRGB.pcd_filename"<<endl;
- cout << "(2)Output_XYZRGB.xyz_filename"<<endl;
- return -1;
- }
- pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
- pcl::io::loadPCDFile (argv[1], *cloud);
- ofstream ofs;
- ofs.open(argv[2]);
- //pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
- //Open XYZ file
- //std::ifstream ifs(argv[1]);
- //std::string buf;
- ////Load XYZ file
- //for(size_t i=0; ifs && getline(ifs, buf); i++)
- //{
- //std::cout << buf << std::endl;
- //std::istringstream is(buf);
- //pcl::PointXYZRGB pnt;
- //is >> pnt.x
- //>> pnt.y
- //>> pnt.z;
- //cloud->push_back ( pnt );
- //}
- for(size_t i=0; i < cloud->points.size() ; i++)
- {
- ofs << setprecision(3)
- << fixed << cloud->points[i].x << " "
- << fixed << cloud->points[i].y << " "
- << fixed << cloud->points[i].z << " "
- << (int)cloud->points[i].r << " "
- << (int)cloud->points[i].g << " "
- << (int)cloud->points[i].b << endl;
- //<< fixed << normals->points[i].normal_x << " "
- //<< fixed << normals->points[i].normal_y << " "
- //<< fixed << normals->points[i].normal_z << endl;
- }
- //ofs.close();
- //pcl::io::savePCDFileASCII(argv[2], *cloud);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement