最近在看PCL濾波配準(zhǔn)等操作,之前在自動(dòng)駕駛-激光雷達(dá)預(yù)處理/特征提取和提到了一些濾除點(diǎn)云等操作,但是最近作者發(fā)現(xiàn)里面還有一些配準(zhǔn)的方法還沒有提到,所以這里重新開個(gè)章節(jié)來(lái)給大家列舉一些常用的濾波方式,方便大家查閱和使用
濾波&聚類
1.1 直通濾波器
void pass_through_filter(const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &input_cloud) //直通濾波器 { std::cout < < "start pass_through_filter" < < std::endl; calc_sight_center(); //計(jì)算視點(diǎn)中心,視點(diǎn)中心為濾波器的輸入?yún)?shù) //
void ex_segmentor::calc_sight_center() // { // double roll, pitch, yaw; //
tf::Quaternion quat_tmp; // tf::quaternionMsgToTF(latest_camera_pos_.pose.pose.orientation, quat_tmp); // tf::Matrix3x3(quat_tmp).getRPY(roll, pitch, yaw); // centerX_ = latest_camera_pos_.pose.pose.position.x + gaze_length_ * cos(yaw); //
centerY_ = latest_camera_pos_.pose.pose.position.y + gaze_length_ * sin(yaw); //
centerZ_ = latest_camera_pos_.pose.pose.position.z - gaze_length_ * sin(pitch); // } //
build the condition pcl::ConditionAnd< pcl::PointXYZRGB >::Ptr range_limit(new pcl::ConditionAnd< pcl::PointXYZRGB >); //構(gòu)建范圍限制條件
range_limit- >addComparison(pcl::FieldComparison< pcl::PointXYZRGB >::ConstPtr(new pcl::FieldComparison< pcl::PointXYZRGB >("x", pcl::ComparisonOps::GT, centerX_ - 1.5))); // x坐標(biāo)大于視點(diǎn)中心x坐標(biāo)-1.5 range_limit- >addComparison(pcl::FieldComparison< pcl::PointXYZRGB >::ConstPtr(new pcl::FieldComparison< pcl::PointXYZRGB >("x", pcl::ComparisonOps::LT, centerX_ + 1.5))); // x坐標(biāo)小于視點(diǎn)中心x坐標(biāo)+1.5
range_limit- >addComparison(pcl::FieldComparison< pcl::PointXYZRGB >::ConstPtr(new pcl::FieldComparison< pcl::PointXYZRGB >("y", pcl::ComparisonOps::GT, centerY_ - 1.5))); // y坐標(biāo)大于視點(diǎn)中心y坐標(biāo)-1.5
range_limit- >addComparison(pcl::FieldComparison< pcl::PointXYZRGB >::ConstPtr(new pcl::FieldComparison< pcl::PointXYZRGB >("y", pcl::ComparisonOps::LT, centerY_ + 1.5))); // y坐標(biāo)小于視點(diǎn)中心y坐標(biāo)+1.5
range_limit- >addComparison(pcl::FieldComparison< pcl::PointXYZRGB >::ConstPtr(new pcl::FieldComparison< pcl::PointXYZRGB >("z", pcl::ComparisonOps::GT, centerZ_ - 1.5))); // z坐標(biāo)大于視點(diǎn)中心z坐標(biāo)-1.5
range_limit- >addComparison(pcl::FieldComparison< pcl::PointXYZRGB >::ConstPtr(new pcl::FieldComparison< pcl::PointXYZRGB >("z", pcl::ComparisonOps::LT, centerZ_ + 1.5))); // z坐標(biāo)小于視點(diǎn)中心z坐標(biāo)+1.5 //構(gòu)建濾波器
pcl::ConditionalRemoval< pcl::PointXYZRGB > condrem; //構(gòu)建濾波器
condrem.setCondition(range_limit); //設(shè)置濾波條件
condrem.setInputCloud(input_cloud); //設(shè)置輸入點(diǎn)云 //濾波操作
condrem.filter(*input_cloud); }
1.2 離群點(diǎn)濾波器
void statical_outlier_filter(const pcl::PointCloud<PointXYZRGB>::Ptr &input_cloud, int nr_k, double stddev_mult) //濾波器移除離群點(diǎn) { pcl::StatisticalOutlierRemoval<PointXYZRGB> sorfilter(true); //構(gòu)建濾波器 sorfilter.setInputCloud(input_cloud); sorfilter.setMeanK(nr_k); //設(shè)置在進(jìn)行統(tǒng)計(jì)時(shí)考慮的臨近點(diǎn)個(gè)數(shù) sorfilter.setStddevMulThresh(stddev_mult); //設(shè)置判斷是否為離群點(diǎn)的閥值,用來(lái)倍乘標(biāo)準(zhǔn)差,也就是上面的stddev_mult sorfilter.filter(*input_cloud); //濾波結(jié)果存儲(chǔ)到cloud_filtered }
1.3 體素化濾波器
void voxel_filter(const pcl::PointCloud< PointXYZRGB >::Ptr &input_cloud, float resolution) //體素化濾波器
{ pcl::VoxelGrid< PointXYZRGB > voxel_grid; //構(gòu)建體素化濾波器
voxel_grid.setInputCloud(input_cloud); //設(shè)置輸入點(diǎn)云
voxel_grid.setLeafSize(resolution, resolution, resolution); //設(shè)置體素的大小 voxel_grid.filter(*input_cloud); //濾波結(jié)果存儲(chǔ)到cloud_filtered }
1.4 平面點(diǎn)濾除
bool remove_plane(const pcl::PointCloud< PointXYZRGB >::Ptr &input_cloud, const Eigen::Vector3f &axis, double plane_thickness) //移除平面 { pcl::ModelCoefficients::Ptr
coefficients(new pcl::ModelCoefficients); //平面參數(shù)矩陣
pcl::PointIndices::Ptr inliers(new pcl::PointIndices); //平面內(nèi)點(diǎn)索引 // Create the
segmentation object pcl::SACSegmentation< pcl::PointXYZRGB > seg; //構(gòu)建分割對(duì)象
seg.setOptimizeCoefficients(true); //設(shè)置是否優(yōu)化系數(shù)
seg.setModelType(pcl::SACMODEL_PERPENDICULAR_PLANE); //設(shè)置模型類型為平面
seg.setMethodType(pcl::SAC_RANSAC); //設(shè)置分割方法為RANSAC
seg.setMaxIterations(500); //設(shè)置最大迭代次數(shù) seg.setAxis(axis); //設(shè)置分割軸 seg.setEpsAngle(0.25); //設(shè)置角度閾值
seg.setDistanceThreshold(plane_thickness); //設(shè)置距離閾值 0.025 0.018
seg.setInputCloud(input_cloud); //設(shè)置輸入點(diǎn)云 seg.segment(*inliers,
*coefficients); //分割平面 if (inliers- >indices.size() < 500) { //
ROS_INFO("plane size is not enough large to remove."); return false; }
pcl::ExtractIndices< pcl::PointXYZRGB > extract; extract.setInputCloud(input_cloud); //設(shè)置輸入點(diǎn)云 extract.setIndices(inliers); //設(shè)置索引,用來(lái)濾除 extract.setNegative(true); //設(shè)置是否濾除索引內(nèi)的點(diǎn) extract.filter(*input_cloud); return true; }
1.5 RGBD顏色特征聚類
void clustoring_with_color(pcl::PointCloud<pcl::PointXYZRGB>::Ptr &input_cloud, std::vector<pcl::PointCloud<PointXYZRGB>::Ptr> &clusters, int min_cluster_size, float distance_th, float color_th, float region_color_th, unsigned int num_nbr) //根據(jù)點(diǎn)云的顏色完成聚類 { std::vector<pcl::PointIndices> clusters_indices; //聚類索引 pcl::search::KdTree<pcl::PointXYZRGB>::Ptr kdtree(new pcl::search::KdTree<pcl::PointXYZRGB>); //構(gòu)建kd樹 kdtree->setInputCloud(input_cloud); //設(shè)置輸入點(diǎn)云 // 基于顏色的區(qū)域生長(zhǎng)聚類對(duì)象
pcl::RegionGrowingRGB<pcl::PointXYZRGB> clustering; clustering.setInputCloud(input_cloud); clustering.setSearchMethod(kdtree); //設(shè)置搜索方法 // 這里,最小簇大小也會(huì)影響后處理步驟: 小于這個(gè)值的clusters_indices將與鄰點(diǎn)合并。
clustering.setMinClusterSize(min_cluster_size); //設(shè)置最小簇大小 // 設(shè)置距離閾值,以知道哪些點(diǎn)將被視為,鄰點(diǎn) clustering.setDistanceThreshold(distance_th); // 1 // 顏色閾值,用于比較兩個(gè)點(diǎn)的RGB顏色 clustering.setPointColorThreshold(color_th); // 9 6.5 25.0f 18.0f // 后處理步驟的區(qū)域顏色閾值:顏色在閾值內(nèi)的clusters_indices將合并為一個(gè)。
clustering.setRegionColorThreshold(region_color_th); // 2 //區(qū)域耦合時(shí)檢查的附近的數(shù)量。默認(rèn)為100, 在不影響結(jié)果的范圍內(nèi)適度設(shè)定小范圍。
clustering.setNumberOfRegionNeighbours(num_nbr); //設(shè)置近鄰數(shù)量 //
clustering.setSmoothModeFlag(true); // clustering.setSmoothnessThreshold(0.95);
clustering.extract(clusters_indices); //提取聚類索引 for (std::vector<pcl::PointIndices>::const_iterator i = clusters_indices.begin(); i !=
clusters_indices.end(); ++i)//遍歷聚類索引 {
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cluster(new
pcl::PointCloud<pcl::PointXYZRGB>); //構(gòu)建聚類點(diǎn)云 for
(std::vector<int>::const_iterator pit = i->indices.begin(); pit != i->indices.end(); ++pit) //遍歷聚類索引中的點(diǎn)索引 { cluster->points.push_back(input_cloud->points[*pit]); //將點(diǎn)添加到聚類點(diǎn)云 } cluster->width = cluster->points.size(); cluster->height = 1; cluster->is_dense = true; clusters.push_back(cluster); //將聚類點(diǎn)云添加到聚類點(diǎn)云集合中 } }
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。
舉報(bào)投訴
-
plc
+關(guān)注
關(guān)注
5051文章
14602瀏覽量
487056 -
濾波
+關(guān)注
關(guān)注
10文章
703瀏覽量
57985 -
點(diǎn)云
+關(guān)注
關(guān)注
0文章
59瀏覽量
4079
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
熱點(diǎn)推薦
matlab 圖像配準(zhǔn)問(wèn)題,有代碼,配準(zhǔn)區(qū)域是綠色的,想要的是灰度圖像的配準(zhǔn)區(qū)域,求助大神?
','joint');title('配準(zhǔn)完成');set(gca,'units','pixels','Visible','off');frame=getframe;im1=frame2im(frame
發(fā)表于 03-21 16:49
大容量有源濾波與無(wú)功補(bǔ)償方式研究
對(duì)于大容量諧波與無(wú)功功率補(bǔ)償,提出了采用混合型有源電力濾波器以及混合型濾波器與無(wú)源濾波器并聯(lián)補(bǔ)償?shù)?b class='flag-5'>方式,分析了并聯(lián)運(yùn)行時(shí)混合型濾波器與無(wú)源
發(fā)表于 04-06 14:06
?19次下載
SAR圖像自動(dòng)配準(zhǔn)性能分析
合成孔徑雷達(dá)(SAR)圖像的自動(dòng)配準(zhǔn)長(zhǎng)期以來(lái)都未能很好的解決,特別是高分辨率SAR圖像其配準(zhǔn)的關(guān)鍵是穩(wěn)健的特征提取與特征匹配算法。在光學(xué)圖像配
發(fā)表于 04-28 15:04
?26次下載
基于SIFT特征的圖像配準(zhǔn)(仿真圖片)
SIFT圖像處理代碼,必須和三個(gè)文件一起下載使用:基于SIFT特征的圖像配準(zhǔn)(Matlab源代碼)、基于SIFT特征的圖像配準(zhǔn)(圖像匹配)。
發(fā)表于 08-06 08:00
?3次下載
使用PCL進(jìn)行點(diǎn)云數(shù)據(jù)粗配準(zhǔn)算法的研究資料分析
傳統(tǒng)ICP算法精度受點(diǎn)云初始位姿影響較大,收斂速度慢,不能滿足精細(xì)化點(diǎn)云建模的要求。基于此問(wèn)題,通過(guò)基于快速點(diǎn)特征直方圖的采樣一致性配準(zhǔn)方法進(jìn)行粗配準(zhǔn)。首先將兩幀待
發(fā)表于 03-01 09:34
?14次下載
電感濾波常用的三種方式
電感濾波常用的方式如下:1、L型濾波其原理就是輸入端串入一個(gè)電感,電感濾除高頻信號(hào)效果最明顯,主要是利用電感中的電流不能突變的原理,當(dāng)電感中的電流增大時(shí),將其存儲(chǔ)于電感當(dāng)中使電流緩慢增
濾波電容不同補(bǔ)償方式優(yōu)缺點(diǎn)對(duì)比
濾波電容不同補(bǔ)償方式優(yōu)缺點(diǎn)對(duì)比? 濾波電容是電子電路中常用的元件,用于對(duì)信號(hào)進(jìn)行濾波處理。不同的補(bǔ)償方式
常用的ADC濾波算法有哪些
ADC(模數(shù)轉(zhuǎn)換器)濾波算法在信號(hào)處理中起著至關(guān)重要的作用,它們能夠幫助我們提取出有用的信號(hào),同時(shí)濾除噪聲和干擾。以下是常用的ADC濾波算法詳解,這些算法各具特色,適用于不同的應(yīng)用場(chǎng)景。
PCL濾波配準(zhǔn)常用的濾波方式
評(píng)論