0
$\begingroup$

Rosanswers logo

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);
}

Originally posted by Nihad on ROS Answers with karma: 22 on 2013-04-08

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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);
}

Originally posted by Adam Allevato with karma: 194 on 2015-05-01

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.