oboxes = inliers_cloud.detect_planar_patches( RuntimeError: [Open3D Error] (class std::vector<class std::shared_ptr<class open3d::geometry::OrientedBoundingBox>,class std::allocator<class std::shared_ptr<class open3d::geometry::OrientedBoundingBox> > > __cdecl open3d::geometry::PointCloud::DetectPlanarPatches(double,double,double,double,unsigned __int64,const class open3d::geometry::KDTreeSearchParam &) const) D:\a\Open3D\Open3D\cpp\open3d\geometry\PointCloudPlanarPatchDetection.cpp:963: DetectPlanarPatches requires pre-computed normal vectors.
时间: 2023-08-20 14:05:26 浏览: 74
这个错误是由于在执行 `detect_planar_patches` 函数时,没有预先计算法向量导致的。`detect_planar_patches` 函数需要法向量作为输入来检测平面补丁。
为了解决这个问题,你需要在调用 `detect_planar_patches` 函数之前,先计算点云的法向量。你可以使用 `estimate_normals` 函数来计算点云的法向量。示例代码如下:
```python
import open3d as o3d
# 读取点云数据
pcd = o3d.io.read_point_cloud("point_cloud.pcd")
# 计算法向量
pcd.estimate_normals()
# 检测平面补丁
inliers_cloud, outliers_cloud = pcd.detect_planar_patches()
# 其他操作...
```
这样修改后,你应该可以成功执行 `detect_planar_patches` 函数了。
相关问题
#if 1 //zhangyu 20220223 robot::path_plan_msg path_recv = path_plan_t; std::reverse(path_recv.x.begin(), path_recv.x.end()); std::reverse(path_recv.y.begin(), path_recv.y.end()); if(path_recv.x.size() < 10) return; robot::path_plan_msg path_filter; int psize = path_recv.x.size(); for(int i = 0; i < psize; i++) { if(i == 0) { path_filter.x.push_back(path_recv.x[i]); path_filter.y.push_back(path_recv.y[i]); continue; } int fsize = path_filter.x.size(); double x0 = path_filter.x[fsize-1]; double y0 = path_filter.y[fsize-1]; double x1 = path_recv.x[i]; double y1 = path_recv.y[i]; double len = hypot(x1-x0, y1-y0); if(len > 0.1 && len < 3.0) { path_filter.x.push_back(path_recv.x[i]); path_filter.y.push_back(path_recv.y[i]); }else { } // ROS_ERROR("Bad path point detect len = %lf", len); } std::reverse(path_filter.x.begin(), path_filter.x.end()); std::reverse(path_filter.y.begin(), path_filter.y.end()); path_plan_t = path_filter; #endif //zhangyu 20220223
这段代码是一个条件编译块(`#if 1` 和 `#endif`)内的实现,用于对路径规划数据进行筛选和反转。
首先,代码创建了一个`path_plan_msg`类型的变量`path_recv`,并将`path_plan_t`的值赋给它。然后,使用`std::reverse`函数将`path_recv.x`和`path_recv.y`中的元素进行反转。
接下来,如果`path_recv.x`的大小小于10,则直接返回。
然后,代码创建了另一个`path_plan_msg`类型的变量`path_filter`,用于存储筛选后的路径规划数据。接着,使用一个循环遍历`path_recv.x`和`path_recv.y`中的元素。
在循环中,首先判断是否是第一个点(即`i == 0`),如果是,则直接将该点添加到`path_filter.x`和`path_filter.y`中,并继续下一次循环。
接下来,获取`path_filter.x`和`path_filter.y`最后一个点的坐标`(x0, y0)`,以及当前遍历到的点的坐标`(x1, y1)`,并计算两点之间的距离`len`。
如果距离大于0.1且小于3.0,则将当前点添加到`path_filter.x`和`path_filter.y`中,否则不进行添加操作。
最后,使用`std::reverse`函数将`path_filter.x`和`path_filter.y`中的元素进行反转,并将最终的筛选结果赋值给`path_plan_t`。
总结来说,这段代码的功能是对路径规划数据进行筛选和反转。它将接收到的路径规划数据反转后进行筛选,保留满足一定条件的点,并将筛选结果赋值给原始的路径规划数据。
img_pub = nh_.advertise<sensor_msgs::Image>(img_pub_name,10); loca_pub = nh_.advertise<detect_msgs::BoundingBoxes>(loca_pub_name,10);
这段代码中使用了 `nh_.advertise` 方法创建了两个消息发布者,分别是 `img_pub` 和 `loca_pub`。
`img_pub` 是一个用于发布 `sensor_msgs::Image` 类型消息的发布者,它将消息发布到名为 `img_pub_name` 的话题上,发布队列的大小为10。
`loca_pub` 是一个用于发布 `detect_msgs::BoundingBoxes` 类型消息的发布者,它将消息发布到名为 `loca_pub_name` 的话题上,发布队列的大小为10。
通过创建这两个发布者,可以将相应类型的消息发送给订阅了相应话题的节点,使其能够接收和处理这些消息。