当前位置:网站首页>[PCL self study: segmentation4] point cloud segmentation based on Min cut
[PCL self study: segmentation4] point cloud segmentation based on Min cut
2022-06-27 23:40:00 【Stanford rabbit】
be based on Min-Cut Point cloud segmentation
One 、 be based on Min-Cut Point cloud segmentation for
In this section , We will learn how to use in pcl::MinCutSegmentation Class based on min-cut Segmentation algorithm . The algorithm performs binary segmentation for a given input point cloud . According to the center of the object and its radius , The algorithm divides the cloud into two groups : Front attractions and background points ( Points belonging to the object and points not belonging to the object ).
Two 、Min-Cut Principle analysis
The idea of this algorithm needs the knowledge of graph theory , as follows :
1. For a given point cloud algorithm , It constructs a graph , It contains every point in the cloud as a set of vertices , And two other vertices called source and sink . Each vertex corresponding to this point in the graph is connected to the source , Connect and converge with the edge . besides , Each vertex ( Except source and sink ) All have edges that connect the corresponding point to its nearest neighbor .
2. The algorithm assigns weights to each edge . There are three different types of weights . Let's look at
① First , It gives weight to the edges between the point clouds . This weight is called smoothing cost , Calculate by formula
s m o o t h C o s t = e − ( d i s t σ ) 2 smoothCost=e^{-(\frac{dist}{ \sigma })^2} smoothCost=e−(σdist)2
there dist Is the distance between points . The farther away the point , The greater the probability that the edge will be cut .
② next step , Algorithm setting data overhead . It consists of foreground penalty and background penalty . The first is the weights of the edges that connect the point cloud to the source vertex , These edges have user-defined constant values . The second edge assigned to the connection point and the convergence vertex , And calculated by the formula
b a c k g r o u n d P e n a l t y = ( d i s t a n c e T o C e n t e r r a d i u s ) backgroundPenalty=(\frac{distanceToCenter}{radius}) backgroundPenalty=(radiusdistanceToCenter)
there distanceToCenter Is the distance between the object and the desired center in the horizontal plane
d i s t a n c e T o C e n t e r = ( x − c e n t e r X ) 2 + ( y − c e n t e r Y ) 2 distanceToCenter=\sqrt{(x-centerX)^2+(y-centerY)^2} distanceToCenter=(x−centerX)2+(y−centerY)2
The radius appearing in the formula is the input parameter of the algorithm , It can be roughly regarded as the range of points outside the center of the object that do not belong to the foreground ( The horizontal radius of an object ).
3. After all the preparations have been completed , Look for the smallest cut . On this basis , Divide the front scenic spots and background points of the cloud .
The specific principle can be understood by referring to this paper . “Min-Cut Based Segmentation of Point Clouds”.
It should be noted that : The effect of this method is not as good as that described in the paper , And the parameters have been compared . Suitable for learning ideas , Not suitable for direct use .
3、 ... and 、 Sample code
#include <iostream>
#include <vector>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/filters/filter_indices.h> // for pcl::removeNaNFromPointCloud
#include <pcl/segmentation/min_cut_segmentation.h>
int main ()
{
// load pcd Point cloud in file
pcl::PointCloud <pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud <pcl::PointXYZ>);
if ( pcl::io::loadPCDFile <pcl::PointXYZ> ("min_cut_segmentation_tutorial.pcd", *cloud) == -1 )
{
std::cout << "Cloud reading failed." << std::endl;
return (-1);
}
// Select a valid point to split
pcl::IndicesPtr indices (new std::vector <int>);
pcl::removeNaNFromPointCloud(*cloud, *indices);
// pcl::MinCutSegmentation The template class has only one parameter PointT, This parameter indicates which type of point will be used .
pcl::MinCutSegmentation<pcl::PointXYZ> seg;
seg.setInputCloud (cloud);
seg.setIndices (indices);
// Provide the necessary segmentation in the point cloud for the algorithm d Point and index of
pcl::PointCloud<pcl::PointXYZ>::Ptr foreground_points(new pcl::PointCloud<pcl::PointXYZ> ());
pcl::PointXYZ point;
point.x = 68.97;
point.y = -18.55;
point.z = 0.57;
foreground_points->points.push_back(point);
seg.setForegroundPoints (foreground_points);
// As mentioned earlier , The algorithm requires that the point known as the center of the object .
seg.setSigma (0.25);
seg.setRadius (3.0433856);
seg.setNumberOfNeighbours (14);
seg.setSourceWeight (0.8);
// Classify the divided points
std::vector <pcl::PointIndices> clusters;
seg.extract (clusters);
std::cout << "Maximum flow is " << seg.getMaxFlow () << std::endl;
// Show point cloud
pcl::PointCloud <pcl::PointXYZRGB>::Ptr colored_cloud = seg.getColoredCloud ();
pcl::visualization::CloudViewer viewer ("Cluster viewer");
viewer.showCloud(colored_cloud);
while (!viewer.wasStopped ())
{
}
return (0);
}
The segmentation effect is as follows :
The elder's This article The algorithm is tried , The results show that the algorithm is not effective .
【 About bloggers 】
Stanford rabbit , male , Master of engineering, Tianjin University . Since graduation, I have been engaged in optical three-dimensional imaging and point cloud processing . Because the three-dimensional processing library used in work is the internal library of the company , Not universally applicable , So I learned to open source by myself PCL Library and its related mathematical knowledge for use . I would like to share the self-study process with you .
Bloggers lack of talent and knowledge , Not yet able to guide , If you have any questions, please leave a message in the comments section for everyone to discuss .
边栏推荐
- Discuz淘宝客网站模板/迪恩淘宝客购物风格商业版模板
- Online JSON to plaintext tool
- 6G显卡显存不足出现CUDA Error:out of memory解决办法
- 思源笔记订阅停止直接删云端数据嘛?
- 解决新版chrome跨域问题:cookie丢失以及samesite属性问题「建议收藏」
- 撰写外文时怎样引用中文文献?
- 手把手教你移植 tinyriscv 到FPGA上
- webService
- Prediction of benign / malignant breast tumors (logistic regression classifier)
- Senior headhunting team manager: interviewed 3000 consultants, summarized and organized 8 commonalities (Mao Sheng)
猜你喜欢

