我试图将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)
))
完整代码可在此处Full code
答案 0 :(得分:0)
我使用属性file = open(dir, 'r') # dir = imgServer.jpg
data = ''
for line in file:
data += line
print data # only the first 3 lines
image.frame_number