Advertisement
ait-survey

xyzrgbnormal-2-xyznormal8bit

Oct 29th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. /***********************************************************************************************
  2. Read file
  3. Output File : PCD file format
  4.  
  5. xyzrgbnormal-2-xyznormal8bit
  6.  
  7. *************************************************************************************************/
  8.  
  9.  
  10. #include <iostream>
  11. #include <iomanip>
  12. #include <fstream>
  13. #include <sstream>
  14.  
  15. #include <pcl/io/pcd_io.h>
  16. #include <pcl/point_types.h>
  17.  
  18.  
  19. int main (int argc, char** argv)
  20. {
  21.     if(argc!=3)
  22.         {
  23.                 fprintf(stderr,"Usage: %s\n(1)Input_XYZRGBNormal_filename\n(2)Output_normal8bit_Filename\n",argv[0]);
  24.                 exit(1);
  25.         }
  26.  
  27.     pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBNormal>);
  28.    
  29.     //Load XYZRGBNormal file
  30.    
  31.     //std::ifstream ifs(input_fname);
  32.     //std:ifstream Input file stream class
  33.     std::ifstream ifs(argv[1]);
  34.    
  35.     //std:strings Strings are objects that represent sequences of characters.
  36.     std::string buf;
  37.  
  38.     for(size_t i=0; ifs && getline(ifs, buf); i++)
  39.     {
  40.        
  41.         std::cout << buf << std::endl;
  42.         std::istringstream is(buf);
  43.         pcl::PointXYZRGBNormal pnt;
  44.         is >> pnt.x
  45.            >> pnt.y
  46.            >> pnt.z
  47.            >> pnt.r
  48.            >> pnt.g
  49.            >> pnt.b
  50.            >> pnt.normal_x
  51.            >> pnt.normal_y
  52.            >> pnt.normal_z
  53.            >> pnt.curvature;
  54.         cloud->push_back ( pnt );
  55.  
  56.     }
  57.  
  58.     //pcdファイルに書き出し
  59.     //std::cout << "Output file name:";
  60.     //std::cin >> output_fname;
  61.    
  62.     pcl::io::savePCDFileASCII(argv[2], *cloud);
  63.  
  64.     //pcl::io::savePCDFileASCII(output_fname, *cloud);
  65.  
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement