00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 #include <gtest/gtest.h>
00041 #include <pcl/point_cloud.h>
00042 #include <pcl/pcl_tests.h>
00043 #include <pcl/io/pcd_io.h>
00044 #include <pcl/features/shot_lrf.h>
00045 
00046 using namespace pcl;
00047 using namespace pcl::test;
00048 using namespace pcl::io;
00049 using namespace std;
00050 
00051 typedef search::KdTree<PointXYZ>::Ptr KdTreePtr;
00052 
00053 PointCloud<PointXYZ> cloud;
00054 vector<int> indices;
00055 KdTreePtr tree;
00056 
00058 TEST (PCL, SHOTLocalReferenceFrameEstimation)
00059 {
00060   PointCloud<ReferenceFrame> bunny_LRF;
00061 
00062   boost::shared_ptr<vector<int> > indicesptr (new vector<int> (indices));
00063 
00064   
00065   SHOTLocalReferenceFrameEstimation<PointXYZ, ReferenceFrame> lrf_estimator;
00066 
00067   float radius = 0.01f;
00068 
00069   lrf_estimator.setRadiusSearch (radius);
00070 
00071   lrf_estimator.setInputCloud (cloud.makeShared ());
00072   lrf_estimator.setSearchMethod (tree);
00073   lrf_estimator.setIndices (indicesptr);
00074 
00075   lrf_estimator.compute (bunny_LRF);
00076 
00077   
00078   EXPECT_EQ (indices.size (), bunny_LRF.size ());
00079 
00080   EXPECT_FALSE (bunny_LRF.is_dense);
00081 
00082   
00083   
00084   EXPECT_TRUE (pcl_isnan (bunny_LRF.at (24).x_axis[0]));
00085 
00086   
00087   
00088   
00089   Eigen::Vector3f point_15_x (-0.849213f, 0.528016f, 0.00593846f);
00090   Eigen::Vector3f point_15_y (0.274564f, 0.451135f, -0.849171f);
00091   Eigen::Vector3f point_15_z (-0.451055f, -0.719497f, -0.528084f);
00092 
00093   
00094   Eigen::Vector3f point_45_x (0.950556f, 0.0673042f, 0.303171f);
00095   Eigen::Vector3f point_45_y (0.156242f, -0.947328f, -0.279569f);
00096   Eigen::Vector3f point_45_z (0.268386f, 0.313114f, -0.911004f);
00097 
00098   
00099   Eigen::Vector3f point_163_x (0.816369f, 0.309943f, -0.487317f);
00100   Eigen::Vector3f point_163_y (0.235273f, -0.949082f, -0.209498f);
00101   Eigen::Vector3f point_163_z (-0.527436f, 0.0563754f, -0.847722f);
00102 
00103   
00104   
00105   Eigen::Vector3f point_311_x (0.77608663f, -0.60673451f, 0.17193851f);
00106   Eigen::Vector3f point_311_y (0.49546647f, 0.75532055f, 0.42895663f);
00107   Eigen::Vector3f point_311_z (-0.39013144f, -0.24771771f, 0.88681078f);
00108 
00109   
00110   
00111   for (int d = 0; d < 3; ++d)
00112   {
00113     EXPECT_NEAR (point_15_x[d], bunny_LRF.at (15).x_axis[d], 1E-3);
00114     EXPECT_NEAR (point_15_y[d], bunny_LRF.at (15).y_axis[d], 1E-3);
00115     EXPECT_NEAR (point_15_z[d], bunny_LRF.at (15).z_axis[d], 1E-3);
00116 
00117     EXPECT_NEAR (point_45_x[d], bunny_LRF.at (45).x_axis[d], 1E-3);
00118     EXPECT_NEAR (point_45_y[d], bunny_LRF.at (45).y_axis[d], 1E-3);
00119     EXPECT_NEAR (point_45_z[d], bunny_LRF.at (45).z_axis[d], 1E-3);
00120 
00121     EXPECT_NEAR (point_163_x[d], bunny_LRF.at (163).x_axis[d], 1E-3);
00122     EXPECT_NEAR (point_163_y[d], bunny_LRF.at (163).y_axis[d], 1E-3);
00123     EXPECT_NEAR (point_163_z[d], bunny_LRF.at (163).z_axis[d], 1E-3);
00124 
00125     EXPECT_NEAR (point_311_x[d], bunny_LRF.at (311).x_axis[d], 1E-3);
00126     EXPECT_NEAR (point_311_y[d], bunny_LRF.at (311).y_axis[d], 1E-3);
00127     EXPECT_NEAR (point_311_z[d], bunny_LRF.at (311).z_axis[d], 1E-3);
00128   }
00129 }
00130 
00131 
00132 int
00133 main (int argc, char** argv)
00134 {
00135   if (argc < 2)
00136   {
00137     std::cerr << "No test file given. Please download `bun0.pcd` and pass its path to the test." << std::endl;
00138     return (-1);
00139   }
00140 
00141   if (loadPCDFile<PointXYZ> (argv[1], cloud) < 0)
00142   {
00143     std::cerr << "Failed to read test file. Please download `bun0.pcd` and pass its path to the test." << std::endl;
00144     return (-1);
00145   }
00146 
00147   indices.resize (cloud.points.size ());
00148   for (size_t i = 0; i < indices.size (); ++i)
00149     indices[i] = static_cast<int> (i);
00150 
00151   tree.reset (new search::KdTree<PointXYZ> (true));
00152   tree->setInputCloud (cloud.makeShared ());
00153 
00154   testing::InitGoogleTest (&argc, argv);
00155   return (RUN_ALL_TESTS ());
00156 }
00157