本文主要是介绍使用ConditionalRemoval移除离群点,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
无需解释,这个滤波器删除点云中不符合用户指定的一个或者多个条件的数据点。
关键成员函数
(1)void setKeepOrganized(bool val)
(2)void setUserFilterValue(float value)
(3)void setCondition(ConditionBasePtr condition)
(函数用法见教程)
条件方程式表达:
创建条件对象:
pcl::ConditionAnd<pcl::PointXYZ>::Ptr range_cond(new pcl::ConditionAnd<pcl::PointXYZ>);
AND condition.
void pcl::ConditionBase< PointT >::addComparison | ( | ComparisonBaseConstPtr | comparison | ) |
range_cond->addComparison(pcl::FieldComparison<pcl::PointXYZ>::ConstPtr (new- pcl::FieldComparison<pcl::PointXYZ>("z",pcl::ComparisonOps::GT,0.0)));
OR condition.
void pcl::ConditionBase< PointT >::addComparison | ( | ComparisonBaseConstPtr | comparison | ) |
class pcl::FieldComparison< PointT >
pcl::FieldComparison< PointT >::FieldComparison | ( | std::string | field_name, |
ComparisonOps::CompareOp | op, | ||
double | compare_val | ||
) |
Construct a FieldComparison.
Parameters:field_name | the name of the field that contains the data we want to compare |
op | the operator to use when making the comparison |
compare_val | the constant value to compare the field value too |
(1)构造函数
pcl::ConditionalRemoval< PointT >::ConditionalRemoval | ( | int | extract_removed_indices = false | ) |
the default constructor.
All ConditionalRemovals require a condition which can be set using the setCondition method
pcl::ConditionalRemoval< PointT >::ConditionalRemoval | ( | ConditionBasePtr | condition, |
bool | extract_removed_indices = false | ||
) |
a constructor that includes the condition.
Parameters:condition | the condition that each point must satisfy to avoid being removed by the filter |
extract_removed_indices | extract filtered indices from indices vector |
virtual void pcl::PCLBase< PointT >::setInputCloud | ( | const PointCloudConstPtr & | cloud | ) |
Provide a pointer to the input dataset.
(3)
void pcl::ConditionalRemoval< PointT >::setKeepOrganized | ( | bool | val | ) |
Set whether the filtered points should be kept and set to the value given through setUserFilterValue (default: NaN), or removed from the PointCloud, thus potentially breaking its organized structure.
By default, points are removed.
(4)void pcl::Filter< PointT >::filter | ( | PointCloud & | output | ) |
Calls the filtering method and returns the filtered dataset in output.
(1)(
附:
EQ 就是 EQUAL等于
<span style="font-family: Arial, Helvetica, sans-serif;">GT 就是 GREATER THAN大于</span>
LT 就是 LESS THAN小于
GE 就是 GREATER THAN OR EQUAL 大于等于
LE 就是 LESS THAN OR EQUAL 小于等于
<pre name="code" class="objc">#include<iostream> #include<pcl\io\io.h> #include<pcl\point_cloud.h> #include<pcl\point_types.h> #include<pcl\filters\conditional_removal.h> using namespace std; int main() {pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>);cloud->width=5;cloud->height=1;cloud->points.resize(cloud->width*cloud->height);for(size_t i=0;i<cloud->points.size();i++){cloud->points[i].x=1024*rand()/(RAND_MAX+1.0f);cloud->points[i].y=1024*rand()/(RAND_MAX+1.0f);cloud->points[i].z=1024*rand()/(RAND_MAX+1.0f);}//创建条件限定下的滤波器pcl::ConditionAnd<pcl::PointXYZ>::Ptr range_cond(new pcl::ConditionAnd<pcl::PointXYZ>);pcl::FieldComparison<pcl::PointXYZ>::ConstPtr cond_1(new pcl::FieldComparison<pcl::PointXYZ>("z",pcl::ComparisonOps::GT,0.0));range_cond->addComparison(cond_1);pcl::FieldComparison<pcl::PointXYZ>::ConstPtr cond_2(new pcl::FieldComparison<pcl::PointXYZ>("z",pcl::ComparisonOps::LT,0.8));range_cond->addComparison(cond_2);//创建滤波器并用条件定义对象初始化pcl::ConditionalRemoval<pcl::PointXYZ> condrem(range_cond);condrem.setInputCloud(cloud);condrem.setKeepOrganized(true);condrem.filter(*cloud_filtered);std::cerr<<"cloud before filtering:"<<std::endl;for(size_t i=0;i<cloud->points.size();i++)std::cerr<<' '<<cloud->points[i].x<<' '<<cloud->points[i].y<<' '<<cloud->points[i].z<<std::endl;std::cerr<<"cloud after filtering:"<<std::endl;for(size_t i=0;i<cloud_filtered->points.size();i++)std::cerr<<' '<<cloud_filtered->points[i].x<<' '<<cloud_filtered->points[i].y<<' '<<cloud->points[i].z<<std::endl;system("pause");return 0; }
这篇关于使用ConditionalRemoval移除离群点的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!