AttributeError: объект 'Image' не имеет атрибута 'frame'

Я пытаюсь сохранить изображения Карлы на свой диск, но на терминале появляется эта ошибка.

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)
 ))

Полный код доступен здесь Полный код

1 ответ

Я решил это с помощью атрибута image.frame_number

camera.listen(lambda image: image.save_to_disk(
    'out%02d/%06d' % (n_output, image.frame_number)
))
Другие вопросы по тегам