test_grabbers.cpp
Go to the documentation of this file.
00001 #include <gtest/gtest.h>
00002 #include <pcl/point_types.h>
00003 #include <pcl/common/io.h>
00004 #include <pcl/io/pcd_io.h>
00005 #include <pcl/io/pcd_grabber.h>
00006 #include <pcl/io/image_grabber.h>
00007 #include <pcl/console/time.h>
00008 
00009 #include <string>
00010 #include <vector>
00011 
00012 using namespace std;
00013 
00014 typedef pcl::PointXYZRGBA PointT;
00015 typedef pcl::PointCloud<PointT> CloudT;
00016 
00017 string tiff_dir_;
00018 string pclzf_dir_;
00019 string pcd_dir_;
00020 vector<CloudT::ConstPtr> pcds_;
00021 vector<std::string> pcd_files_;
00022 
00023 
00024 // Helper function for grabbing a cloud
00025 void
00026 cloud_callback (bool *signal_received, 
00027                 CloudT::ConstPtr *ptr_to_fill, 
00028                 const CloudT::ConstPtr &input_cloud)
00029 {
00030   *signal_received = true;
00031   *ptr_to_fill = input_cloud;
00032 }
00033 
00034 // Helper function for grabbing a cloud (vector
00035 void
00036 cloud_callback_vector (std::vector<CloudT::ConstPtr> *vector_to_fill, 
00037                        const CloudT::ConstPtr &input_cloud)
00038 {
00039   vector_to_fill->push_back (input_cloud);
00040 }
00041 
00042 TEST (PCL, PCDGrabber)
00043 {
00044   pcl::PCDGrabber<PointT> grabber (pcd_files_, 10, false); // TODO add directory functionality
00045   EXPECT_EQ (grabber.size (), pcds_.size ());
00046   vector<CloudT::ConstPtr> grabbed_clouds;
00047   boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> 
00048     fxn = boost::bind (cloud_callback_vector, &grabbed_clouds, _1);
00049   grabber.registerCallback (fxn);
00050   grabber.start ();
00051   // 1 second should be /plenty/ of time
00052   boost::this_thread::sleep (boost::posix_time::microseconds (1E6));
00053   grabber.stop ();
00054 
00056   ASSERT_EQ (pcds_.size (), grabbed_clouds.size ());
00057   for (size_t i = 0; i < pcds_.size (); i++)
00058   {
00059     // Also compare against FileGrabber-style loaded cloud
00060     CloudT::ConstPtr cloud_from_file_grabber = grabber[i];
00061     EXPECT_EQ (grabbed_clouds[i]->size (), pcds_[i]->size ());
00062     EXPECT_EQ (cloud_from_file_grabber->size (), pcds_[i]->size ());
00063     for (size_t j = 0; j < pcds_[i]->size (); j++)
00064     {
00065       const PointT &pcd_pt = pcds_[i]->at(j);
00066       const PointT &grabbed_pt = grabbed_clouds[i]->at(j);
00067       const PointT &fg_pt = cloud_from_file_grabber->at(j);
00068       if (pcl_isnan (pcd_pt.x))
00069       {
00070         EXPECT_TRUE (pcl_isnan (grabbed_pt.x));
00071         EXPECT_TRUE (pcl_isnan (fg_pt.x));
00072       }
00073       else
00074       {
00075         EXPECT_FLOAT_EQ (pcd_pt.x, grabbed_pt.x);
00076         EXPECT_FLOAT_EQ (pcd_pt.x, fg_pt.x);
00077       }
00078       if (pcl_isnan (pcd_pt.y))
00079       {
00080         EXPECT_TRUE (pcl_isnan (grabbed_pt.y));
00081         EXPECT_TRUE (pcl_isnan (fg_pt.y));
00082       }
00083       else
00084       {
00085         EXPECT_FLOAT_EQ (pcd_pt.y, grabbed_pt.y);
00086         EXPECT_FLOAT_EQ (pcd_pt.y, fg_pt.y);
00087       }
00088       if (pcl_isnan (pcd_pt.z))
00089       {
00090         EXPECT_TRUE (pcl_isnan (grabbed_pt.z));
00091         EXPECT_TRUE (pcl_isnan (fg_pt.z));
00092       }
00093       else
00094       {
00095         EXPECT_FLOAT_EQ (pcd_pt.z, grabbed_pt.z);
00096         EXPECT_FLOAT_EQ (pcd_pt.z, fg_pt.z);
00097       }
00098       EXPECT_EQ (pcd_pt.r, grabbed_pt.r);
00099       EXPECT_EQ (pcd_pt.g, grabbed_pt.g);
00100       EXPECT_EQ (pcd_pt.b, grabbed_pt.b);
00101       EXPECT_EQ (pcd_pt.a, grabbed_pt.a);
00102       EXPECT_EQ (pcd_pt.r, fg_pt.r);
00103       EXPECT_EQ (pcd_pt.g, fg_pt.g);
00104       EXPECT_EQ (pcd_pt.b, fg_pt.b);
00105       EXPECT_EQ (pcd_pt.a, fg_pt.a);
00106     }
00107   }
00108 
00109 }
00110 
00111 TEST (PCL, ImageGrabberTIFF)
00112 {
00113   // Get all clouds from the grabber
00114   pcl::ImageGrabber<PointT> grabber (tiff_dir_, 0, false, false);
00115   vector<CloudT::ConstPtr> tiff_clouds;
00116   CloudT::ConstPtr cloud_buffer;
00117   bool signal_received = false;
00118   boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> 
00119     fxn = boost::bind (cloud_callback, &signal_received, &cloud_buffer, _1);
00120   grabber.registerCallback (fxn);
00121   grabber.setCameraIntrinsics (525., 525., 320., 240.); // Setting old intrinsics which were used to generate these tests
00122   grabber.start ();
00123   for (size_t i = 0; i < grabber.size (); i++)
00124   {
00125     grabber.trigger ();
00126     size_t niter = 0;
00127     while (!signal_received)
00128     {
00129       boost::this_thread::sleep (boost::posix_time::microseconds (10000));
00130       if (++niter > 100)
00131       {
00132         ASSERT_TRUE (false);
00133         return;
00134       }
00135     }
00136     tiff_clouds.push_back (cloud_buffer);
00137     signal_received = false;
00138   }
00139 
00140   // Make sure they match
00141   EXPECT_EQ (pcds_.size (), tiff_clouds.size ());
00142   for (size_t i = 0; i < pcds_.size (); i++)
00143   {
00144     // Also compare against dynamically loaded cloud
00145     CloudT::ConstPtr cloud_from_file_grabber = grabber[i];
00146     for (size_t j = 0; j < pcds_[i]->size (); j++)
00147     {
00148       const PointT &pcd_pt = pcds_[i]->at(j);
00149       const PointT &tiff_pt = tiff_clouds[i]->at(j);
00150       const PointT &tiff_fg_pt = cloud_from_file_grabber->at(j);
00151       if (pcl_isnan (pcd_pt.x))
00152       {
00153         EXPECT_TRUE (pcl_isnan (tiff_pt.x));
00154         EXPECT_TRUE (pcl_isnan (tiff_fg_pt.x));
00155       }
00156       else
00157       {
00158         EXPECT_FLOAT_EQ (pcd_pt.x, tiff_pt.x);
00159         EXPECT_FLOAT_EQ (pcd_pt.x, tiff_fg_pt.x);
00160       }
00161       if (pcl_isnan (pcd_pt.y))
00162       {
00163         EXPECT_TRUE (pcl_isnan (tiff_pt.y));
00164         EXPECT_TRUE (pcl_isnan (tiff_fg_pt.y));
00165       }
00166       else
00167       {
00168         EXPECT_FLOAT_EQ (pcd_pt.y, tiff_pt.y);
00169         EXPECT_FLOAT_EQ (pcd_pt.y, tiff_fg_pt.y);
00170       }
00171       if (pcl_isnan (pcd_pt.z))
00172       {
00173         EXPECT_TRUE (pcl_isnan (tiff_pt.z));
00174         EXPECT_TRUE (pcl_isnan (tiff_fg_pt.z));
00175       }
00176       else
00177       {
00178         EXPECT_FLOAT_EQ (pcd_pt.z, tiff_pt.z);
00179         EXPECT_FLOAT_EQ (pcd_pt.z, tiff_fg_pt.z);
00180       }
00181       EXPECT_EQ (pcd_pt.r, tiff_pt.r);
00182       EXPECT_EQ (pcd_pt.g, tiff_pt.g);
00183       EXPECT_EQ (pcd_pt.b, tiff_pt.b);
00184       EXPECT_EQ (pcd_pt.r, tiff_fg_pt.r);
00185       EXPECT_EQ (pcd_pt.g, tiff_fg_pt.g);
00186       EXPECT_EQ (pcd_pt.b, tiff_fg_pt.b);
00187       //EXPECT_EQ (pcd_pt.a, tiff_pt.a);    // the alpha channel in the PCD set was saved as 255 but it should have been 0
00188     }
00189   }
00190 }
00191 
00192 TEST (PCL, ImageGrabberPCLZF)
00193 {
00194   // Get all clouds from the grabber
00195   pcl::ImageGrabber<PointT> grabber (pclzf_dir_, 0, false, true);
00196   vector <CloudT::ConstPtr> pclzf_clouds;
00197   CloudT::ConstPtr cloud_buffer;
00198   bool signal_received = false;
00199   boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> 
00200     fxn = boost::bind (cloud_callback, &signal_received, &cloud_buffer, _1);
00201   grabber.registerCallback (fxn);
00202   grabber.start ();
00203   for (size_t i = 0; i < grabber.size (); i++)
00204   {
00205     grabber.trigger ();
00206     size_t niter = 0;
00207     while (!signal_received)
00208     {
00209       boost::this_thread::sleep (boost::posix_time::microseconds (10000));
00210       if (++niter > 100)
00211       {
00212         ASSERT_TRUE (false);
00213         return;
00214       }
00215     }
00216     pclzf_clouds.push_back (cloud_buffer);
00217     signal_received = false;
00218   }
00219   // Make sure they match
00220   EXPECT_EQ (pcds_.size (), pclzf_clouds.size ());
00221   EXPECT_EQ (pcds_.size (), grabber.size ());
00222   for (size_t i = 0; i < pcds_.size (); i++)
00223   {
00224     CloudT::ConstPtr cloud_from_file_grabber = grabber[i];
00225     for (size_t j = 0; j < pcds_[i]->size (); j++)
00226     {
00227       const PointT &pcd_pt = pcds_[i]->at(j);
00228       const PointT &pclzf_pt = pclzf_clouds[i]->at(j);
00229       const PointT &pclzf_fg_pt = cloud_from_file_grabber->at(j);
00230       if (pcl_isnan (pcd_pt.x))
00231       {
00232         EXPECT_TRUE (pcl_isnan (pclzf_pt.x));
00233         EXPECT_TRUE (pcl_isnan (pclzf_fg_pt.x));
00234       }
00235       else
00236       {
00237         EXPECT_FLOAT_EQ (pcd_pt.x, pclzf_pt.x);
00238         EXPECT_FLOAT_EQ (pcd_pt.x, pclzf_fg_pt.x);
00239       }
00240       if (pcl_isnan (pcd_pt.y))
00241       {
00242         EXPECT_TRUE (pcl_isnan (pclzf_pt.y));
00243         EXPECT_TRUE (pcl_isnan (pclzf_fg_pt.y));
00244       }
00245       else
00246       {
00247         EXPECT_FLOAT_EQ (pcd_pt.y, pclzf_pt.y);
00248         EXPECT_FLOAT_EQ (pcd_pt.y, pclzf_fg_pt.y);
00249       }
00250       if (pcl_isnan (pcd_pt.z))
00251       {
00252         EXPECT_TRUE (pcl_isnan (pclzf_pt.z));
00253         EXPECT_TRUE (pcl_isnan (pclzf_fg_pt.z));
00254       }
00255       else
00256       {
00257         EXPECT_FLOAT_EQ (pcd_pt.z, pclzf_pt.z);
00258         EXPECT_FLOAT_EQ (pcd_pt.z, pclzf_fg_pt.z);
00259       }
00260       EXPECT_EQ (pcd_pt.r, pclzf_pt.r);
00261       EXPECT_EQ (pcd_pt.g, pclzf_pt.g);
00262       EXPECT_EQ (pcd_pt.b, pclzf_pt.b);
00263       EXPECT_EQ (pcd_pt.r, pclzf_fg_pt.r);
00264       EXPECT_EQ (pcd_pt.g, pclzf_fg_pt.g);
00265       EXPECT_EQ (pcd_pt.b, pclzf_fg_pt.b);
00266       //EXPECT_EQ (pcd_pt.a, pclzf_pt.a);     // the alpha channel in the PCD set was saved as 255 but it should have been 0
00267     }
00268   }
00269 }
00270 
00271 TEST (PCL, ImageGrabberOMP)
00272 {
00273   // Get all clouds from the grabber
00274   pcl::ImageGrabber<PointT> grabber (pclzf_dir_, 0, false, true);
00275   vector <CloudT::ConstPtr> pclzf_clouds;
00276   CloudT::ConstPtr cloud_buffer;
00277   bool signal_received = false;
00278   boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> 
00279     fxn = boost::bind (cloud_callback, &signal_received, &cloud_buffer, _1);
00280   grabber.registerCallback (fxn);
00281   grabber.setNumberOfThreads (0); // Let OMP select
00282   grabber.start ();
00283   for (size_t i = 0; i < grabber.size (); i++)
00284   {
00285     grabber.trigger ();
00286     size_t niter = 0;
00287     while (!signal_received)
00288     {
00289       boost::this_thread::sleep (boost::posix_time::microseconds (10000));
00290       if (++niter > 100)
00291       {
00292         ASSERT_TRUE (false);
00293         return;
00294       }
00295     }
00296     pclzf_clouds.push_back (cloud_buffer);
00297     signal_received = false;
00298   }
00299   // Make sure they match
00300   EXPECT_EQ (pcds_.size (), pclzf_clouds.size ());
00301   EXPECT_EQ (pcds_.size (), grabber.size ());
00302   for (size_t i = 0; i < pcds_.size (); i++)
00303   {
00304     CloudT::ConstPtr cloud_from_file_grabber = grabber[i];
00305     for (size_t j = 0; j < pcds_[i]->size (); j++)
00306     {
00307       const PointT &pcd_pt = pcds_[i]->at(j);
00308       const PointT &pclzf_pt = pclzf_clouds[i]->at(j);
00309       const PointT &pclzf_fg_pt = cloud_from_file_grabber->at(j);
00310       if (pcl_isnan (pcd_pt.x))
00311       {
00312         EXPECT_TRUE (pcl_isnan (pclzf_pt.x));
00313         EXPECT_TRUE (pcl_isnan (pclzf_fg_pt.x));
00314       }
00315       else
00316       {
00317         EXPECT_FLOAT_EQ (pcd_pt.x, pclzf_pt.x);
00318         EXPECT_FLOAT_EQ (pcd_pt.x, pclzf_fg_pt.x);
00319       }
00320       if (pcl_isnan (pcd_pt.y))
00321       {
00322         EXPECT_TRUE (pcl_isnan (pclzf_pt.y));
00323         EXPECT_TRUE (pcl_isnan (pclzf_fg_pt.y));
00324       }
00325       else
00326       {
00327         EXPECT_FLOAT_EQ (pcd_pt.y, pclzf_pt.y);
00328         EXPECT_FLOAT_EQ (pcd_pt.y, pclzf_fg_pt.y);
00329       }
00330       if (pcl_isnan (pcd_pt.z))
00331       {
00332         EXPECT_TRUE (pcl_isnan (pclzf_pt.z));
00333         EXPECT_TRUE (pcl_isnan (pclzf_fg_pt.z));
00334       }
00335       else
00336       {
00337         EXPECT_FLOAT_EQ (pcd_pt.z, pclzf_pt.z);
00338         EXPECT_FLOAT_EQ (pcd_pt.z, pclzf_fg_pt.z);
00339       }
00340       EXPECT_EQ (pcd_pt.r, pclzf_pt.r);
00341       EXPECT_EQ (pcd_pt.g, pclzf_pt.g);
00342       EXPECT_EQ (pcd_pt.b, pclzf_pt.b);
00343       EXPECT_EQ (pcd_pt.r, pclzf_fg_pt.r);
00344       EXPECT_EQ (pcd_pt.g, pclzf_fg_pt.g);
00345       EXPECT_EQ (pcd_pt.b, pclzf_fg_pt.b);
00346       //EXPECT_EQ (pcd_pt.a, pclzf_pt.a);     // the alpha channel in the PCD set was saved as 255 but it should have been 0
00347     }
00348   }
00349 }
00350 
00351 TEST (PCL, ImageGrabberTimestamps)
00352 {
00353   // Initialize the grabber but don't load
00354   pcl::ImageGrabber<PointT> grabber (pclzf_dir_, 0, false, true);
00355   uint64_t frame0_microsec, frame1_microsec; 
00356   ASSERT_EQ (grabber.size (), 3);
00357   EXPECT_TRUE (grabber.getTimestampAtIndex (0, frame0_microsec));
00358   EXPECT_TRUE (grabber.getTimestampAtIndex (1, frame1_microsec));
00359   uint64_t timediff = frame1_microsec - frame0_microsec;
00360   EXPECT_EQ (timediff, 254471); // 20121214T142256.068683 - 20121214T142255.814212 
00361 }
00362 
00363 TEST (PCL, ImageGrabberSetIntrinsicsTIFF)
00364 {
00365   pcl::ImageGrabber<PointT> grabber (tiff_dir_, 0, false, false);
00366 
00367   // Get all clouds from the grabber
00368   vector <CloudT::ConstPtr> tiff_clouds;
00369   CloudT::ConstPtr cloud_buffer;
00370   bool signal_received = false;
00371   boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> 
00372     fxn = boost::bind (cloud_callback, &signal_received, &cloud_buffer, _1);
00373   grabber.registerCallback (fxn);
00374   grabber.start ();
00375   // Change the camera parameters
00376   double fx_multiplier = 1.2;
00377   double fy_multiplier = 0.5;
00378   double cx_multiplier = 0.8;
00379   double cy_multiplier = 1.3;
00380   double fx_old, fy_old, cx_old, cy_old;
00381   //grabber.getCameraIntrinsics (fx_old, fy_old, cx_old, cy_old); Need to use old intrinsics, can't trust defaults
00382   fx_old = 525;
00383   fy_old = 525;
00384   cx_old = 320;
00385   cy_old = 240;
00386   double fx_new = fx_multiplier * fx_old;
00387   double fy_new = fy_multiplier * fy_old;
00388   double cx_new = cx_multiplier * cx_old;
00389   double cy_new = cy_multiplier * cy_old;
00390   grabber.setCameraIntrinsics (fx_new, fy_new, cx_new, cy_new);
00391   // Collect the clouds
00392   for (size_t i = 0; i < grabber.size (); i++)
00393   {
00394     grabber.trigger ();
00395     size_t niter = 0;
00396     while (!signal_received)
00397     {
00398       boost::this_thread::sleep (boost::posix_time::microseconds (10000));
00399       if (++niter > 100)
00400       {
00401         ASSERT_TRUE (false);
00402         return;
00403       }
00404     }
00405     tiff_clouds.push_back (cloud_buffer);
00406     signal_received = false;
00407   }
00408 
00409   // Make sure they match
00410   EXPECT_EQ (pcds_.size (), tiff_clouds.size ());
00411   for (size_t i = 0; i < pcds_.size (); i++)
00412   {
00413     EXPECT_EQ (pcds_[i]->width, tiff_clouds[i]->width);
00414     EXPECT_EQ (pcds_[i]->height, tiff_clouds[i]->height);
00415     for (int x = 0; x < pcds_[i]->width; x++)
00416     {
00417       for (int y = 0; y < pcds_[i]->height; y++)
00418       {
00419         const PointT &pcd_pt = pcds_[i]->operator()(x,y);
00420         const PointT &tiff_pt = tiff_clouds[i]->operator()(x,y);
00421         if (pcl_isnan (pcd_pt.x))
00422           EXPECT_TRUE (pcl_isnan (tiff_pt.x));
00423         else
00424           EXPECT_NEAR ( pcd_pt.x * (x-cx_new), tiff_pt.x * fx_multiplier * (x-cx_old), 1E-4);
00425         if (pcl_isnan (pcd_pt.y))
00426           EXPECT_TRUE (pcl_isnan (tiff_pt.y));
00427         else
00428           EXPECT_NEAR ( pcd_pt.y * (y-cy_new), tiff_pt.y * fy_multiplier * (y-cy_old), 1E-4);
00429         if (pcl_isnan (pcd_pt.z))
00430           EXPECT_TRUE (pcl_isnan (tiff_pt.z));
00431         else
00432           EXPECT_FLOAT_EQ (pcd_pt.z, tiff_pt.z);
00433       }
00434     }
00435   }
00436 
00437 }
00438 
00439 TEST (PCL, ImageGrabberSetIntrinsicsPCLZF)
00440 {
00441   pcl::ImageGrabber<PointT> grabber (pclzf_dir_, 0, false, true);
00442 
00443   // Get all clouds from the grabber
00444   vector <CloudT::ConstPtr> pclzf_clouds;
00445   CloudT::ConstPtr cloud_buffer;
00446   bool signal_received = false;
00447   boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> 
00448     fxn = boost::bind (cloud_callback, &signal_received, &cloud_buffer, _1);
00449   grabber.registerCallback (fxn);
00450   grabber.start ();
00451   // Change the camera parameters
00452   double fx_multiplier = 1.2;
00453   double fy_multiplier = 0.5;
00454   double cx_multiplier = 0.8;
00455   double cy_multiplier = 1.3;
00456   double fx_old, fy_old, cx_old, cy_old;
00457   grabber.getCameraIntrinsics (fx_old, fy_old, cx_old, cy_old);
00458   double fx_new = fx_multiplier * fx_old;
00459   double fy_new = fy_multiplier * fy_old;
00460   double cx_new = cx_multiplier * cx_old;
00461   double cy_new = cy_multiplier * cy_old;
00462   grabber.setCameraIntrinsics (fx_new, fy_new, cx_new, cy_new);
00463   // Collect the clouds
00464   for (size_t i = 0; i < grabber.size (); i++)
00465   {
00466     grabber.trigger ();
00467     size_t niter = 0;
00468     while (!signal_received)
00469     {
00470       boost::this_thread::sleep (boost::posix_time::microseconds (10000));
00471       if (++niter > 100)
00472       {
00473         ASSERT_TRUE (false);
00474         return;
00475       }
00476     }
00477     pclzf_clouds.push_back (cloud_buffer);
00478     signal_received = false;
00479   }
00480 
00481   // Make sure they match
00482   EXPECT_EQ (pcds_.size (), pclzf_clouds.size ());
00483   for (size_t i = 0; i < pcds_.size (); i++)
00484   {
00485     EXPECT_EQ (pcds_[i]->width, pclzf_clouds[i]->width);
00486     EXPECT_EQ (pcds_[i]->height, pclzf_clouds[i]->height);
00487     for (int x = 0; x < pcds_[i]->width; x++)
00488     {
00489       for (int y = 0; y < pcds_[i]->height; y++)
00490       {
00491         const PointT &pcd_pt = pcds_[i]->operator()(x,y);
00492         const PointT &pclzf_pt = pclzf_clouds[i]->operator()(x,y);
00493         if (pcl_isnan (pcd_pt.x))
00494           EXPECT_TRUE (pcl_isnan (pclzf_pt.x));
00495         else
00496           EXPECT_NEAR ( pcd_pt.x * (x-cx_new), pclzf_pt.x * fx_multiplier * (x-cx_old), 1E-4);
00497         if (pcl_isnan (pcd_pt.y))
00498           EXPECT_TRUE (pcl_isnan (pclzf_pt.y));
00499         else
00500           EXPECT_NEAR ( pcd_pt.y * (y-cy_new), pclzf_pt.y * fy_multiplier * (y-cy_old), 1E-4);
00501         if (pcl_isnan (pcd_pt.z))
00502           EXPECT_TRUE (pcl_isnan (pclzf_pt.z));
00503         else
00504           EXPECT_FLOAT_EQ (pcd_pt.z, pclzf_pt.z);
00505       }
00506     }
00507   }
00508 }
00509 
00510 /* ---[ */
00511 int
00512   main (int argc, char** argv)
00513 {
00514   if (argc < 2)
00515   {
00516     std::cerr << "No test files were given. Please add the path to grabber_sequences to this test." << std::endl;
00517     return (-1);
00518   }
00519 
00520   std::string grabber_sequences = argv[1];
00521   tiff_dir_ = grabber_sequences + "/tiff";
00522   pclzf_dir_ = grabber_sequences + "/pclzf";
00523   pcd_dir_ = grabber_sequences + "/pcd";
00524   // Get pcd files
00525   boost::filesystem::directory_iterator end_itr;
00526   for (boost::filesystem::directory_iterator itr (pcd_dir_); itr != end_itr; ++itr)
00527   {
00528 #if BOOST_FILESYSTEM_VERSION == 3
00529     if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ())) == ".PCD" )
00530 #else
00531     if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->leaf ())) == ".PCD" )
00532 #endif
00533     {
00534 #if BOOST_FILESYSTEM_VERSION == 3
00535       pcd_files_.push_back (itr->path ().string ());
00536       std::cout << "added: " << itr->path ().string () << std::endl;
00537 #else
00538       pcd_files_.push_back (itr->pcd_dir_ ().string ());
00539       std::cout << "added: " << itr->pcd_dir_ () << std::endl;
00540 #endif
00541     }
00542   }
00543   sort (pcd_files_.begin (), pcd_files_.end ());
00544   // And load them
00545   for (size_t i = 0; i < pcd_files_.size (); i++)
00546   {
00547     CloudT::Ptr cloud (new CloudT);
00548     pcl::io::loadPCDFile (pcd_files_[i], *cloud); 
00549     pcds_.push_back (cloud);
00550   }
00551 
00552   testing::InitGoogleTest (&argc, argv);
00553   return (RUN_ALL_TESTS ());
00554 }
00555 /* ]--- */


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:34:55