8 import pyrealsense2
as rs
13 dev = test.find_first_device_or_exit()
14 depth_sensor = dev.first_depth_sensor()
15 color_sensor = dev.first_color_sensor()
17 previous_depth_frame_number = -1
18 previous_color_frame_number = -1
19 after_set_option =
False 23 global after_set_option
27 if platform.system() ==
'Linux' and after_set_option:
33 global after_set_option
34 after_set_option =
True 35 sensor.set_option(option, value)
37 after_set_option =
False 40 global previous_depth_frame_number
42 test.check_frame_drops(frame, previous_depth_frame_number, allowed_drops)
43 previous_depth_frame_number = frame.get_frame_number()
46 global previous_color_frame_number
48 test.check_frame_drops(frame, previous_color_frame_number, allowed_drops)
49 previous_color_frame_number = frame.get_frame_number()
52 depth_profile =
next(p
for p
in 53 depth_sensor.profiles
if p.fps() == 30
54 and p.stream_type() == rs.stream.depth
55 and p.format() == rs.format.z16
56 and p.as_video_stream_profile().width() == 640
57 and p.as_video_stream_profile().height() == 480)
59 color_profile =
next(p
for p
in color_sensor.profiles
if p.fps() == 30
60 and p.stream_type() == rs.stream.color
61 and p.format() == rs.format.yuyv
62 and p.as_video_stream_profile().width() == 640
63 and p.as_video_stream_profile().height() == 480)
65 depth_sensor.open( depth_profile )
66 depth_sensor.start( check_depth_frame_drops )
67 color_sensor.open( color_profile )
68 color_sensor.start( check_color_frame_drops )
74 laser_power = rs.option.laser_power
75 current_laser_control = 10
77 test.start(
"Checking for frame drops when setting laser power several times")
80 new_value = current_laser_control + 10*i
86 depth_sensor.set_option( rs.option.visual_preset, int(rs.l500_visual_preset.max_range) )
91 product_line = dev.get_info(rs.camera_info.product_line)
92 options_to_ignore = []
94 if product_line ==
"L500":
95 options_to_ignore = [rs.option.host_performance, rs.option.trigger_camera_accuracy_health, rs.option.reset_camera_accuracy_health]
98 global options_to_ignore
99 options = sensor.get_supported_options()
100 for option
in options:
102 if option
in options_to_ignore:
104 if sensor.is_option_read_only(option):
106 old_value = sensor.get_option( option )
107 range = sensor.get_option_range( option )
108 new_value = range.min
109 if old_value == new_value:
110 new_value = range.max
111 if not log.d(
str(option), old_value,
'->', new_value ):
112 test.info(
str(option), new_value, persistent =
True )
114 sensor.set_option( option, old_value )
116 test.unexpected_exception()
119 test.reset_info( persistent =
True )
124 test.start(
"Checking frame drops when setting options on depth")
131 test.start(
"Checking frame drops when setting options on color")
143 test.print_results_and_exit()
def check_depth_frame_drops(frame)
def test_option_changes(sensor)
def set_new_value(sensor, option, value)
virtual frame finish(frame f)
void next(auto_any_t cur, type2type< T, C > *)
def check_color_frame_drops(frame)