6 import pyrealsense2
as rs
7 from rspy
import test, log
9 devices = test.find_devices_by_product_line_or_exit(rs.product_line.L500)
11 depth_sensor = device.first_depth_sensor()
12 sd = rs.serializable_device(device)
14 visual_preset_number = depth_sensor.get_option(rs.option.visual_preset)
15 visual_preset_name = rs.l500_visual_preset(int(visual_preset_number))
19 :param json: a string representing a json file 20 :return: a dictionary with all settings 22 translation_table = dict.fromkeys(
map(ord,
'",\''),
None)
24 for line
in json.splitlines():
27 setting, value = line.split(
':')
28 setting = setting.strip().translate(translation_table)
29 value = value.strip().translate(translation_table)
30 json_dict[ setting ] = value
34 global depth_sensor, sd
35 depth_sensor.set_option(rs.option.visual_preset, int(rs.l500_visual_preset.low_ambient_light))
36 actual_data =
str( sd.serialize_json() )
42 for key
in actual_data_dict.keys():
43 if key
not in data_dict:
44 log.d(
"New setting added to json:", key)
45 elif "Visual Preset" in key
or "Temperature" in key
or "temperature" in key:
49 elif data_dict[ key ] != actual_data_dict[ key ]:
50 log.d( key,
"was expected to have value of", data_dict[ key ],
51 "but actually had value of", actual_data_dict[ key ])
65 low_ambient_data_with_default_preset =
""" 68 "Apd Temperature": -9999, 69 "Confidence Threshold": 1, 71 "Depth Units": 0.000250000011874363, 73 "Enable IR Reflectivity": 0.0, 74 "Enable Max Usable Range": 0.0, 75 "Error Polling Enabled": 1, 76 "Frames Queue Size": 16, 77 "Freefall Detection Enabled": 1, 78 "Global Time Enabled": 0.0, 79 "Host Performance": 0.0, 80 "Humidity Temperature": 32.8908233642578, 81 "Inter Cam Sync Mode": 0.0, 82 "Invalidation Bypass": 0.0, 83 "LDD temperature": 32.1463623046875, 85 "Ma Temperature": 39.667610168457, 86 "Mc Temperature": 31.6955661773682, 88 "Noise Estimation": 0.0, 90 "Post Processing Sharpening": 1, 91 "Pre Processing Sharpening": 0.0, 93 "Reset Camera Accuracy Health": 0.0, 95 "Trigger Camera Accuracy Health": 0.0, 100 test.start(
"Trying to load settings with default preset from json")
102 sd.load_json( low_ambient_data_with_default_preset )
103 visual_preset_number = depth_sensor.get_option(rs.option.visual_preset)
104 visual_preset_name = rs.l500_visual_preset(int(visual_preset_number))
107 equal = test.check_equal(visual_preset_name, rs.l500_visual_preset.low_ambient_light)
109 log.w(
"It is possible that FW changed the default settings of the camera." )
112 test.unexpected_exception()
119 wrong_data_with_default_preset =
""" 122 "Apd Temperature": -9999, 123 "Confidence Threshold": 1, 125 "Depth Units": 0.000250000011874363, 127 "Enable IR Reflectivity": 0.0, 128 "Enable Max Usable Range": 0.0, 129 "Error Polling Enabled": 1, 130 "Frames Queue Size": 16, 131 "Freefall Detection Enabled": 1, 132 "Global Time Enabled": 0.0, 133 "Host Performance": 0.0, 134 "Humidity Temperature": 32.8908233642578, 135 "Inter Cam Sync Mode": 0.0, 136 "Invalidation Bypass": 0.0, 137 "LDD temperature": 32.1463623046875, 139 "Ma Temperature": 39.667610168457, 140 "Mc Temperature": 31.6955661773682, 142 "Noise Estimation": 0.0, 143 "Noise Filtering": 4, 144 "Post Processing Sharpening": 1, 145 "Pre Processing Sharpening": 0.0, 147 "Reset Camera Accuracy Health": 0.0, 149 "Trigger Camera Accuracy Health": 0.0, 154 test.start(
"Trying to load wrong settings, should get custom preset")
156 sd.load_json( wrong_data_with_default_preset )
157 visual_preset_number = depth_sensor.get_option(rs.option.visual_preset)
158 visual_preset_name = rs.l500_visual_preset(int(visual_preset_number))
160 test.check_equal(visual_preset_name, rs.l500_visual_preset.custom)
162 test.unexpected_exception()
170 wrong_data_with_low_ambient_preset =
""" 173 "Apd Temperature": -9999, 174 "Confidence Threshold": 1, 176 "Depth Units": 0.000250000011874363, 178 "Enable IR Reflectivity": 0.0, 179 "Enable Max Usable Range": 0.0, 180 "Error Polling Enabled": 1, 181 "Frames Queue Size": 16, 182 "Freefall Detection Enabled": 1, 183 "Global Time Enabled": 0.0, 184 "Host Performance": 0.0, 185 "Humidity Temperature": 32.8908233642578, 186 "Inter Cam Sync Mode": 0.0, 187 "Invalidation Bypass": 0.0, 188 "LDD temperature": 32.1463623046875, 190 "Ma Temperature": 39.667610168457, 191 "Mc Temperature": 31.6955661773682, 193 "Noise Estimation": 0.0, 194 "Noise Filtering": 4, 195 "Post Processing Sharpening": 1, 196 "Pre Processing Sharpening": 0.0, 198 "Reset Camera Accuracy Health": 0.0, 200 "Trigger Camera Accuracy Health": 0.0, 205 test.start(
"Trying to load wrong settings with specified preset")
207 sd.load_json( wrong_data_with_low_ambient_preset )
208 visual_preset_number = depth_sensor.get_option(rs.option.visual_preset)
209 visual_preset_name = rs.l500_visual_preset(int(visual_preset_number))
211 test.check_equal(visual_preset_name, rs.l500_visual_preset.low_ambient_light)
213 test.unexpected_exception()
217 test.start(
"Trying to load non default presets")
218 presets = [rs.l500_visual_preset.custom,
219 rs.l500_visual_preset.no_ambient_light,
220 rs.l500_visual_preset.low_ambient_light,
221 rs.l500_visual_preset.max_range,
222 rs.l500_visual_preset.short_range]
224 for preset
in presets:
226 depth_sensor.set_option(rs.option.visual_preset, int(preset))
227 serialized_json = sd.serialize_json()
229 if preset == rs.l500_visual_preset.custom:
230 depth_sensor.set_option(rs.option.visual_preset, int(rs.l500_visual_preset.short_range))
232 depth_sensor.set_option(rs.option.visual_preset, int(rs.l500_visual_preset.custom))
233 sd.load_json(serialized_json)
234 visual_preset_number = depth_sensor.get_option(rs.option.visual_preset)
235 visual_preset_name = rs.l500_visual_preset(int(visual_preset_number))
236 test.check_equal(visual_preset_name, preset)
238 test.unexpected_exception()
242 test.print_results_and_exit()
def log_settings_differences(data)
virtual frame finish(frame f)
GeneratorWrapper< T > map(Func &&function, GeneratorWrapper< U > &&generator)