def stop_pipeline(pipeline): if pipeline: try: pipeline.stop() except RuntimeError as rte: # if the error Occurred because the pipeline wasn't started we ignore it if str(rte) != "stop() cannot be called before start()": test.unexpected_exception() except Exception: test.unexpected_exception()
def stop_sensor(sensor): if sensor: # if the sensor is already closed get_active_streams returns an empty list if sensor.get_active_streams(): try: sensor.stop() except RuntimeError as rte: if str( rte ) != "stop_streaming() failed. UVC device is not streaming!": test.unexpected_exception() except Exception: test.unexpected_exception() sensor.close()
def test_option_changes(sensor): options = sensor.get_supported_options() for option in options: try: if sensor.is_option_read_only(option): continue old_value = sensor.get_option(option) range = sensor.get_option_range(option) new_value = range.min if old_value == new_value: new_value = range.max if not log.d(str(option), old_value, '->', new_value): test.info(str(option), new_value, persistent=True) set_new_value(sensor, option, new_value) sensor.set_option(option, old_value) except: test.unexpected_exception() break finally: test.reset_info(persistent=True)
depth_sensor.open(dp) depth_sensor.start(depth_frame_call_back) color_sensor.open(cp) color_sensor.start(color_frame_call_back) ############################################################################################# # Test #1 test.start("Checking for frame drops in", n_cal, "calibrations") for i in range(n_cal): try: dcs.reset_calibration() ccs.reset_calibration() d2r.trigger_device_calibration(rs.calibration_type.manual_depth_to_rgb) ac.wait_for_calibration() except: test.unexpected_exception() test.finish() ############################################################################################# # Test #2 test.start("Checking for frame drops in a failed calibration") ac.reset_status_list() try: d2r.trigger_device_calibration(rs.calibration_type.manual_depth_to_rgb) try: d2r.trigger_device_calibration(rs.calibration_type.manual_depth_to_rgb) ac.wait_for_calibration() except Exception as e: # Second trigger should throw exception test.check_exception(e, RuntimeError, "Camera Accuracy Health is already active") else:
while i < len(list): if list[i - 1] == list[i] == rs.calibration_status.special_frame: del list[i] else: i += 1 ############################################################################################# # Test #1 test.start("Depth sensor is off, should get an error") try: d2r.trigger_device_calibration( rs.calibration_type.manual_depth_to_rgb ) ac.wait_for_calibration() except Exception as e: test.check_exception(e, RuntimeError, "not streaming") else: test.unexpected_exception() # No error Occurred, should have received a RuntimeError test.check(ac.status_list_is_empty()) # No status changes are expected, list should remain empty test.finish() ############################################################################################# # Test #2 test.start("Color sensor is off, calibration should succeed") ac.reset_status_list() # Deleting previous test depth_sensor.open( dp ) depth_sensor.start( lambda f: None ) try: d2r.trigger_device_calibration( rs.calibration_type.manual_depth_to_rgb ) ac.wait_for_calibration() ac.trim_irrelevant_statuses(irrelevant_statuses) filter_special_frames( ac.status_list ) test.check_equal_lists(ac.status_list, successful_calibration_status_list)