Convex hull detection of point cloud is more commonly used. PCL comes with Convex hull detection ConvexHull, which is a relatively simple function. Set the dimension setDimension of ConvexHull, and record it here
Header: #include <; pcl/surface/convex_hull.h>
Header: #include <; pcl/surface/convex_hull.h>
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::io::loadPCDFile<pcl::PointXYZ>("bun_45.pcd", *cloud);
pcl::ConvexHull<pcl::PointXYZ> hull;
hull.setInputCloud(cloud);
hull.setDimension(3);
std::vector<pcl::Vertices> polygons;
pcl::PointCloud<pcl::PointXYZ>::Ptr surface_hull(new pcl::PointCloud<pcl::PointXYZ>);
hull.reconstruct(*surface_hull, polygons);
cout << surface_hull->size() << endl;
// ---------------------- Visualizer -------------------------------------------
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer);
viewer->setBackgroundColor(255,255,255);
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> color_handler(cloud, 255, 255, 0);
viewer->addPointCloud(cloud, color_handler, "sample cloud");
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 6, "sample cloud");
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> color_handlerK(surface_hull, 255, 0, 0);
viewer->addPointCloud(surface_hull, color_handlerK, "point");
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 6, "point");
//viewer->addPolygon<pcl::PointXYZ>(surface_hull, 0, 0, 255, "polyline");
while (!viewer->wasStopped())
{
viewer->spinOnce(100);
}
Adopting Stanford Rabbit Point Cloud, the effect is shown in the figure below:
If the point cloud in a certain convex hull is further separated from the scene, Crophull can be used for filtering
CropHull filtering can refer to: https://blog.csdn.net/zfjBIT/article/details/92795689
Thanks for the correction of Xiao snail. If we get the convex hull curve, further triangulation is needed. It is not correct to connect the convex hull points only
Read More:
- Opencv detection yolov4 target detection video stream error
- Error lnk2038 occurred during PCL code compilation: detected “error” during PCL code compilation_ ITERATOR_ DEBUG_ Mismatch of level: value ‘0’ does not match value ‘2’ solution
- Solution of error in CAD license detection
- PCL environment construction (PCL 1.8.1 + vs 2017)
- Vs2012 compiling PCL dependency library vtk7.0
- ‘dependencies.dependency.version‘ for org.springframework.cloud:spring-cloud-starter-openfeign:jar
- PCL environment configuration (pcl1.8.1, vs2017, win10)
- Vs2015 configuring OpenGL development environment: configuration of glfw library and glad Library
- Solution to PCL XL error of HP p2055d laser printer
- How to mine Bitcoin using Alibaba Cloud and Tencent Cloud servers (ubuntu)
- Develop a Boolean equation for overflow detection
- The solution of using OpenGL’s Glu Library in qt5.2 under win7
- Edge detection: two methods
- Configuring glfw library and glad Library in opengl-vs2015
- OpenGL, such as glad library and glfw library, is incompatible
- Cannot call the same level library solution in pychar
- Spring cloud config does not read bootstrap.properties/yml
- PCL Programming Notes — assertion ` PX! = 0 ‘failed
- configure: error: readline library not found solution
- Vs configuration of OpenGL development environment: configuration of glfw library and glad Library