PointCloud 库:计算筛选关键点 - 输入云错误

PointCloud library: Compute sift keypoints - input cloud error

我正在尝试用这个计算输入云的筛选关键点 代码:

#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";

现在问题出在筛选关键点内部class,因为 PointXYZ 似乎没有名为“强度”的参数。

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;

如果我想为 PointXYZ 值筛选关键点,我应该使用什么?

实际上,问题是我正在使用 pcl::PointXYZ 并且存在类型 pcl::PointXYZRGB。这个具有(颜色的)属性强度,现在它可以工作了,只需将每个“PointType”更改为“PointXYZRGB”