关于Carla中传感器(摄像头)的仿真,做个简单的记录:
获取摄像头属性的代码如下:
# 创建一个摄像头传感器,并将摄像头安装到车辆上的指定位置处
sensor_camera = world.spawn_actor(blueprint,
attach_to=vehicle)
# 获得所有摄像头参数
attributes_camera = sensor_camera.attributes
# print("camera_attributes:", attributes_camera)
i = 1
for key, value in attributes_camera.items():
key, value)
i += 1
属性输出的结果如下:
attribute_1 role_name front
attribute_2 chromatic_aberration_offset 0.0
attribute_3 sensor_tick 0.0
attribute_4 fstop 1.4
attribute_5 image_size_x 800
attribute_6 image_size_y 600
attribute_7 fov 90.0
attribute_8 lens_circle_falloff 5.0
attribute_9 lens_circle_multiplier 0.0
attribute_10 exposure_compensation 0.0
attribute_11 lens_y_size 0.08
attribute_12 lens_k -1.0
attribute_13 exposure_mode histogram
attribute_14 lens_kcube 0.0
attribute_15 lens_x_size 0.08
attribute_16 exposure_max_bright 12.0
attribute_17 shutter_speed 200.0
attribute_18 bloom_intensity 0.675
attribute_19 iso 100.0
attribute_20 enable_postprocess_effects true
attribute_21 gamma 2.2
attribute_22 motion_blur_intensity 0.45
attribute_23 motion_blur_max_distortion 0.35
attribute_24 lens_flare_intensity 0.1
attribute_25 motion_blur_min_object_screen_size 0.1
attribute_26 exposure_min_bright 10.0
attribute_27 exposure_speed_up 3.0
attribute_28 exposure_speed_down 1.0
attribute_29 tint 0.0
attribute_30 calibration_constant 16.0
attribute_31 focal_distance 1000.0
attribute_32 min_fstop 1.2
attribute_33 blade_count 5
attribute_34 blur_amount 1.0
attribute_35 blur_radius 0.0
attribute_36 slope 0.88
attribute_37 toe 0.55
attribute_38 white_clip 0.04
attribute_39 shoulder 0.26
attribute_40 black_clip 0.0
attribute_41 temp 6500.0
attribute_42 chromatic_aberration_intensity 0.0
上述属性都是默认值。
如果想要自己设置摄像头的属性,结合上述的属性,参照如下的方法。
# 从蓝图库中筛选出来rgb摄像头蓝图
blueprint = blueprint_library.find('sensor.camera.rgb')
# 设置设摄像头蓝图的镜头参数
blueprint.set_attribute('image_size_x', str(1024))
blueprint.set_attribute('image_size_y', str(600))
blueprint.set_attribute('fov', '110')
如上设置后,使用这个blueprint的摄像头的属性就会生效:
本文完。