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>
- 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);
- }
- 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 );
- }
- pcl::io::savePCDFileBinary(argv[2], *cloud);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment