diff --git a/examples/capture/rs-capture.cpp b/examples/capture/rs-capture.cpp index b7cc55bdd0..f13f5efb31 100644 --- a/examples/capture/rs-capture.cpp +++ b/examples/capture/rs-capture.cpp @@ -1,39 +1,77 @@ -// License: Apache 2.0. See LICENSE file in root directory. +// License: Apache 2.0. See LICENSE file in root directory. // Copyright(c) 2017 Intel Corporation. All Rights Reserved. #include // Include RealSense Cross Platform API -#include "example.hpp" // Include short list of convenience functions for rendering +#include +#include + +std::ostream & operator<<( std::ostream & ss, const rs2::frame & self ) +{ + ss << rs2_format_to_string( self.get_profile().format() ); + ss << " #" << self.get_frame_number(); + ss << " @" << rsutils::string::from( self.get_timestamp() ); + return ss; +} + +std::string print_frameset(rs2::frame f) +{ + std::ostringstream ss; + ss << "frame"; + if (auto fs = f.as()) + { + ss << "set"; + for(auto sf : fs) + { + ss << " " << sf; + } + } + else + { + ss << " " << f; + } + return ss.str(); +} + +void run_and_verify_frame_received(rs2::pipeline& pipe) +{ + auto start = std::chrono::high_resolution_clock().now(); + pipe.start(); + auto frameset = pipe.wait_for_frames(); + auto stop = std::chrono::high_resolution_clock().now(); + auto duration_ms = std::chrono::duration_cast(stop - start).count(); + /*auto depth_frame = frameset.get_depth_frame(); + if( depth_frame) + { + std::cout << "D"; + } + auto color_frame = frameset.get_color_frame(); + if( color_frame) + { + std::cout << "C"; + } + std::cout << std::endl;*/ + std::ostringstream ss; + ss << "After " << duration_ms << "[msec], got first frame of " << print_frameset(frameset); + std::cout << ss.str() << std::endl; + pipe.stop(); +} // Capture Example demonstrates how to // capture depth and color video streams and render them to the screen int main(int argc, char * argv[]) try { - rs2::log_to_console(RS2_LOG_SEVERITY_ERROR); - // Create a simple OpenGL window for rendering: - window app(1280, 720, "RealSense Capture Example"); + rs2::log_to_file(RS2_LOG_SEVERITY_DEBUG, "mylog.txt"); - // Declare depth colorizer for pretty visualization of depth data - rs2::colorizer color_map; - // Declare rates printer for showing streaming rates of the enabled streams. - rs2::rates_printer printer; + auto ctx = rs2::context(); + auto dev = ctx.query_devices().front(); + rs2::pipeline pipe(ctx); + pipe.set_device(&dev); - // Declare RealSense pipeline, encapsulating the actual device and sensors - rs2::pipeline pipe; - - // Start streaming with default recommended configuration - // The default video configuration contains Depth and Color streams - // If a device is capable to stream IMU data, both Gyro and Accelerometer are enabled by default - pipe.start(); - - while (app) // Application still alive? + int iterations = 0; + while (++iterations < 500) // Application still alive? { - rs2::frameset data = pipe.wait_for_frames(). // Wait for next set of frames from the camera - apply_filter(printer). // Print each enabled stream frame rate - apply_filter(color_map); // Find and colorize the depth data - - // The show method, when applied on frameset, break it to frames and upload each frame into a gl textures - // Each texture is displayed on different viewport according to it's stream unique id - app.show(data); + std::cout << "iteration no" << iterations << std::endl; + run_and_verify_frame_received(pipe); } return EXIT_SUCCESS; @@ -48,3 +86,4 @@ catch (const std::exception& e) std::cerr << e.what() << std::endl; return EXIT_FAILURE; } + diff --git a/src/linux/backend-v4l2.cpp b/src/linux/backend-v4l2.cpp index 8889d3f50d..e67cf6322d 100644 --- a/src/linux/backend-v4l2.cpp +++ b/src/linux/backend-v4l2.cpp @@ -2098,6 +2098,7 @@ namespace librealsense ++pixel_format.index; } + LOG_WARNING("GET_PROFILES() - results_size = " << results.size()); return results; } diff --git a/src/rs.cpp b/src/rs.cpp index 035380315b..78af09ffa7 100644 --- a/src/rs.cpp +++ b/src/rs.cpp @@ -2307,6 +2307,7 @@ NOEXCEPT_RETURN(, pipe) rs2_pipeline_profile* rs2_pipeline_start(rs2_pipeline* pipe, rs2_error ** error) BEGIN_API_CALL { VALIDATE_NOT_NULL(pipe); + LOG_WARNING("PIPELINE START"); return new rs2_pipeline_profile{ pipe->pipeline->start(std::make_shared()) }; } HANDLE_EXCEPTIONS_AND_RETURN(nullptr, pipe) diff --git a/unit-tests/live/frames/test-pipeline-start-stop.py b/unit-tests/live/frames/test-pipeline-start-stop.py index 5f8a6b3a74..244e9d1f42 100644 --- a/unit-tests/live/frames/test-pipeline-start-stop.py +++ b/unit-tests/live/frames/test-pipeline-start-stop.py @@ -1,19 +1,21 @@ # License: Apache 2.0. See LICENSE file in root directory. # Copyright(c) 2023-2024 Intel Corporation. All Rights Reserved. -# test:donotrun:!nightly + # Currently, we exclude D457 as it's failing # test:device each(D400*) !D457 # On D455 and other units with IMU it takes ~4 seconds per iteration -# test:timeout 220 +# test:timeout 500 import pyrealsense2 as rs from rspy.stopwatch import Stopwatch from rspy import test, log import time +rs.log_to_file(rs.log_severity.debug, "pipeine_test_log.log") + # Run multiple start stop of all streams and verify we get a frame for each once -ITERATIONS_COUNT = 50 +ITERATIONS_COUNT = 500 dev, ctx = test.find_first_device_or_exit() pipe = rs.pipeline(ctx)