0

我正在尝试将 Carla 的图像保存在我的磁盘中,但我在终端上收到此错误。

Traceback (most recent call last):
  File "carla_basic_tutorial.py", line 83, in <lambda>
    'out%02d/%06d.png' % (n_output, image.frame)
AttributeError: 'Image' object has no attribute 'frame'

我已经从需求文件和 Pillow 中安装了库,安装了 GPU 的驱动程序。

部分代码在下面可用

# Spawn the camera and attach it to the vehicle
camera = world.spawn_actor(
    camera_bp,
    camera_transform,
    attach_to=vehicle
)
actor_list.append(camera)
print('created %s' % camera.type_id)



# Check how much "out" folders already exists
n_output = len([d for d in os.listdir() if d.startswith('out')])

# Sets the function that will be called by the camera
# This will save the images to disk at a "out" folder
camera.listen(lambda image: image.save_to_disk(
     'out%02d/%06d.png' % (n_output, image.frame)
 ))

完整代码在这里完整代码

4

1 回答 1

0

我使用属性解决了这个问题image.frame_number

camera.listen(lambda image: image.save_to_disk(
    'out%02d/%06d' % (n_output, image.frame_number)
))
于 2019-10-26T18:00:20.540 回答