c++ - calculate normals and displaying with PCL -
hello i'm trying work whith point cloud planes clustering normals points, i'm using following code seems not working want. don`t know programming on pcl, doubts variable contains cloud if want work with, , displaying normals necessary use pclvisualizer, tried stuff without getting result. pleas give advices results, need. best regards , thank you.
#include <pcl/point_types.h> #include <pcl/visualization/pcl_visualizer.h> #include <pcl/io/openni_grabber.h> #include <pcl/sample_consensus/sac_model_plane.h> #include <pcl/visualization/cloud_viewer.h> #include <pcl/features/normal_3d.h> using namespace std; class simpleopenniviewer { public: pcl::normalestimation<pcl::pointxyz, pcl::normal> ne; simpleopenniviewer () : viewer ("pcl openni viewer") {} void cloud_cb_ (const pcl::pointcloud<pcl::pointxyz>::constptr &cloud) { if (!viewer.wasstopped()) { ne.setinputcloud (cloud); pcl::search::kdtree<pcl::pointxyz>::ptr tree (new pcl::search::kdtree<pcl::pointxyz> ()); ne.setsearchmethod (tree); pcl::pointcloud<pcl::normal>::ptr cloud_normals (new pcl::pointcloud<pcl::normal>); ne.setradiussearch (0.03); ne.compute (*cloud_normals); cout<<"normales calculadas"<<endl; viewer.showcloud (cloud); } } void run () { pcl::grabber* interface = new pcl::opennigrabber(); boost::function<void (const pcl::pointcloud<pcl::pointxyz>::constptr&)> f = boost::bind (&simpleopenniviewer::cloud_cb_, this, _1); interface->registercallback (f); interface->start (); while (!viewer.wasstopped()) { boost::this_thread::sleep (boost::posix_time::seconds (1)); } interface->stop (); } pcl::visualization::cloudviewer viewer; }; int main () { simpleopenniviewer v; v.run (); return 0; }
i don't know doing, guess input cloud unorganized point cloud. no width , height given. change in example width , height sensor.
if (!viewer.wasstopped()) { cloud->width = 640; cloud->height = 480; ne.setinputcloud (cloud);
Comments
Post a Comment