Viewpoint Feature Histogram. [closed]

asked 2013-04-03 01:07:20 -0500

this post is marked as community wiki

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

I am trying to use following code to generate VFH signature, but for each run it produces different value. For example: Output:

1st run-> Signature:0000000000DC1E80
2nd run-> Signature:0000000000EB1E80
3rd run-> Signature:0000000002A71E80

why it produces different signature for each run?

#include <pcl/io/io.h>  
......................

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    = 5;
  cloud.height   = 1;
  cloud.is_dense = false;
  cloud.points.resize (cloud.width * cloud.height);

  int x_i=1,y_i=2,z_i=3;
  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);*/

    cloud.points[i].x = 0.1+x_i;
    cloud.points[i].y = 0.2+y_i;
    cloud.points[i].z = 0.3+z_i;
    x_i++;
    y_i++;
    z_i++;

  }

  pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
  std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;

  for (size_t i = 0; i < cloud.points.size (); ++i)
    std::cerr << "    " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;

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



          for (size_t i = 0; i < vfhs->points.size(); ++i)
              std::cerr << "Signature: " << vfhs->points[i].histogram<< std::endl;
}
edit retag flag offensive reopen merge delete

Closed for the following reason PCL Question: The PCL community prefers to answer questions at http://www.pcl-users.org/ by tfoote
close date 2015-11-19 20:04:32.273595