PCL 和 CMake 问题:链接时 StatisticalOutlierRemoval 未定义

Issue with PCL and CMake : StatisticalOutlierRemoval undefined while linking

我目前正在尝试使用 PCL 过滤点云,感谢 StatisticalOutlierRemoval 而不使用 ROS,仅使用 PCL 我通过代码中的 official github repository. I used this 安装,我得到以下信息链接时出错:

CMakeFiles/tests/11_pcl/removeOutliers.dir/removeOutliers.cpp.o: In function `pcl::StatisticalOutlierRemoval<pcl::PointXYZRGB>::applyFilter(std::vector<int, std::allocator<int> >&)':
removeOutliers.cpp:(.text._ZN3pcl25StatisticalOutlierRemovalINS_11PointXYZRGBEE11applyFilterERSt6vectorIiSaIiEE[_ZN3pcl25StatisticalOutlierRemovalINS_11PointXYZRGBEE11applyFilterERSt6vectorIiSaIiEE]+0x1): undefined reference to `pcl::StatisticalOutlierRemoval<pcl::PointXYZRGB>::applyFilterIndices(std::vector<int, std::allocator<int> >&)'
CMakeFiles/tests/11_pcl/removeOutliers.dir/removeOutliers.cpp.o:(.rodata._ZTVN3pcl25StatisticalOutlierRemovalINS_11PointXYZRGBEEE[_ZTVN3pcl25StatisticalOutlierRemovalINS_11PointXYZRGBEEE]+0x48): undefined reference to `pcl::StatisticalOutlierRemoval<pcl::PointXYZRGB>::applyFilter(pcl::PointCloud<pcl::PointXYZRGB>&)'

在我的 CMakeList 中有以下几行:

find_package(PCL 1.3 REQUIRED COMPONENTS common io visualization)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

和:

add_executable(tests/11_pcl/removeOutliers removeOutliers.cpp)
target_link_libraries(tests/11_pcl/removeOutliers ${PCL_LIBRARIES} ${OpenCV_LIBS})    

在我的 cpp 文件中,我只尝试使用 :

初始化异常值删除
pcl::StatisticalOutlierRemoval<pcl::PointXYZRGB> sor;

我有以下 headers :

#include <pcl/common/common_headers.h>
#include <pcl/features/normal_3d.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/console/parse.h>

//Filters
#include <pcl/point_types.h>
#include <pcl/filters/statistical_outlier_removal.h>

我想我可能在 PCL 中缺少一个组件...有什么想法吗?

好的,我找到了解决办法。我实际上在 PCL(过滤器)中缺少一个组件..

find_package(PCL 1.3 REQUIRED COMPONENTS common io visualization filters)

现在一切正常。