ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How can I print VFH signature?

asked 2013-04-08 01:21:00 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I want to print VFH signature. Below is my sample code. After VFH signature calculation, how can i print this?

int main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ> cloud;

  //pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

  // Fill in the cloud data
  cloud.width    = 50;
  cloud.height   = 1;
  cloud.is_dense = false;
  cloud.points.resize (cloud.width * cloud.height);


  for (size_t i = 0; i < cloud.points.size (); ++i)
  {
    cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);

  }

pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
          ne.setInputCloud (cloud.makeShared());

          // Create an empty kdtree representation, and pass it to the normal estimation object.
          // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).

          pcl::search::KdTree<pcl::PointXYZ>::Ptr cloud_normal_tree (new pcl::search::KdTree<pcl::PointXYZ>());
          ne.setSearchMethod (cloud_normal_tree);

          // Output datasets
          pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);

          // Use all neighbors in a sphere of radius 3cm
          ne.setRadiusSearch (0.03);

          // Compute the features
          ne.compute (*normals);

          // Create the VFH estimation class, and pass the input dataset+normals to it
          pcl::VFHEstimation<pcl::PointXYZ, pcl::Normal, pcl::VFHSignature308> vfh;
          vfh.setInputCloud (cloud.makeShared ());
          vfh.setInputNormals (normals);
          // alternatively, if cloud is of type PointNormal, do vfh.setInputNormals (cloud);

          // Create an empty kdtree representation, and pass it to the FPFH estimation object.
          // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
          pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
          vfh.setSearchMethod (tree);

          // Output datasets
          pcl::PointCloud<pcl::VFHSignature308>::Ptr vfhs (new pcl::PointCloud<pcl::VFHSignature308> ());

          // Compute the features
          vfh.compute (*vfhs);
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-05-01 11:02:46 -0500

Modified from another question:

pcl::PointCloud<pcl::PointXYZ>::iterator b1;
for (b1 = cloudPCL.points.begin(); b1 < cloudPCL.points.end(); b1++, b2++)
{

    ROS_INFO_STREAM("x: " << b1->x << ", y: " << b1->y << ", z: " << b1->z);
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-04-08 01:21:00 -0500

Seen: 342 times

Last updated: May 01 '15