subsampleRandom.cc
Go to the documentation of this file.
00001 #include <pointcloud_utils.h>
00002 
00003 using namespace std;
00004 using namespace lslgeneric;
00005 
00006 int main(int argc, char **argv)
00007 {
00008 
00009     if(argc!=2)
00010     {
00011         cout<<argv[0]<<" nameOfScan.wrl\n";
00012         return -1;
00013     }
00014 
00015     pcl::PointCloud<pcl::PointXYZ> pc = readVRML<pcl::PointXYZ>(argv[1]), pcs;
00016     char fname[500];
00017     snprintf(fname,499,"%s_subsampled.wrl",argv[1]);
00018 
00019     double retain_percentage = 0.05;
00020     for(int i=0; i<pc.points.size(); i++)
00021     {
00022         double r = (double)rand()/(double)RAND_MAX;
00023         if(r < retain_percentage)
00024         {
00025             pcl::PointXYZ pt = pc.points[i];
00026             pt.x = pt.x*100;
00027             pt.y = pt.y*100;
00028             pt.z = pt.z*100;
00029             pcs.points.push_back(pt);
00030         }
00031     }
00032     writeToVRML<pcl::PointXYZ>(fname,pcs);
00033 
00034     return 0;
00035 }


pointcloud_vrml
Author(s): Todor Stoyanov
autogenerated on Wed Oct 8 2014 23:30:29