7 import pyrealsense2
as rs
9 from rspy
import test, log
20 Wait for the first frame for 'max_delay_allowed' + 1 extra second 21 If the frame arrives it will return the seconds it took since open() call 22 If no frame it will return 'max_delay_allowed' 24 first_frame_time = max_delay_allowed
28 nonlocal first_frame_time, open_call_stopwatch
29 if first_frame_time == max_delay_allowed:
30 first_frame_time = open_call_stopwatch.get_elapsed()
32 open_call_stopwatch.reset()
34 sensor.start(frame_cb)
39 while first_frame_time == max_delay_allowed
and open_call_stopwatch.get_elapsed() < max_delay_allowed + 1:
45 return first_frame_time
53 test.start(
"Testing device creation time on " + platform.system() +
" OS")
55 dev = test.find_first_device_or_exit()
56 device_creation_time = device_creation_stopwatch.get_elapsed()
57 max_time_for_device_creation = 1.5
58 print(
"Device creation time is: {:.3f} [sec] max allowed is: {:.1f} [sec] ".format(device_creation_time, max_time_for_device_creation))
59 test.check(device_creation_time < max_time_for_device_creation)
64 product_line = dev.get_info(rs.camera_info.product_line)
65 if product_line ==
"D400":
66 max_delay_for_depth_frame = 1.5
67 max_delay_for_color_frame = 1.5
68 elif product_line ==
"L500":
69 max_delay_for_depth_frame = 2.5
70 max_delay_for_color_frame = 1.5
72 log.f(
"This test support only D400 + L515 devices" )
75 ds = dev.first_depth_sensor()
76 cs = dev.first_color_sensor()
79 ds.profiles
if p.fps() == 30
80 and p.stream_type() == rs.stream.depth
81 and p.format() == rs.format.z16)
84 cs.profiles
if p.fps() == 30
85 and p.stream_type() == rs.stream.color
86 and p.format() == rs.format.rgb8)
90 test.start(
"Testing first depth frame delay on " + product_line +
" device - "+ platform.system() +
" OS")
92 print(
"Time until first depth frame is: {:.3f} [sec] max allowed is: {:.1f} [sec] ".format(first_depth_frame_delay, max_delay_for_depth_frame))
93 test.check(first_depth_frame_delay < max_delay_for_depth_frame)
98 test.start(
"Testing first color frame delay on " + product_line +
" device - "+ platform.system() +
" OS")
100 print(
"Time until first color frame is: {:.3f} [sec] max allowed is: {:.1f} [sec] ".format(first_color_frame_delay, max_delay_for_color_frame))
101 test.check(first_color_frame_delay < max_delay_for_color_frame)
106 test.print_results_and_exit()
static std::string print(const transformation &tf)
virtual frame finish(frame f)
void next(auto_any_t cur, type2type< T, C > *)
def time_to_first_frame(sensor, profile, max_delay_allowed)