我是新来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'发布于 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提供的文档,检查您正在使用的函数以及它们是如何定义的。(我知道这可能很乏味,但这是必要的)。
我希望这有助于解决这个问题。
发布于 2020-08-11 12:52:48
根据strawlab的official example的说法,正确的叫法是:
seg.set_max_iterations(100)
https://stackoverflow.com/questions/63305508
复制相似问题