0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

PCL濾波配準(zhǔn)常用的濾波方式

麥辣雞腿堡 ? 來(lái)源:古月居 ? 作者:lovely_yoshino ? 2023-11-28 11:24 ? 次閱讀

最近在看PCL濾波配準(zhǔn)等操作,之前在自動(dòng)駕駛-激光雷達(dá)預(yù)處理/特征提取和提到了一些濾除點(diǎn)云等操作,但是最近作者發(fā)現(xiàn)里面還有一些配準(zhǔn)的方法還沒(méi)有提到,所以這里重新開(kāi)個(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&lt;PointXYZRGB&gt;::Ptr &input_cloud, int nr_k, double stddev_mult) //濾波器移除離群點(diǎn)    {        pcl::StatisticalOutlierRemoval&lt;PointXYZRGB&gt; 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&lt;pcl::PointXYZRGB&gt;::Ptr &input_cloud, std::vector&lt;pcl::PointCloud&lt;PointXYZRGB&gt;::Ptr&gt; &clusters, int min_cluster_size, float distance_th, float color_th, float region_color_th, unsigned int num_nbr) //根據(jù)點(diǎn)云的顏色完成聚類    {        std::vector&lt;pcl::PointIndices&gt; clusters_indices;                                              //聚類索引        pcl::search::KdTree&lt;pcl::PointXYZRGB&gt;::Ptr kdtree(new pcl::search::KdTree&lt;pcl::PointXYZRGB&gt;); //構(gòu)建kd樹(shù)        kdtree-&gt;setInputCloud(input_cloud);                                                           //設(shè)置輸入點(diǎn)云        // 基于顏色的區(qū)域生長(zhǎng)聚類對(duì)象        

pcl::RegionGrowingRGB&lt;pcl::PointXYZRGB&gt; 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&lt;pcl::PointIndices&gt;::const_iterator i = clusters_indices.begin(); i != 
clusters_indices.end(); ++i)//遍歷聚類索引        {            
pcl::PointCloud&lt;pcl::PointXYZRGB&gt;::Ptr cluster(new 
pcl::PointCloud&lt;pcl::PointXYZRGB&gt;); //構(gòu)建聚類點(diǎn)云            for 
(std::vector&lt;int&gt;::const_iterator pit = i-&gt;indices.begin(); pit != i-&gt;indices.end(); ++pit) //遍歷聚類索引中的點(diǎn)索引            {                cluster-&gt;points.push_back(input_cloud-&gt;points[*pit]); //將點(diǎn)添加到聚類點(diǎn)云            }            cluster-&gt;width = cluster-&gt;points.size();            cluster-&gt;height = 1;            cluster-&gt;is_dense = true;            clusters.push_back(cluster); //將聚類點(diǎn)云添加到聚類點(diǎn)云集合中        }    }
聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(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
    plc
    +關(guān)注

    關(guān)注

    5001

    文章

    12946

    瀏覽量

    459225
  • 濾波
    +關(guān)注

    關(guān)注

    10

    文章

    652

    瀏覽量

    56464
  • 點(diǎn)云
    +關(guān)注

    關(guān)注

    0

    文章

    58

    瀏覽量

    3763
收藏 人收藏

    評(píng)論

    相關(guān)推薦

    常用的經(jīng)典濾波算法有哪些??

    常用的經(jīng)典濾波算法有哪些??
    發(fā)表于 07-01 15:15

    跪求常用濾波方法

    常用濾波方法
    發(fā)表于 12-17 22:50

    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

    AD轉(zhuǎn)換常用濾波算法

    AD轉(zhuǎn)換常用濾波算法
    發(fā)表于 08-01 10:46

    電路濾波方式提問(wèn)

    有人知道這個(gè)電路圖中的四個(gè)電容作用分別是什么嗎?它的低通濾波為什么沒(méi)有電阻,還是只用了電容濾波,濾波方式是什么?
    發(fā)表于 08-31 17:44

    大容量有源濾波與無(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次下載

    濾波器的原理種類以及計(jì)算方式

    濾波器的濾波電路、原理種類以及計(jì)算方式
    的頭像 發(fā)表于 03-12 17:16 ?8.5w次閱讀
    <b class='flag-5'>濾波</b>器的原理種類以及計(jì)算<b class='flag-5'>方式</b>

    基于SIFT特征的圖像準(zhǔn)(圖像匹配)

     SIFT圖像處理代碼,必須和三個(gè)文件一起下載使用:基于SIFT特征的圖像準(zhǔn)(Matlab源代碼)、基于SIFT特征的圖像準(zhǔn)(仿真圖片)。
    發(fā)表于 08-06 08:00 ?3次下載

    基于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次下載
    使用<b class='flag-5'>PCL</b>進(jìn)行點(diǎn)云數(shù)據(jù)粗<b class='flag-5'>配</b><b class='flag-5'>準(zhǔn)</b>算法的研究資料分析

    常用的數(shù)字濾波方法

    平均值濾波就是對(duì)多個(gè)采樣值進(jìn)行平均算法,這是消除隨機(jī)誤差最常用的方法。
    的頭像 發(fā)表于 08-24 11:28 ?4w次閱讀

    電感濾波常用的三種方式

    電感濾波常用方式如下:1、L型濾波其原理就是輸入端串入一個(gè)電感,電感濾除高頻信號(hào)效果最明顯,主要是利用電感中的電流不能突變的原理,當(dāng)電感中的電流增大時(shí),將其存儲(chǔ)于電感當(dāng)中使電流緩慢增
    的頭像 發(fā)表于 12-22 09:09 ?3.2w次閱讀

    TST嘉碩濾波常用型號(hào)列表

    TST嘉碩濾波常用型號(hào)列表
    發(fā)表于 10-27 15:48 ?22次下載

    濾波電容不同補(bǔ)償方式優(yōu)缺點(diǎn)對(duì)比

    濾波電容不同補(bǔ)償方式優(yōu)缺點(diǎn)對(duì)比? 濾波電容是電子電路中常用的元件,用于對(duì)信號(hào)進(jìn)行濾波處理。不同的補(bǔ)償方式
    的頭像 發(fā)表于 01-04 16:00 ?802次閱讀