Advertisement
SUGIYAMA

xyzrgbnormalpcd_argv

Nov 11th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 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.     {
  12.             int r,g,b;
  13.             if(argc!=3)
  14.    
  15.     pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBNormal>);
  16.    
  17.     //XYZファイルの読み込み
  18.    
  19.     std::ifstream ifs(argv[1]);
  20.     std::string buf;
  21.  
  22.     for(size_t i=0; ifs && getline(ifs, buf); i++)
  23.     {
  24.        
  25.         std::cout << buf << std::endl;
  26.         std::istringstream is(buf);
  27.  
  28.         pcl::PointXYZRGBNormal pnt;
  29.         is >> pnt.x
  30.            >> pnt.y
  31.            >> pnt.z
  32.            >> pnt.r
  33.            >> pnt.g
  34.            >> pnt.b
  35.            >> pnt.normal_x
  36.                >> pnt.normal_y
  37.                >> pnt.normal_z
  38.                    >> pnt.curvature;
  39.  
  40.         cloud->push_back ( pnt );
  41.  
  42.     }
  43.  
  44.     //pcdファイルに書き出し
  45.      pcl::io::savePCDFileASCII(argv[2], *cloud);
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement