首页 > 解决方案 > python-pcl Segmentation_PointXYZI'对象没有属性'set_MaxIterations'

问题描述

我是 C++ 新手。因此,我正在尝试使用 python-pcl,但出现错误:

AttributeError: 'pcl._pcl.Segmentation_PointXYZI' object has no attribute 'set_MaxIterations'

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

我的代码:

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)

输出:

('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'

标签: pythonrospoint-cloud-librarypoint-cloudslidar

解决方案


根据strawlab的官方示例,正确的调用是:

seg.set_max_iterations(100)


推荐阅读