c++ - 使用点云检测表面上的空圆形/矩形
问题描述
我正在使用英特尔 Realsense L515 激光雷达来获取点云。我需要检测表面(即桌子或墙壁)上的空白区域(没有物体阻挡它),以便机械臂有足够的空间在该点向表面施加压力。
到目前为止,我已经在 PCL 中分割了点云,以便找到一个平面,首先检测表面。之后,我尝试在该区域的任何地方分割一个 10-20 厘米的圆圈,以尝试为机器人操作找到一个空白空间。
但是,正如您所看到的,圆圈(黄色点)是空心的,而不是一个完整的圆盘(因此其中可能有物体),并且其中有孔,因此在创建孔时,它并不是桌子上真正的空位通过在平面分割阶段消除的对象(在这种情况下,我的脚在圆的中间)。
有什么方法可以在平面上获得真正的非物体杂乱区域?
当前代码:
//Plane segmentation processing start
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
// Create the plane segmentation object
pcl::SACSegmentation<pcl::PointXYZ> seg;
// Optional
seg.setOptimizeCoefficients (true);
// Mandatory
seg.setModelType (pcl::SACMODEL_PLANE);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setDistanceThreshold (0.005);
// Create the filtering object
pcl::ExtractIndices<pcl::PointXYZ> extract;
// Segment the largest planar component from the remaining cloud
seg.setInputCloud(cloud);
pcl::ScopeTime scopeTime("Test loop plane");
{
seg.segment(*inliers, *coefficients);
}
if (inliers->indices.size() == 0)
{
std::cerr << "Could not estimate a planar model for the given dataset." << std::endl;
}
// Extract the inliers
extract.setInputCloud(cloud);
extract.setIndices(inliers);
extract.setNegative(false);
extract.filter(*cloud_p);
std::cerr << "PointCloud representing the planar component: " << cloud_p->width * cloud_p->height << " data points." << std::endl;
//Circle segmentation processing start
pcl::ModelCoefficients::Ptr coefficients_c (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers_c (new pcl::PointIndices);
// Create the circle segmentation object
pcl::SACSegmentation<pcl::PointXYZ> seg_c;
// Optional
seg_c.setOptimizeCoefficients (true);
// Mandatory
seg_c.setModelType (pcl::SACMODEL_CIRCLE2D);
seg_c.setMethodType (pcl::SAC_RANSAC);
seg_c.setDistanceThreshold (0.01);
seg_c.setRadiusLimits(0.1,0.2);
// Create the filtering object
pcl::ExtractIndices<pcl::PointXYZ> extract_c;
// Segment a circle component from the remaining cloud
seg_c.setInputCloud(cloud_p);
pcl::ScopeTime scopeTime2("Test loop circle");
{
seg_c.segment(*inliers_c, *coefficients_c);
}
if (inliers_c->indices.size() == 0)
{
std::cerr << "Could not estimate a circle model for the given dataset." << std::endl;
}
std::cerr << "Circle coefficients: \nCenter coordinates: " << coefficients_c->values[0] << " " << coefficients_c->values[1] << " " << coefficients_c->values[2] << " ";
// Extract the inliers
extract_c.setInputCloud(cloud_p);
extract_c.setIndices(inliers_c);
extract_c.setNegative(false);
extract_c.filter(*cloud_c);
std::cerr << "PointCloud representing the circle component: " << cloud_c->width * cloud_c->height << " data points." << std::endl;
解决方案
推荐阅读
- html - 引导 CSS 错位
- html - 为什么有些文件在提交到 Subversion 时会丢失?
- c# - C#如何在dataGridView中只显示文件名而不在Winforms中显示完整路径
- java - DateTimeFormatter 和 ZonedDateTime - 在不明确和不存在的日期时间 (DST) 上引发异常
- javascript - NextJS - 将查询参数附加到动态路由
- c# - AsyncIO ControlCode 如何在 C# 中工作
- c# - 如何使用 IConnectionPoint 捕获“作为附件转发”事件?
- python - Telegram API sendPhoto 返回“错误请求:文件类型不匹配”
- ms-access-2013 - MS Access 2013:每个国家销售的前 10 名商品
- python - 无论我尝试什么,PyCharm 都找不到 cv2