Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************************************************************
- Read file : TXT file
- Output File : PCD file format
- XYZRGBNormal 2 PCD
- *************************************************************************************************/
- #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)
- {
- float r,g,b;
- if(argc!=3)
- {
- fprintf(stderr,"Usage: %s\n(1)Input_XYZRGBNormal_filename\n(2)Output_Text_Filename\n",argv[0]);
- exit(1);
- }
- pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBNormal>);
- //XYZRGBNormalファイルの読み込み
- //std::ifstream ifs(input_fname);
- //std:ifstream Input file stream class
- std::ifstream ifs(argv[1]);
- //std:strings Strings are objects that represent sequences of characters.
- std::string buf;
- for(size_t i=0; ifs && getline(ifs, buf); i++)
- {
- std::cout << buf << std::endl;
- std::istringstream is(buf);
- pcl::PointXYZRGBNormal pnt;
- is >> pnt.x
- >> pnt.y
- >> pnt.z
- >> r
- >> g
- >> b
- >> pnt.normal_x
- >> pnt.normal_y
- >> pnt.normal_z
- >> pnt.curvature;
- pnt.r= (uint8_t)r;
- pnt.g= (uint8_t)g;
- pnt.b= (uint8_t)b;
- cloud->push_back ( pnt );
- }
- //pcdファイルに書き出し
- //std::cout << "Output file name:";
- //std::cin >> output_fname;
- pcl::io::savePCDFileASCII(argv[2], *cloud);
- //pcl::io::savePCDFileASCII(output_fname, *cloud);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement