python - AttributeError:“图像”对象没有属性“框架”
问题描述
我正在尝试将 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)
))
完整代码在这里完整代码
解决方案
我使用属性解决了这个问题image.frame_number
camera.listen(lambda image: image.save_to_disk(
'out%02d/%06d' % (n_output, image.frame_number)
))
推荐阅读
- jenkins-pipeline - 如何在管道中的两个(或更多)不同阶段运行 CloverPublisher,每次它都会覆盖上一阶段发布的覆盖率报告
- swift - CloudKit 单元测试查询未执行
- c# - LINQ lambda:如何组合没有链接的两个表
- javascript - 如何更改 html 登录页面?
- .net - GraphQL 客户端正在 C# 中重新调整空数据
- python - 我的不和谐命令比我想要的要多
- django - django 视图中的多个表单引发 csrf 令牌错误
- javascript - 渲染着色器而无需在 ThreeJS 中将几何图形添加到场景中
- excel - 如何在 Excel VBA 中粘贴所有形状和列宽
- python - 为什么函数的内存位置每次在 python 中都会改变?