c++ - Extract Point Cloud from a pcl::people::PersonCluster<PointT> -
i doing project university , need extract point cloud of people work it. made ros node adapting code of tutorial ground based rgdb people detection, , want publish in topic point cloud of first detected cluster.
but not able extract point cloud, definition of class defined here person_cluster.h. , there public member:
typedef pcl::pointcloud<pointt> pointcloud;
so convert in sensor_msgs::pointcloud2
do:
pcl_conversions::frompcl(clusters.at(0).pointcloud,person_msg);
where person_msg
pointcloud2
message, clusters
vector of pcl::people::personcluster<pointt>
, , want publish first point cloud because assume there 1 person in scene.
the compiler gives me error:
error: invalid use of ‘pcl::people::personcluster::pointcloud’ pcl_conversions::frompcl(clusters.at(0).pointcloud,person_msg);
i don't have lot of knowledge c++ , not able overcome error. googling error seems appears when don't "define" class, doubt in pcl library defined bad class.
for interested resolved problem.
in forum of pcl found post same developer of people detector used gave answer. basically:
// cloud after voxeling , ground plane removal: pointcloudt::ptr no_ground_cloud (new pointcloudt); no_ground_cloud = people_detector.getnogroundcloud(); // show pointclouds of every person cluster: pointcloudt::ptr cluster_cloud (new pointcloudt); for(std::vector<pcl::people::personcluster<pointt> >::iterator = clusters.begin(); != clusters.end(); ++it) { if (it->getpersonconfidence() > min_confidence) { // create pointcloud points belonging current cluster: cluster_cloud->clear(); pcl::pointindices clusterindices = it->getindices(); // cluster indices std::vector<int> indices = clusterindices.indices; for(unsigned int = 0; < indices.size(); i++) // fill cluster cloud { pointt* p = &no_ground_cloud->points[indices[i]]; cluster_cloud->push_back(*p); } // visualization: viewer.removeallpointclouds(); viewer.removeallshapes(); pcl::visualization::pointcloudcolorhandlerrgbfield<pointt> rgb(cluster_cloud); viewer.addpointcloud<pointt> (cluster_cloud, rgb, "cluster_cloud"); viewer.setpointcloudrenderingproperties (pcl::visualization::pcl_visualizer_point_size, 2, "cluster_cloud"); viewer.spinonce(500); } }
actually not able convert such type of point cloud in sensor message pointcloud2, trying convert pointcloud in pcl::pointcloud<pcl::pointxyz>
.
a working solution use cluster_cloud
type of pcl::pointcloud<pcl::pointxyz>
, using publisher of type pcl::pointcloud<pcl::pointxyz>
such:
ros::publisher person_pub = nh.advertise<pointcloud>("personpointcloud", 1000);
anyway no publish anything, rviz didnt showed anything. viever displaying point cloud of detected person. since pointcloud not such expected (if move arm algorithm no give arm) not useful project drop it.
so still remains problem publish in ros, problem pointcloud resolved.
Comments
Post a Comment