test_pipeline_first_frame_delay.py
Go to the documentation of this file.
1 # License: Apache 2.0. See LICENSE file in root directory.
2 # Copyright(c) 2021 Intel Corporation. All Rights Reserved.
3 
4 # test:device L500*
5 # test:device D400*
6 
7 import pyrealsense2 as rs
8 from rspy.stopwatch import Stopwatch
9 from rspy import test, log
10 import time
11 import platform
12 
13 
14 # Start depth + color streams and measure the time from stream opened until first frame arrived using pipeline API.
15 # Verify that the time do not exceeds the maximum time allowed
16 # Note - Using Windows Media Foundation to handle power management between USB actions take time (~27 ms)
17 
18 
19 # Set maximum delay for first frame according to product line
20 dev = test.find_first_device_or_exit()
21 
22 # The device starts at D0 (Operational) state, allow time for it to get into idle state
23 time.sleep( 3 )
24 
25 product_line = dev.get_info(rs.camera_info.product_line)
26 if product_line == "D400":
27  max_delay_for_depth_frame = 2
28  max_delay_for_color_frame = 2
29 elif product_line == "L500":
30  max_delay_for_depth_frame = 3 # Includes L515 depth frame FW delay of 1.5 [sec]
31  max_delay_for_color_frame = 1.5
32 else:
33  log.f("This test support only D400 + L515 devices")
34 
35 
36 def time_to_first_frame(config):
37  pipe = rs.pipeline()
38  start_call_stopwatch = Stopwatch()
39  pipe.start(config)
40  pipe.wait_for_frames()
41  delay = start_call_stopwatch.get_elapsed()
42  pipe.stop()
43  return delay
44 
45 
46 ################################################################################################
47 test.start("Testing pipeline first depth frame delay on " + product_line + " device - " + platform.system() + " OS")
48 depth_cfg = rs.config()
49 depth_cfg.enable_stream(rs.stream.depth, rs.format.z16, 30)
50 frame_delay = time_to_first_frame(depth_cfg)
51 print("Delay from pipeline.start() until first depth frame is: {:.3f} [sec] max allowed is: {:.1f} [sec] ".format(frame_delay, max_delay_for_depth_frame))
52 test.check(frame_delay < max_delay_for_depth_frame)
54 
55 
56 ################################################################################################
57 test.start("Testing pipeline first color frame delay on " + product_line + " device - " + platform.system() + " OS")
58 color_cfg = rs.config()
59 color_cfg.enable_stream(rs.stream.color, rs.format.rgb8, 30)
60 frame_delay = time_to_first_frame(color_cfg)
61 print("Delay from pipeline.start() until first color frame is: {:.3f} [sec] max allowed is: {:.1f} [sec] ".format(frame_delay, max_delay_for_color_frame))
62 test.check(frame_delay < max_delay_for_color_frame)
64 
65 
66 ################################################################################################
67 test.print_results_and_exit()
static std::string print(const transformation &tf)
virtual frame finish(frame f)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11