From 6a90b19f1d7f853120f7a858e3af40bee4725453 Mon Sep 17 00:00:00 2001 From: Tamir Date: Mon, 2 Oct 2023 11:58:54 +0300 Subject: [PATCH] Y16 calibration format test created --- .../streaming/test-y16-calibration-format.py | 57 +++++++++++++++++++ unit-tests/live/streaming/test-y16.cpp | 52 ----------------- 2 files changed, 57 insertions(+), 52 deletions(-) create mode 100644 unit-tests/live/streaming/test-y16-calibration-format.py delete mode 100644 unit-tests/live/streaming/test-y16.cpp diff --git a/unit-tests/live/streaming/test-y16-calibration-format.py b/unit-tests/live/streaming/test-y16-calibration-format.py new file mode 100644 index 0000000000..81d329baeb --- /dev/null +++ b/unit-tests/live/streaming/test-y16-calibration-format.py @@ -0,0 +1,57 @@ +# License: Apache 2.0. See LICENSE file in root directory. +# Copyright(c) 2023 Intel Corporation. All Rights Reserved. + +# test:device D400* +# This test checks streaming y16 profile + +import time +import pyrealsense2 as rs +from rspy import test, log +from rspy.timer import Timer + + +y16_streamed = False + + +def close_resources(sensor): + """ + Stop and Close sensor. + :sensor: sensor of device + """ + if len(sensor.get_active_streams()) > 0: + sensor.stop() + sensor.close() + + +def frame_callback(frame): + global y16_streamed + y16_streamed = True + + +timer = Timer(5) + +device = test.find_first_device_or_exit() +depth_sensor = device.first_depth_sensor() + +test.start('Check that y16 is streaming:') + +profile_y16 = next(p for p in depth_sensor.profiles if p.format() == rs.format.y16) +test.check(profile_y16) +log.d(str(profile_y16)) + +if profile_y16: + depth_sensor.open(profile_y16) + depth_sensor.start(frame_callback) + + timer.start() + while not timer.has_expired(): + if y16_streamed: + break + time.sleep(0.1) + + test.check(not timer.has_expired()) + + +close_resources(depth_sensor) +test.finish() +test.print_results_and_exit() diff --git a/unit-tests/live/streaming/test-y16.cpp b/unit-tests/live/streaming/test-y16.cpp deleted file mode 100644 index f18806c612..0000000000 --- a/unit-tests/live/streaming/test-y16.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// License: Apache 2.0. See LICENSE file in root directory. -// Copyright(c) 2022 Intel Corporation. All Rights Reserved. - -//#test:device each(D400*) - -#include "../live-common.h" -#include - -using namespace rs2; - -rs2::stream_profile get_ir_y16_profile(rs2::depth_sensor depth_sensor) -{ - auto depth_profiles = depth_sensor.get_stream_profiles(); - rs2::stream_profile ir_profile; - for (auto& p : depth_profiles) - { - if (p.format() == RS2_FORMAT_Y16) - { - ir_profile = p; - break; - } - } - return ir_profile; -} - -// Y16 CONFIGURATION TESTS -TEST_CASE("Y16 streaming", "[live]") -{ - auto dev = find_first_device_or_exit(); - - auto depth_sensor = dev.query_sensors()[0]; - auto y16_profile = get_ir_y16_profile(depth_sensor); - REQUIRE(y16_profile); - depth_sensor.open(y16_profile); - bool y16_streamed = false; - depth_sensor.start([&y16_streamed](rs2::frame f){ - y16_streamed = true; - }); - rsutils::time::timer t(std::chrono::seconds(30)); - while (!t.has_expired()) - { - if (y16_streamed) - break; - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - - // fail on timeout - REQUIRE(!t.has_expired()); - - depth_sensor.stop(); - depth_sensor.close(); -}