c++point-cloud-librarysiftpoint-cloudskeypoint

PointCloud library: Compute sift keypoints - input cloud error


I am trying to compute the sift keypoints of an input cloud with this code:

#include <iostream>
#include <boost/thread/thread.hpp>
#include <pcl/range_image/range_image.h>
#include <pcl/io/ply_io.h>
#include <pcl/visualization/range_image_visualizer.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/features/range_image_border_extractor.h>
#include <pcl/keypoints/narf_keypoint.h>
#include <pcl/features/narf_descriptor.h>
#include <pcl/console/parse.h>
#include <pcl/point_types.h>
#include <pcl/features/pfh.h>
#include <pcl/kdtree/kdtree.h>
#include <pcl/surface/gp3.h>
#include <pcl/features/spin_image.h>
#include <cmath>
#include <pcl/registration/icp.h>
#include <pcl/keypoints/sift_keypoint.h>
void processSift (std::string filename, std::string filename2){
    // ------------------------------------------------------------------
    // -----Read ply file-----
    // ------------------------------------------------------------------
    pcl::PointCloud<PointType>::Ptr cloud_xyz_ptr(
                    new pcl::PointCloud<PointType>);
    pcl::PointCloud<PointType>& cloud_xyz = *cloud_xyz_ptr;
    if (pcl::io::loadPLYFile(filename, cloud_xyz) == -1) {
            cerr << "Was not able to open file \"" << filename << "\".\n";
            printUsage("");
    }

    // Parameters for sift computation
    const float min_scale = 0.01f;
    const int n_octaves = 3;
    const int n_scales_per_octave = 4;
    const float min_contrast = 0.001f;
pcl::SIFTKeypoint<PointType, pcl::PointWithScale> sift;
pcl::search::KdTree<PointType> tree= new pcl::search::KdTree<PointType> ();//new API
pcl::PointCloud<pcl::PointWithScale>::Ptr sifts (new 
pcl::PointCloud<pcl::PointWithScale>);
pcl::KdTree<PointType>::PointCloudConstPtr ptr_sift_cloud(&cloud_xyz);
sift.setInputCloud(ptr_sift_cloud);
//sift.setSearchMethod (tree);
sift.setScales(min_scale, n_octaves, n_scales_per_octave);
sift.setMinimumContrast(min_contrast);
sift.compute (*sifts);

cout << "Computed " << (*sifts).size () << " SIFT Keypoints";

Now the problem is internal to the sift keypoint class as it looks like PointXYZ does not have a parameter named "intensity".

In file included from
/home/adrian/PointCloudComparator/src/comparator.cpp:21:0:
/usr/include/pcl-1.7/pcl/keypoints/sift_keypoint.h: In instantiation of
‘float pcl::SIFTKeypointFieldSelector<PointT>::operator()(const PointT&)
const [with PointT = pcl::PointXYZ]’:
/usr/include/pcl-1.7/pcl/keypoints/impl/sift_keypoint.hpp:236:82: required
from ‘void pcl::SIFTKeypoint<PointInT, PointOutT>::computeScaleSpace(const
PointCloudIn&, pcl::SIFTKeypoint<PointInT, PointOutT>::KdTree&, const
std::vector<float>&, Eigen::MatrixXf&) [with PointInT = pcl::PointXYZ;
PointOutT = pcl::PointWithScale; pcl::SIFTKeypoint<PointInT,
PointOutT>::PointCloudIn = pcl::PointCloud<pcl::PointXYZ>;
pcl::SIFTKeypoint<PointInT, PointOutT>::KdTree =
pcl::search::Search<pcl::PointXYZ>; Eigen::MatrixXf = Eigen::Matrix<float,
-1, -1>]’
/usr/include/pcl-1.7/pcl/keypoints/impl/sift_keypoint.hpp:163:56:   required
from ‘void pcl::SIFTKeypoint<PointInT,
PointOutT>::detectKeypointsForOctave(const PointCloudIn&,
pcl::SIFTKeypoint<PointInT, PointOutT>::KdTree&, float, int,
pcl::SIFTKeypoint<PointInT, PointOutT>::PointCloudOut&) [with PointInT =
pcl::PointXYZ; PointOutT = pcl::PointWithScale;    pcl::SIFTKeypoint<PointInT,
PointOutT>::PointCloudIn = pcl::PointCloud<pcl::PointXYZ>;
pcl::SIFTKeypoint<PointInT, PointOutT>::KdTree =
pcl::search::Search<pcl::PointXYZ>; pcl::SIFTKeypoint<PointInT,
PointOutT>::PointCloudOut = pcl::PointCloud<pcl::PointWithScale>]’
/usr/include/pcl-1.7/pcl/keypoints/impl/sift_keypoint.hpp:139:83:   required
from ‘void pcl::SIFTKeypoint<PointInT,
PointOutT>::detectKeypoints(pcl::SIFTKeypoint<PointInT,
PointOutT>::PointCloudOut&) [with PointInT = pcl::PointXYZ; PointOutT =
pcl::PointWithScale; pcl::SIFTKeypoint<PointInT, PointOutT>::PointCloudOut =
pcl::PointCloud<pcl::PointWithScale>]’
/home/adrian/PointCloudComparator/src/comparator.cpp:340:1:   required from here
/usr/include/pcl-1.7/pcl/keypoints/sift_keypoint.h:49:16: error: ‘const
struct pcl::PointXYZ’ has no member named ‘intensity’
   return p.intensity;

If i would like to have sift keypoints for the PointXYZ values, what should I use?


Solution

  • Actually, the problem is that I am using pcl::PointXYZ and there exists a type pcl::PointXYZRGB. This one has the attribute intensity (of the color) and now it works, just by changing every "PointType" to "PointXYZRGB"