test-frame-drop.py
Go to the documentation of this file.
1 # License: Apache 2.0. See LICENSE file in root directory.
2 # Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #test:device L500*
5 
6 import pyrealsense2 as rs
7 from rspy import test, ac
8 
9 test.set_env_vars({"RS2_AC_DISABLE_CONDITIONS":"1",
10  "RS2_AC_DISABLE_RETRIES":"1",
11  "RS2_AC_FORCE_BAD_RESULT":"1",
12  "RS2_AC_LOG_TO_STDOUT":"1"
13  })
14 
15 # rs.log_to_file( rs.log_severity.debug, "rs.log" )
16 
17 dev = test.find_first_device_or_exit()
18 depth_sensor = dev.first_depth_sensor()
19 color_sensor = dev.first_color_sensor()
20 
21 # Resetting sensors to factory calibration
22 dcs = rs.calibrated_sensor(depth_sensor)
23 
24 ccs = rs.calibrated_sensor(color_sensor)
25 
26 d2r = rs.device_calibration(dev)
27 d2r.register_calibration_change_callback( ac.status_list_callback )
28 
29 cp = next(p for p in color_sensor.profiles if p.fps() == 30
30  and p.stream_type() == rs.stream.color
31  and p.format() == rs.format.yuyv
32  and p.as_video_stream_profile().width() == 1280
33  and p.as_video_stream_profile().height() == 720)
34 
35 dp = next(p for p in
36  depth_sensor.profiles if p.fps() == 30
37  and p.stream_type() == rs.stream.depth
38  and p.format() == rs.format.z16
39  and p.as_video_stream_profile().width() == 1024
40  and p.as_video_stream_profile().height() == 768)
41 
42 # This variable controls how many calibrations we do while testing for frame drops
43 n_cal = 5
44 # Variables for saving the previous color frame number and previous depth frame number
45 previous_color_frame_number = -1
46 previous_depth_frame_number = -1
47 
48 # Functions that assert that each frame we receive has the frame number following the previous frame number
50  global previous_color_frame_number
51  test.check_frame_drops(frame, previous_color_frame_number)
52  previous_color_frame_number = frame.get_frame_number()
53 
55  global previous_depth_frame_number
56  test.check_frame_drops(frame, previous_depth_frame_number)
57  previous_depth_frame_number = frame.get_frame_number()
58 
59 depth_sensor.open( dp )
60 depth_sensor.start( depth_frame_call_back )
61 color_sensor.open( cp )
62 color_sensor.start( color_frame_call_back )
63 
64 #############################################################################################
65 # Test #1
66 test.start("Checking for frame drops in", n_cal, "calibrations")
67 for i in range(n_cal):
68  try:
69  dcs.reset_calibration()
70  ccs.reset_calibration()
71  d2r.trigger_device_calibration( rs.calibration_type.manual_depth_to_rgb )
72  ac.wait_for_calibration()
73  except:
74  test.unexpected_exception()
76 
77 #############################################################################################
78 # Test #2
79 test.start("Checking for frame drops in a failed calibration")
80 ac.reset_status_list()
81 try:
82  d2r.trigger_device_calibration( rs.calibration_type.manual_depth_to_rgb )
83  try:
84  d2r.trigger_device_calibration( rs.calibration_type.manual_depth_to_rgb )
85  ac.wait_for_calibration()
86  except Exception as e: # Second trigger should throw exception
87  test.check_exception(e, RuntimeError, "Camera Accuracy Health is already active")
88  else:
89  test.unexpected_exception()
90  ac.wait_for_calibration() # First trigger should continue and finish successfully
91 except:
92  test.unexpected_exception()
94 
95 #############################################################################################
96 
97 depth_sensor.stop()
98 depth_sensor.close()
99 color_sensor.stop()
100 color_sensor.close()
101 
102 test.print_results_and_exit()
def depth_frame_call_back(frame)
def color_frame_call_back(frame)
virtual frame finish(frame f)
void next(auto_any_t cur, type2type< T, C > *)
Definition: foreach.hpp:757


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