Generate dataset from VFH

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Generate dataset from VFH

SAV94
Hi every body,

i'm new at using PCL, i'm trying to generate a dataset with the descriptors
of the VFH code. Below i paste the code that i have implemented. Basically
what i'm trying to do is: get the data of the descriptors pointer and save
it all on a .txt file. I've tried some things but i keep getting errors, can
you guys help me to figure it out on how to do this? How can i get this data
so i can do a for cycle and save one by one on the .txt file?

Thanks for your atention, and your help.


Code:

#include <pcl/io/pcd_io.h>
#include <pcl/features/normal_3d.h>
#include <pcl/io/ply_io.h>
#include <pcl/features/vfh.h>
#include<pcl/visualization/histogram_visualizer.h>
#include <pcl/point_types.h>
#include <iostream>
#include <fstream>
using namespace std;

int
main(int argc, char** argv)
{
        // Cloud for storing the object.
        pcl::PointCloud<pcl::PointXYZ>::Ptr object(new
pcl::PointCloud<pcl::PointXYZ>);
        // Object for storing the normals.
        pcl::PointCloud<pcl::Normal>::Ptr normals(new
pcl::PointCloud<pcl::Normal>);
        // Object for storing the VFH descriptor.
        pcl::PointCloud<pcl::VFHSignature308>::Ptr descriptor(new
pcl::PointCloud<pcl::VFHSignature308>);

        // Note: you should have performed preprocessing to cluster out the object
        // from the cloud, and save it to this individual file.
        pcl::PLYReader Reader;
        // Read a PCD file from disk.
        if (Reader.read(argv[1], *object) != 0)
        {
                PCL_ERROR ("No se pudo leer el archivo .ply \n");
                return -1;
        }

        // Estimate the normals.
        pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normalEstimation;
        normalEstimation.setInputCloud(object);
        normalEstimation.setRadiusSearch(0.03);
        pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree(new
pcl::search::KdTree<pcl::PointXYZ>);
        normalEstimation.setSearchMethod(kdtree);
        normalEstimation.compute(*normals);

        // VFH estimation object.
        pcl::VFHEstimation<pcl::PointXYZ, pcl::Normal, pcl::VFHSignature308> vfh;
        vfh.setInputCloud(object);
        vfh.setInputNormals(normals);
        vfh.setSearchMethod(kdtree);
        // Optionally, we can normalize the bins of the resulting histogram,
        // using the total number of points.
        vfh.setNormalizeBins(true);
        // Also, we can normalize the SDC with the maximum size found between
        // the centroid and any of the cluster's points.
        vfh.setNormalizeDistance(false);

        vfh.compute(*descriptor);

        // Plotter object.
        pcl::visualization::PCLHistogramVisualizer viewer;
        // We need to set the size of the descriptor beforehand.
        viewer.addFeatureHistogram(*descriptor, 308);

        viewer.spin();
}



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users