Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/librealsense2/h/rs_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ const char* rs2_get_notification_serialized_data(rs2_notification* notification,
*/
rs2_stream_profile_list* rs2_get_stream_profiles(rs2_sensor* sensor, rs2_error** error);

/**
* retrieve list of debug stream profiles that given subdevice can provide
* \param[in] sensor input RealSense subdevice
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return list of debug stream profiles that given subdevice can provide, should be released by rs2_delete_profiles_list
*/
rs2_stream_profile_list * rs2_get_debug_stream_profiles( rs2_sensor * sensor, rs2_error ** error );

/**
* check how subdevice is streaming
* \param[in] sensor input RealSense subdevice
Expand Down
1 change: 1 addition & 0 deletions include/librealsense2/h/rs_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ typedef enum rs2_extension
RS2_EXTENSION_HDR_MERGE,
RS2_EXTENSION_SEQUENCE_ID_FILTER,
RS2_EXTENSION_MAX_USABLE_RANGE_SENSOR,
RS2_EXTENSION_DEBUG_STREAM_SENSOR,
RS2_EXTENSION_COUNT
} rs2_extension;
const char* rs2_extension_type_to_string(rs2_extension type);
Expand Down
44 changes: 44 additions & 0 deletions include/librealsense2/hpp/rs_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,5 +752,49 @@ namespace rs2
return res;
}
};

class debug_stream_sensor : public sensor
{
public:
debug_stream_sensor( sensor s )
: sensor( s.get() )
{
rs2_error * e = nullptr;
if( rs2_is_sensor_extendable_to( _sensor.get(), RS2_EXTENSION_DEBUG_STREAM_SENSOR, &e ) == 0 && ! e )
{
_sensor.reset();
}
error::handle( e );
}

operator bool() const { return _sensor.get() != nullptr; }

/**
* Retrieves the list of debug stream profiles supported by the sensor.
* \return list of debug stream profiles that given sensor can provide
*/
std::vector< stream_profile > get_debug_stream_profiles() const
{
std::vector< stream_profile > results;

rs2_error * e = nullptr;
std::shared_ptr< rs2_stream_profile_list > list(
rs2_get_debug_stream_profiles( _sensor.get(), &e ),
rs2_delete_stream_profiles_list );
error::handle( e );

auto size = rs2_get_stream_profiles_count( list.get(), &e );
error::handle( e );

for( auto i = 0; i < size; i++ )
{
stream_profile profile( rs2_get_stream_profile( list.get(), i, &e ) );
error::handle( e );
results.push_back( profile );
}

return results;
}
};
}
#endif // LIBREALSENSE_RS2_SENSOR_HPP
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,5 @@ target_sources(${LRS_TARGET}
"${CMAKE_CURRENT_LIST_DIR}/serializable-interface.h"
"${CMAKE_CURRENT_LIST_DIR}/depth-to-rgb-calibration.h"
"${CMAKE_CURRENT_LIST_DIR}/max-usable-range-sensor.h"
"${CMAKE_CURRENT_LIST_DIR}/debug-stream-sensor.h"
)
7 changes: 4 additions & 3 deletions src/core/streaming.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ namespace librealsense

typedef enum profile_tag
{
PROFILE_TAG_ANY = 0,
PROFILE_TAG_SUPERSET = 1, // to be included in enable_all
PROFILE_TAG_DEFAULT = 2, // to be included in default pipeline start
PROFILE_TAG_ANY = 4, // does not include PROFILE_TAG_DEBUG
PROFILE_TAG_DEBUG = 8, // tag for debug formats
} profile_tag;

struct tagged_profile
{
rs2_stream stream;
int stream_index;
uint32_t width, height;
int width, height;
rs2_format format;
uint32_t fps;
int fps;
int tag;
};

Expand Down
16 changes: 16 additions & 0 deletions src/debug-stream-sensor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2020 Intel Corporation. All Rights Reserved.

#pragma once

#include "core/streaming.h"

namespace librealsense
{
class debug_stream_sensor
{
public:
virtual stream_profiles get_debug_stream_profiles() const= 0;
};
MAP_EXTENSION( RS2_EXTENSION_DEBUG_STREAM_SENSOR, debug_stream_sensor );
}
36 changes: 18 additions & 18 deletions src/ds5/ds5-factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,11 @@ namespace librealsense
auto usb_spec = get_usb_spec();
bool usb3mode = (usb_spec >= platform::usb3_type || usb_spec == platform::usb_undefined);

uint32_t depth_width = usb3mode ? 848 : 640;
uint32_t depth_height = usb3mode ? 480 : 480;
uint32_t color_width = usb3mode ? 1280 : 640;
uint32_t color_height = usb3mode ? 720 : 480;
uint32_t fps = usb3mode ? 30 : 15;
int depth_width = usb3mode ? 848 : 640;
int depth_height = usb3mode ? 480 : 480;
int color_width = usb3mode ? 1280 : 640;
int color_height = usb3mode ? 720 : 480;
int fps = usb3mode ? 30 : 15;

tags.push_back({ RS2_STREAM_COLOR, -1, color_width, color_height, RS2_FORMAT_RGB8, fps, profile_tag::PROFILE_TAG_SUPERSET | profile_tag::PROFILE_TAG_DEFAULT });
tags.push_back({ RS2_STREAM_DEPTH, -1, depth_width, depth_height, RS2_FORMAT_Z16, fps, profile_tag::PROFILE_TAG_SUPERSET | profile_tag::PROFILE_TAG_DEFAULT });
Expand Down Expand Up @@ -855,9 +855,9 @@ namespace librealsense
auto usb_spec = get_usb_spec();
bool usb3mode = (usb_spec >= platform::usb3_type || usb_spec == platform::usb_undefined);

uint32_t width = usb3mode ? 1280 : 640;
uint32_t height = usb3mode ? 720 : 480;
uint32_t fps = usb3mode ? 30 : 15;
int width = usb3mode ? 1280 : 640;
int height = usb3mode ? 720 : 480;
int fps = usb3mode ? 30 : 15;

tags.push_back({ RS2_STREAM_COLOR, -1, width, height, RS2_FORMAT_RGB8, fps, profile_tag::PROFILE_TAG_SUPERSET | profile_tag::PROFILE_TAG_DEFAULT });
tags.push_back({ RS2_STREAM_DEPTH, -1, width, height, RS2_FORMAT_Z16, fps, profile_tag::PROFILE_TAG_SUPERSET | profile_tag::PROFILE_TAG_DEFAULT });
Expand Down Expand Up @@ -927,11 +927,11 @@ namespace librealsense
auto usb_spec = get_usb_spec();
bool usb3mode = (usb_spec >= platform::usb3_type || usb_spec == platform::usb_undefined);

uint32_t depth_width = usb3mode ? 848 : 640;
uint32_t depth_height = usb3mode ? 480 : 480;
uint32_t color_width = usb3mode ? 1280 : 640;
uint32_t color_height = usb3mode ? 720 : 480;
uint32_t fps = usb3mode ? 30 : 15;
int depth_width = usb3mode ? 848 : 640;
int depth_height = usb3mode ? 480 : 480;
int color_width = usb3mode ? 1280 : 640;
int color_height = usb3mode ? 720 : 480;
int fps = usb3mode ? 30 : 15;

tags.push_back({ RS2_STREAM_COLOR, -1, color_width, color_height, RS2_FORMAT_RGB8, fps, profile_tag::PROFILE_TAG_SUPERSET | profile_tag::PROFILE_TAG_DEFAULT });
tags.push_back({ RS2_STREAM_DEPTH, -1, depth_width, depth_height, RS2_FORMAT_Z16, fps, profile_tag::PROFILE_TAG_SUPERSET | profile_tag::PROFILE_TAG_DEFAULT });
Expand Down Expand Up @@ -976,11 +976,11 @@ namespace librealsense
auto usb_spec = get_usb_spec();
bool usb3mode = (usb_spec >= platform::usb3_type || usb_spec == platform::usb_undefined);

uint32_t depth_width = usb3mode ? 848 : 640;
uint32_t depth_height = usb3mode ? 480 : 480;
uint32_t color_width = usb3mode ? 1280 : 640;
uint32_t color_height = usb3mode ? 720 : 480;
uint32_t fps = usb3mode ? 30 : 15;
int depth_width = usb3mode ? 848 : 640;
int depth_height = usb3mode ? 480 : 480;
int color_width = usb3mode ? 1280 : 640;
int color_height = usb3mode ? 720 : 480;
int fps = usb3mode ? 30 : 15;

tags.push_back({ RS2_STREAM_COLOR, -1, color_width, color_height, RS2_FORMAT_RGB8, fps, profile_tag::PROFILE_TAG_SUPERSET | profile_tag::PROFILE_TAG_DEFAULT });
tags.push_back({ RS2_STREAM_DEPTH, -1, depth_width, depth_height, RS2_FORMAT_Z16, fps, profile_tag::PROFILE_TAG_SUPERSET | profile_tag::PROFILE_TAG_DEFAULT });
Expand Down
4 changes: 2 additions & 2 deletions src/l500/l500-color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,8 @@ namespace librealsense

bool usb3mode = (_usb_mode >= platform::usb3_type || _usb_mode == platform::usb_undefined);

uint32_t width = usb3mode ? 1280 : 960;
uint32_t height = usb3mode ? 720 : 540;
int width = usb3mode ? 1280 : 960;
int height = usb3mode ? 720 : 540;

tags.push_back({ RS2_STREAM_COLOR, -1, width, height, RS2_FORMAT_RGB8, 30, profile_tag::PROFILE_TAG_SUPERSET | profile_tag::PROFILE_TAG_DEFAULT });

Expand Down
11 changes: 8 additions & 3 deletions src/l500/l500-depth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ namespace librealsense

bool usb3mode = (_usb_mode >= platform::usb3_type || _usb_mode == platform::usb_undefined);

uint32_t width = usb3mode ? 640 : 320;
uint32_t height = usb3mode ? 480 : 240;
int width = usb3mode ? 640 : 320;
int height = usb3mode ? 480 : 240;

tags.push_back({ RS2_STREAM_DEPTH, -1, width, height, RS2_FORMAT_Z16, 30, profile_tag::PROFILE_TAG_SUPERSET | profile_tag::PROFILE_TAG_DEFAULT });
tags.push_back({ RS2_STREAM_INFRARED, -1, width, height, RS2_FORMAT_Y8, 30, profile_tag::PROFILE_TAG_SUPERSET | profile_tag::PROFILE_TAG_DEFAULT });
tags.push_back({ RS2_STREAM_CONFIDENCE, -1, width, height, RS2_FORMAT_RAW8, 30, profile_tag::PROFILE_TAG_SUPERSET });

tags.push_back({ RS2_STREAM_DEPTH, -1, -1, -1, RS2_FORMAT_FG, -1, profile_tag::PROFILE_TAG_DEBUG } );
return tags;
}

Expand Down Expand Up @@ -379,6 +379,11 @@ namespace librealsense
return l500::max_usable_range(noise_estimation);
}

stream_profiles l500_depth_sensor::get_debug_stream_profiles() const
{
return get_stream_profiles( PROFILE_TAG_DEBUG );
}

// We want to disable max-usable-range when not in a particular preset:
bool l500_depth_sensor::is_max_range_preset() const
{
Expand Down
5 changes: 4 additions & 1 deletion src/l500/l500-depth.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "l500-options.h"
#include "calibrated-sensor.h"
#include "max-usable-range-sensor.h"
#include "debug-stream-sensor.h"

namespace librealsense
{
Expand Down Expand Up @@ -93,6 +94,7 @@ namespace librealsense
, public virtual l500_depth_sensor_interface
, public calibrated_sensor
, public max_usable_range_sensor
, public debug_stream_sensor
{
public:
explicit l500_depth_sensor(
Expand Down Expand Up @@ -221,6 +223,8 @@ namespace librealsense

float get_max_usable_depth_range() const override;

stream_profiles get_debug_stream_profiles() const override;

void create_snapshot(std::shared_ptr<depth_sensor>& snapshot) const override
{
snapshot = std::make_shared<depth_sensor_snapshot>(get_depth_scale());
Expand Down Expand Up @@ -260,7 +264,6 @@ namespace librealsense
bool is_max_range_preset() const;

private:

action_delayer _action_delayer;
l500_device * const _owner;
float _depth_units;
Expand Down
1 change: 1 addition & 0 deletions src/realsense.def
Original file line number Diff line number Diff line change
Expand Up @@ -398,5 +398,6 @@ EXPORTS
rs2_terminal_parse_response

rs2_get_max_usable_depth_range
rs2_get_debug_stream_profiles


11 changes: 11 additions & 0 deletions src/rs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,16 @@ rs2_stream_profile_list* rs2_get_stream_profiles(rs2_sensor* sensor, rs2_error**
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, sensor)

rs2_stream_profile_list * rs2_get_debug_stream_profiles( rs2_sensor * sensor,
rs2_error ** error ) BEGIN_API_CALL
{
VALIDATE_NOT_NULL( sensor );
auto debug_streaming
= VALIDATE_INTERFACE( sensor->sensor, librealsense::debug_stream_sensor );
return new rs2_stream_profile_list{ debug_streaming->get_debug_stream_profiles() };
}
HANDLE_EXCEPTIONS_AND_RETURN( nullptr, sensor )

rs2_stream_profile_list* rs2_get_active_streams(rs2_sensor* sensor, rs2_error** error) BEGIN_API_CALL
{
VALIDATE_NOT_NULL(sensor);
Expand Down Expand Up @@ -1390,6 +1400,7 @@ int rs2_is_sensor_extendable_to(const rs2_sensor* sensor, rs2_extension extensio
case RS2_EXTENSION_FISHEYE_SENSOR : return VALIDATE_INTERFACE_NO_THROW(sensor->sensor, librealsense::fisheye_sensor) != nullptr;
case RS2_EXTENSION_CALIBRATED_SENSOR : return VALIDATE_INTERFACE_NO_THROW(sensor->sensor, librealsense::calibrated_sensor) != nullptr;
case RS2_EXTENSION_MAX_USABLE_RANGE_SENSOR : return VALIDATE_INTERFACE_NO_THROW(sensor->sensor, librealsense::max_usable_range_sensor) != nullptr;
case RS2_EXTENSION_DEBUG_STREAM_SENSOR : return VALIDATE_INTERFACE_NO_THROW( sensor->sensor, librealsense::debug_stream_sensor ) != nullptr;


default:
Expand Down
25 changes: 13 additions & 12 deletions src/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,19 @@ namespace librealsense
_source_owner = owner;
}

stream_profiles sensor_base::get_stream_profiles(int tag) const
stream_profiles sensor_base::get_stream_profiles( int tag ) const
{
if (tag == profile_tag::PROFILE_TAG_ANY)
return *_profiles;

stream_profiles results;
for (auto p : *_profiles)

for( auto p : *_profiles )
{
auto curr_tag = p->get_tag();
if (curr_tag & tag)
results.push_back(p);
if( curr_tag & tag
|| tag == profile_tag::PROFILE_TAG_ANY
&& ! ( curr_tag & profile_tag::PROFILE_TAG_DEBUG ) )
{
results.push_back( p );
}
}

return results;
Expand Down Expand Up @@ -262,7 +264,7 @@ namespace librealsense
last_timestamp,
last_frame_number,
false,
fo.frame_size);
(uint32_t)fo.frame_size );
fr->additional_data = additional_data;

// update additional data
Expand Down Expand Up @@ -548,7 +550,6 @@ namespace librealsense
std::unordered_set<std::shared_ptr<video_stream_profile>> profiles;
power on(std::dynamic_pointer_cast<uvc_sensor>(shared_from_this()));

if (_uvc_profiles.empty()) {}
_uvc_profiles = _device->get_profiles();

for (auto&& p : _uvc_profiles)
Expand Down Expand Up @@ -1210,7 +1211,7 @@ namespace librealsense
stream_profiles synthetic_sensor::init_stream_profiles()
{
stream_profiles result_profiles;
auto profiles = _raw_sensor->get_stream_profiles();
auto profiles = _raw_sensor->get_stream_profiles( PROFILE_TAG_ANY | PROFILE_TAG_DEBUG );

for (auto&& pbf : _pb_factories)
{
Expand Down Expand Up @@ -1290,13 +1291,13 @@ namespace librealsense
for (auto&& pbf : _pb_factories)
{
auto satisfied_req = pbf->find_satisfied_requests(requests, _pbf_supported_profiles[pbf.get()]);
satisfied_count = satisfied_req.size();
satisfied_count = (int)satisfied_req.size();
if (satisfied_count > max_satisfied_req
|| (satisfied_count == max_satisfied_req
&& pbf->get_source_info().size() < best_source_size))
{
max_satisfied_req = satisfied_count;
best_source_size = pbf->get_source_info().size();
best_source_size = (int)pbf->get_source_info().size();
best_match_processing_block_factory = pbf;
best_match_requests = satisfied_req;
}
Expand Down
1 change: 1 addition & 0 deletions src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ namespace librealsense
CASE(SEQUENCE_ID_FILTER)
CASE(HDR_MERGE)
CASE(MAX_USABLE_RANGE_SENSOR)
CASE(DEBUG_STREAM_SENSOR)
default: assert(!is_valid(value)); return UNKNOWN_VALUE;
}
#undef CASE
Expand Down
Loading