vmware虚拟机桥接连通
![[sword finger offer] 47 Maximum value of gifts](/img/bc/1aff1223b1672c4089151dc56c4d4e.png)
[sword finger offer] 47 Maximum value of gifts

居家办公竟比去公司上班还累?

VMware virtual machine bridging connectivity

ASP.NET仓库进销存ERP管理系统源码 ERP小程序源码

What problems should be paid attention to in the serpentine wiring of PCB?

How vivado adds timing constraints
思源笔记订阅停止直接删云端数据嘛?
![[tinyriscv verilator] branch transplanted to Da Vinci development board of punctual atom](/img/a8/4786e82d0646b08c195dd0a17af227.png)
[tinyriscv verilator] branch transplanted to Da Vinci development board of punctual atom

EXCEL 打印设置公共表头
随机推荐
Practice torch FX: pytorch based model optimization quantization artifact
Can you do these five steps of single cell data cleaning?
golang使用mongo-driver操作——查(进阶)
思源笔记订阅停止直接删云端数据嘛?
Sentinel
ICML 2022: UFRGS |作为最优策略转移基础的乐观线性支持和后继特征
十大券商注册账户安全吗,会有风险吗?
vivado VIO IP的用法
如何设置企业微信群机器人定时发消息?
Discuz taobaoke website template / Dean taobaoke shopping style commercial version template
What if Fiddler fails to listen to the interface
To build a "strong core" in Nansha, the first IC Nansha conference was held in Nansha
第 2 章 集成 MP
First principles (optimal solution theory)
vmware虚拟机桥接连通
Small chip chiplet Technology
居家办公竟比去公司上班还累?
Use of go log package log
c语言-日期格式化[通俗易懂]
SQL中IS NOT NULL与!=NULL的区别