(第六章 点云滤波)使用StatisticalOutlierRemoval滤波器移除离群点
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/filters/statistical_outlier_removal.h>
using namespace std;
int
main(int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PCDReader reader;
reader.read<pcl::PointXYZ>("C:\\Users\\oh_clm\\Desktop\\点云库PCL从入门到精通\\第六章\\3 statistical_removal\\source\\table_scene_lms400.pcd", *cloud);
std::cerr << "Cloud before filtering: " << std::endl;
std::cerr << *cloud << std::endl;
pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor;
sor.setInputCloud(cloud);
sor.setMeanK(50);
sor.setStddevMulThresh(1.0);
sor.filter(*cloud_filtered);
std::cerr << "Cloud after filtering: " << std::endl;
std::cerr << *cloud_filtered << std::endl;
pcl::PCDWriter writer;
writer.write<pcl::PointXYZ>("C:\\Users\\oh_clm\\Desktop\\点云库PCL从入门到精通\\第六章\\3 statistical_removal\\source\\table_scene_lms400_inliers.pcd", *cloud_filtered, false);
sor.setNegative(true);
sor.filter(*cloud_filtered);
writer.write<pcl::PointXYZ>("C:\\Users\\oh_clm\\Desktop\\点云库PCL从入门到精通\\第六章\\3 statistical_removal\\source\\table_scene_lms400_outliers.pcd", *cloud_filtered, false);
return (0);
}
出现错误没有解决:
D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(80,10): error C2332: “class”: 缺少标记名 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(80,10): error C3306: “pcl::”: 不允许存在未命名的类 模板 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(90,30): error C2065: “StatisticalOutlierRemoval”: 未声明的标识符 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(181): message : 查看对正在编译的 类 模板 实例化“pcl::”的引用 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(90,19): error C2974: ‘std::shared_ptr’ : 模板 对于 '_Ty’是无效参数,应为类型 1>D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\memory(1504): message : 参见“std::shared_ptr”的声明 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(90,64): error C2143: 语法错误: 缺少“;”(在“>”的前面) 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(90,64): error C2059: 语法错误:“>” 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(90,1): error C2238: 意外的标记位于“;”之前 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(91,1): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(91,41): error C2146: 语法错误: 缺少“>”(在标识符“StatisticalOutlierRemoval”的前面) 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(91,1): error C2947: 应由“>”终止 模板参数列表,却找到“<” 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(91,67): error C2146: 语法错误: 缺少“;”(在标识符“PointT”的前面) 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(91,73): error C2059: 语法错误:“>” 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(91,1): error C2238: 意外的标记位于“;”之前 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(97,1): error C2590: “StatisticalOutlierRemoval”: 只有构造函数可以有基/成员初始值列表 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(193,46): error C3856: “StatisticalOutlierRemoval”: 符号不是 模板 类 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(193,52): error C2143: 语法错误: 缺少“;”(在“pcl::PCLPointCloud2”的前面) 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(193,3): error C2913: 显式专用化;“pcl::StatisticalOutlierRemoval”不是类模板的专用化 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(193,66): error C2059: 语法错误:“>” 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(193,70): error C2059: 语法错误:“public” 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(194,3): error C2143: 语法错误: 缺少“;”(在“{”的前面) 1>D:\Program Files (x86)\PCL 1.12.0\include\pcl-1.12\pcl\filters\statistical_outlier_removal.h(194,3): error C2447: “{”: 缺少函数标题(是否是老式的形式表?) 1>D:\PCL\example\source\repos\pcl_test\pcl_test\源.cpp(20,48): error C2079: “sor”使用未定义的 class“pcl::StatisticalOutlierRemoval”
|