首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python-pcl Segmentation_PointXYZI‘对象没有属性'set_MaxIterations’

python-pcl Segmentation_PointXYZI‘对象没有属性'set_MaxIterations’
EN

Stack Overflow用户
提问于 2020-08-08 00:09:24
回答 2查看 444关注 0票数 0

我是新来C++的。所以,我尝试使用python-pcl,但我得到了一个错误:

代码语言:javascript
复制
AttributeError: 'pcl._pcl.Segmentation_PointXYZI' object has no attribute 'set_MaxIterations'

我正在尝试为平面模型创建分割对象,并使用PointXYZI类型设置参数。我必须使用PointXYZI。我该如何解决这个问题?

我的代码:

代码语言:javascript
复制
def cluster_extraction(self,data):

    print("Type1: ", type(data))

    cloud_filtered = self.downsampling(data,0.3)     

    print("Type2: ", type(cloud_filtered))  

    seg = cloud_filtered.make_segmenter()
    seg.set_optimize_coefficients (True)
    seg.set_model_type (pcl.SACMODEL_PLANE)
    seg.set_method_type (pcl.SAC_RANSAC)
    seg.set_MaxIterations (100)
    seg.set_distance_threshold (0.02)

输出:

代码语言:javascript
复制
('Type1: ', <type 'pcl._pcl.PointCloud_PointXYZI'>)
('Type2: ', <type 'pcl._pcl.PointCloud_PointXYZI'>)
[ERROR] [1596926303.890116]: bad callback: <bound method sub_pub_node.callback of <__main__.sub_pub_node object at 0x7f154be44ad0>>
Traceback (most recent call last):
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
    cb(msg)
  File "node.py", line 154, in callback
    downsampled_data = self.processing(pcl2_data)
  File "node.py", line 103, in processing
    processing.cluster_extraction(pcl2_data)
  File "node.py", line 43, in cluster_extraction
    seg.set_MaxIterations (100)
AttributeError: 'pcl._pcl.Segmentation_PointXYZI' object has no attribute 'set_MaxIterations'
EN

回答 2

Stack Overflow用户

发布于 2020-08-10 17:42:17

我不确定你的python-pcl包是从哪里来的,但是我会假设你用的是this one,并且因为在Segmentation_PointXYZI类中没有名为set_MaxIterations(int )的方法(大家都这么认为),你可以试着用setMaxIterations(int )来代替它。

PointCloud_PointXYZI类的定义中,您可以发现用于此类型点云的分割方法是来自pcl_seg.SACSegmentation_PointXYZI_t的一个实例,该实例定义了将最大迭代次数设置为setMaxIterations(int )的方法。

请查看here提供的文档,检查您正在使用的函数以及它们是如何定义的。(我知道这可能很乏味,但这是必要的)。

我希望这有助于解决这个问题。

票数 0
EN

Stack Overflow用户

发布于 2020-08-11 12:52:48

根据strawlab的official example的说法,正确的叫法是:

seg.set_max_iterations(100)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63305508

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档