Advertisement
SUGIYAMA

xyzrgbnormalpcd

Sep 23rd, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. #include <sstream>
  5.  
  6. #include <pcl/io/pcd_io.h>
  7. #include <pcl/point_types.h>
  8.  
  9.  
  10. int main (int argc, char** argv){
  11.     char input_fname[2048];
  12.     char output_fname[2048];
  13.  
  14.     //ファイル名の読み込み
  15.     std::cout << "Input file name:";
  16.     std::cin >> input_fname;
  17.    
  18.  
  19.     pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBNormal>);
  20.    
  21.     //XYZファイルの読み込み
  22.    
  23.     std::ifstream ifs(input_fname);
  24.     std::string buf;
  25.  
  26.     for(size_t i=0; ifs && getline(ifs, buf); i++){
  27.        
  28.         std::cout << buf << std::endl;
  29.         std::istringstream is(buf);
  30.                 pcl::PointXYZRGBNormal pnt;
  31.         is >> pnt.x
  32.            >> pnt.y
  33.            >> pnt.z
  34.            >> pnt.r
  35.            >> pnt.g
  36.            >> pnt.b
  37.            >> pnt.normal_x
  38.            >> pnt.normal_y
  39.            >> pnt.normal_z
  40.            >> pnt.curvature;
  41.  
  42.         cloud->push_back ( pnt );
  43.  
  44.     }
  45.  
  46.     //pcdファイルに書き出し
  47.     std::cout << "Output file name:";
  48.     std::cin >> output_fname;
  49.     pcl::io::savePCDFileASCII(output_fname, *cloud);
  50.  
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement