Question

I have what I think is a fairly basic question about a conversion in the point cloud library from a proprietry data type to float. My issue I think comes from a lack of experience with templates, data types and C++ in general.

The function that should perform this conversion is copyToFloatArray, defined in the documentation as:

virtual void pcl::DefaultPointRepresentation< FPFHSignature33 >::copyToFloatArray ( const FPFHSignature33 & p, float * out
) const [inline, virtual]

Copy point data from input point to a float array.

This method must be overriden in all subclasses.

Parameters:

p The input point

out A pointer to a float array.

Implements pcl::PointRepresentation< FPFHSignature33 >.

I have attempted to implement it as follows:

pcl::PointCloud<pcl::FPFHSignature33>::Ptr fpfhs (new pcl::PointCloud<pcl::FPFHSignature33> ());
// populate fpfh...
float **myArray;
pcl::DefaultPointRepresentation< pcl::FPFHSignature33 >::copyToFloatArray ( &fpfhs, &**myArray);

The error that's thrown up at compilation time is as follows:

/home/bc/PCL/pcd_read.cpp: In function ‘int main(int, char**)’:
/home/bc/PCL/pcd_read.cpp:68: error: no matching function for call to 
‘pcl::DefaultPointRepresentation<pcl::FPFHSignature33>::copyToFloatArray(boost::shared_ptr<pcl::PointCloud<pcl::FPFHSignature33> >*, float*)’
/usr/include/pcl-1.2/pcl/point_representation.h:254: note: candidates are: 
virtual void pcl::DefaultPointRepresentation<pcl::FPFHSignature33>::copyToFloatArray(const pcl::FPFHSignature33&, float*) const
make[2]: *** [CMakeFiles/pcd_read.dir/pcd_read.cpp.o] Error 1
make[1]: *** [CMakeFiles/pcd_read.dir/all] Error 2
make: *** [all] Error 2

It appears that the issue is in the first argument being passed to the function, but I can't seem to create a const FPFHSignature33 & p object.

Does anyone have any idea if these suspicions are correct, and if so what direction I might take to start to resolve the issue?

Thanks for any help.

Was it helpful?

Solution

First, you need to allocate memory in your floatArray. Then, you need to derefence the fpfhs ptr using *. finally, there is no need for a double pointer array there.

Here is the corrected code :

pcl::PointCloud<pcl::FPFHSignature33>::Ptr fpfhs (new pcl::PointCloud<pcl::FPFHSignature33> ());
// populate fpfh...
float *myArray = new float[ 3* point_count ];
pcl::DefaultPointRepresentation< pcl::FPFHSignature33 >::copyToFloatArray ( *fpfhs, myArray);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top