我正在尝试使用 pclVisualizer 显示点云,但出现以下链接器错误:
/usr/include/pcl-1.7/pcl/visualization/impl/pcl_visualizer.hpp:72:未定义引用`pcl::visualization::PointCloudGeometryHandlerXYZ<MyPointType>::PointCloudGeometryHandlerXYZ(boost::shared_ptrpcl::PointCloud\<MyPointType const > 常量&)'
该错误是由对 addPointCloud 的调用引起的,我仅在使用自定义点云类型时才收到该错误。如果我使用标准的 pcl::PointXYZ,那就没问题了。我正在运行 pcl 1.7 版。
#include <iostream>
#include <string>
#include <pcl/common/common_headers.h>
#include <pcl/visualization/pcl_visualizer.h>
struct MyPointType
{
PCL_ADD_POINT4D;
uint32_t classificationFlags;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
} EIGEN_ALIGN16;
POINT_CLOUD_REGISTER_POINT_STRUCT(MyPointType,
(float, x, x)
(float, y, y)
(float, z, z)
(uint32_t, classificationFlags, classificationFlags))
pcl::visualization::PCLVisualizer::Ptr simpleVis()
{
pcl::visualization::PCLVisualizer::Ptr viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
viewer->setBackgroundColor (0, 0, 0);
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
viewer->addCoordinateSystem (1.0);
viewer->initCameraParameters ();
return (viewer);
}
int main(int argc, char *argv[])
{
pcl::visualization::PCLVisualizer::Ptr viewer = simpleVis();
while (!viewer->wasStopped ())
{
viewer->spinOnce (100);
//typedef pcl::PointXYZ PointType;
typedef MyPointType PointType;
typedef pcl::PointCloud<PointType> CloudType;
boost::shared_ptr<CloudType> cloud_test(new CloudType);
viewer->addPointCloud<PointType> (cloud_test, "sample cloud");
}
return 0;
}