cloud - Error on running BSplines example in PCL 1.7 -


why receiving following error, when running 'fitting trimmed b-splines unordered point clouds' example point cloud library(pcl) tutorials, same cmakelists file?

pcl : 1.7.1(compiled source @ /usr/local/include/pcl-1.7.1/pcl/) os : ubuntu 12.04  cmakefiles/bspline_fitting.dir/bspline.cpp.o: in function `main': bspline.cpp:(.text+0x282):`                                                             undefined reference `pointcloud2vector3d(boost::shared_ptr<pcl::pointcloud<pcl::pointxyz>`   >, std::vector<eigen::matrix<double, 3, 1, 0, 3, 1>,   eigen::aligned_allocator<eigen::matrix<double, 3, 1, 0, 3, 1> > >&)'  bspline.cpp:(.text+0xb41): undefined reference `visualizecurve(on_nurbscurve&, on_nurbssurface&, pcl::visualization::pclvisualizer&)'     collect2: ld returned 1 exit status     make[2]: *** [bspline_fitting] error 1     make[1]: *** [cmakefiles/bspline_fitting.dir/all] error 2     make: *** [all] error 2 

as temporary solution try use following code instead:

#include <pcl/point_cloud.h> #include <pcl/point_types.h> #include <pcl/io/pcd_io.h>  #include <pcl/visualization/pcl_visualizer.h> #include <pcl/surface/on_nurbs/fitting_surface_tdm.h> #include <pcl/surface/on_nurbs/fitting_curve_2d_asdm.h> #include <pcl/surface/on_nurbs/triangulation.h>  typedef pcl::pointxyz point;  void pointcloud2vector3d (pcl::pointcloud<point>::ptr cloud, pcl::on_nurbs::vector_vec3d &data);  void visualizecurve (on_nurbscurve &curve,                 on_nurbssurface &surface,                 pcl::visualization::pclvisualizer &viewer);  int main (int argc, char *argv[]) {   std::string pcd_file, file_3dm;    if (argc < 3)   {     printf ("\nusage: pcl_example_nurbs_fitting_surface pcd<pointxyz>-in-file 3dm-out-file\n\n");     exit (0);   }   pcd_file = argv[1];   file_3dm = argv[2];    pcl::visualization::pclvisualizer viewer ("b-spline surface fitting");   viewer.setsize (800, 600);    // ############################################################################   // load point cloud    printf ("  loading %s\n", pcd_file.c_str ());   pcl::pointcloud<point>::ptr cloud (new pcl::pointcloud<point>);   pcl::pclpointcloud2 cloud2;   pcl::on_nurbs::nurbsdatasurface data;    if (pcl::io::loadpcdfile (pcd_file, cloud2) == -1)     throw std::runtime_error ("  pcd file not found.");    frompclpointcloud2 (cloud2, *cloud);   pointcloud2vector3d (cloud, data.interior);   pcl::visualization::pointcloudcolorhandlercustom<point> handler (cloud, 0, 255, 0);   viewer.addpointcloud<point> (cloud, handler, "cloud_cylinder");   printf ("  %zu points in data set\n", cloud->size ());    // ############################################################################   // fit b-spline surface    // parameters   unsigned order (3);   unsigned refinement (5);   unsigned iterations (10);   unsigned mesh_resolution (256);    pcl::on_nurbs::fittingsurface::parameter params;   params.interior_smoothness = 0.2;   params.interior_weight = 1.0;   params.boundary_smoothness = 0.2;   params.boundary_weight = 0.0;    // initialize   printf ("  surface fitting ...\n");   on_nurbssurface nurbs = pcl::on_nurbs::fittingsurface::initnurbspcaboundingbox (order, &data);   pcl::on_nurbs::fittingsurface fit (&data, nurbs);   //  fit.setquiet (false); // enable/disable debug output    // mesh visualization   pcl::polygonmesh mesh;   pcl::pointcloud<pcl::pointxyz>::ptr mesh_cloud (new pcl::pointcloud<pcl::pointxyz>);   std::vector<pcl::vertices> mesh_vertices;   std::string mesh_id = "mesh_nurbs";   pcl::on_nurbs::triangulation::convertsurface2polygonmesh (fit.m_nurbs, mesh, mesh_resolution);   viewer.addpolygonmesh (mesh, mesh_id);    // surface refinement   (unsigned = 0; < refinement; i++)   {     fit.refine (0);     fit.refine (1);     fit.assemble (params);     fit.solve ();     pcl::on_nurbs::triangulation::convertsurface2vertices (fit.m_nurbs, mesh_cloud, mesh_vertices, mesh_resolution);     viewer.updatepolygonmesh<pcl::pointxyz> (mesh_cloud, mesh_vertices, mesh_id);     viewer.spinonce ();   }    // surface fitting final refinement level   (unsigned = 0; < iterations; i++)   {     fit.assemble (params);     fit.solve ();     pcl::on_nurbs::triangulation::convertsurface2vertices (fit.m_nurbs, mesh_cloud, mesh_vertices, mesh_resolution);     viewer.updatepolygonmesh<pcl::pointxyz> (mesh_cloud, mesh_vertices, mesh_id);     viewer.spinonce ();   }    // ############################################################################   // fit b-spline curve    // parameters   pcl::on_nurbs::fittingcurve2dapdm::fitparameter curve_params;   curve_params.addcpsaccuracy = 5e-2;   curve_params.addcpsiteration = 3;   curve_params.maxcps = 200;   curve_params.accuracy = 1e-3;   curve_params.iterations = 100;    curve_params.param.closest_point_resolution = 0;   curve_params.param.closest_point_weight = 1.0;   curve_params.param.closest_point_sigma2 = 0.1;   curve_params.param.interior_sigma2 = 0.00001;   curve_params.param.smooth_concavity = 1.0;   curve_params.param.smoothness = 1.0;    // initialisation (circular)   printf ("  curve fitting ...\n");   pcl::on_nurbs::nurbsdatacurve2d curve_data;   curve_data.interior = data.interior_param;   curve_data.interior_weight_function.push_back (true);   on_nurbscurve curve_nurbs = pcl::on_nurbs::fittingcurve2dapdm::initnurbscurve2d (order, curve_data.interior);    // curve fitting   pcl::on_nurbs::fittingcurve2dasdm curve_fit (&curve_data, curve_nurbs);   // curve_fit.setquiet (false); // enable/disable debug output   curve_fit.fitting (curve_params);   visualizecurve (curve_fit.m_nurbs, fit.m_nurbs, viewer);    // ############################################################################   // triangulation of trimmed surface    printf ("  triangulate trimmed surface ...\n");   viewer.removepolygonmesh (mesh_id);   pcl::on_nurbs::triangulation::converttrimmedsurface2polygonmesh (fit.m_nurbs, curve_fit.m_nurbs, mesh,                                                                    mesh_resolution);   viewer.addpolygonmesh (mesh, mesh_id);     // save trimmed b-spline surface   //if ( fit.m_nurbs.isvalid() )   //{   //  onx_model model;   //  onx_model_object& surf = model.m_object_table.appendnew();   //  surf.m_object = new on_nurbssurface(fit.m_nurbs);   //  surf.m_bdeleteobject = true;   //  surf.m_attributes.m_layer_index = 1;   //  surf.m_attributes.m_name = "surface";    //  onx_model_object& curv = model.m_object_table.appendnew();   //  curv.m_object = new on_nurbscurve(curve_fit.m_nurbs);   //  curv.m_bdeleteobject = true;   //  curv.m_attributes.m_layer_index = 2;   //  curv.m_attributes.m_name = "trimming curve";    //  model.write(file_3dm.c_str());   //  printf("  model saved: %s\n", file_3dm.c_str());   //}    printf ("  ... done.\n");    viewer.spin ();   return 0; }  void pointcloud2vector3d (pcl::pointcloud<point>::ptr cloud, pcl::on_nurbs::vector_vec3d &data) {   (unsigned = 0; < cloud->size (); i++)   {     point &p = cloud->at (i);     if (!pcl_isnan (p.x) && !pcl_isnan (p.y) && !pcl_isnan (p.z))       data.push_back (eigen::vector3d (p.x, p.y, p.z));   } }  void visualizecurve (on_nurbscurve &curve, on_nurbssurface &surface, pcl::visualization::pclvisualizer &viewer) {   pcl::pointcloud<pcl::pointxyzrgb>::ptr curve_cloud (new pcl::pointcloud<pcl::pointxyzrgb>);    pcl::on_nurbs::triangulation::convertcurve2pointcloud (curve, surface, curve_cloud, 4);   (std::size_t = 0; < curve_cloud->size () - 1; i++)   {     pcl::pointxyzrgb &p1 = curve_cloud->at (i);     pcl::pointxyzrgb &p2 = curve_cloud->at (i + 1);     std::ostringstream os;     os << "line" << i;     viewer.removeshape (os.str ());     viewer.addline<pcl::pointxyzrgb> (p1, p2, 1.0, 0.0, 0.0, os.str ());   }    pcl::pointcloud<pcl::pointxyzrgb>::ptr curve_cps (new pcl::pointcloud<pcl::pointxyzrgb>);   (int = 0; < curve.cvcount (); i++)   {     on_3dpoint p1;     curve.getcv (i, p1);      double pnt[3];     surface.evaluate (p1.x, p1.y, 0, 3, pnt);     pcl::pointxyzrgb p2;     p2.x = float (pnt[0]);     p2.y = float (pnt[1]);     p2.z = float (pnt[2]);      p2.r = 255;     p2.g = 0;     p2.b = 0;      curve_cps->push_back (p2);   }   viewer.removepointcloud ("cloud_cps");   viewer.addpointcloud (curve_cps, "cloud_cps"); } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -