Save histogram data into float array

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

Save histogram data into float array

SAV94
Hello, everyone,
I would like to know how I can save the histogram data in a float type
array, this is my code and in the hist variable I am saving the histogram
data but when I print it in the command window it comes out with parentheses
and I need the data without it.

#include <pcl/io/pcd_io.h>
#include <pcl/features/normal_3d.h>
#include <pcl/features/vfh.h>
#include <pcl/io/ply_io.h>
using namespace std;

int
main(int argc, char** argv)
{
        //std::vector<float> hist;
        pcl::VFHSignature308 hist;
        std::string argv1(argv[1]);
        // 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(argv1, *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);

        hist = descriptor->points[0];

        cout << "Vector:\n" << hist << endl;

}

Please help me, so far the only option I have found has been to save this
data in a .txt text file to remove the parentheses and then save them as
.csv


       



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