Skip to content

Commit

Permalink
PR #13527 from Nir-Az: R/256 -> align to development 20/11/2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir-Az authored Nov 20, 2024
2 parents 3a64d2a + e87b853 commit 0af8a6f
Show file tree
Hide file tree
Showing 44 changed files with 970 additions and 53 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/static_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,15 @@ jobs:
echo "Error - The minimal CMake version required for LibRS is ${EXPECTED_CMAKE_MAJOR_VER}.${EXPECTED_CMAKE_MINOR_VER} but on this build the minimal CMake version that works is $CURRENT_CMAKE_MAJOR_VER.$CURRENT_CMAKE_MINOR_VER"
exit 1
fi
build_flags_docs:
name: "Generate build-flags.html"
timeout-minutes: 10
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3

- name: Build docs
run: |
python3 scripts/lrs_options-to-html.py
6 changes: 6 additions & 0 deletions CMake/lrs_options.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## This file is also being used to generate our build flags document at https://intelrealsense.github.io/librealsense/build-flags-docs/build-flags.html
## Formatting notes for this file:
## Options are listed as: <name> | <description> [comment] | <value>
## regular comments should be ABOVE their relevent option
## use double # for comments that should not show in the options doc

option(ENABLE_CCACHE "Build with ccache." ON)
option(BUILD_WITH_CUDA "Enable CUDA" OFF)
option(BUILD_GLSL_EXTENSIONS "Build GLSL extensions API" ON)
Expand Down
3 changes: 2 additions & 1 deletion common/d500-on-chip-calib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ namespace rs2
auto depth_sensor = _sub->s->as <rs2::depth_sensor>();

// disabling the depth visual preset change for D555 - not needed
if (get_device_pid() != "0B56" && get_device_pid() != "DDS")
std::string dev_name = _dev.supports( RS2_CAMERA_INFO_NAME ) ? _dev.get_info( RS2_CAMERA_INFO_NAME ) : "";
if( dev_name.find( "D555" ) == std::string::npos )
{
// set depth preset as default preset
set_option_if_needed<rs2::depth_sensor>(depth_sensor, RS2_OPTION_VISUAL_PRESET, 1);
Expand Down
6 changes: 3 additions & 3 deletions common/device-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3351,10 +3351,10 @@ namespace rs2
{
bool is_d555 = false;

if( dev.supports( RS2_CAMERA_INFO_PRODUCT_ID ) )
if( dev.supports( RS2_CAMERA_INFO_NAME ) )
{
auto pid_str = std::string( dev.get_info( RS2_CAMERA_INFO_PRODUCT_ID ) );
if( pid_str == "0B56" || pid_str == "DDS" )
auto dev_name = std::string( dev.get_info( RS2_CAMERA_INFO_NAME ) );
if( dev_name.find( "D555" ) != std::string::npos )
is_d555 = true;
}

Expand Down
12 changes: 10 additions & 2 deletions common/output-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ void output_model::add_log(rs2_log_severity severity, std::string filename, int

void output_model::run_command(std::string command, device_models_list & device_models)
{
std::string opcode_error_as_string = "";
try
{
if (to_lower(command) == "clear")
Expand Down Expand Up @@ -990,7 +991,11 @@ void output_model::run_command(std::string command, device_models_list & device_
{
found = true;
auto res = dbg.send_and_receive_raw_data(buffer);

if (res.data())
{
int8_t opcode = *res.data();
opcode_error_as_string = dbg.get_opcode_string(opcode);
}
std::string response = rsutils::string::from() << "\n" << terminal_parser.parse_response(to_lower(command), res);
add_log(RS2_LOG_SEVERITY_INFO, __FILE__, 0, response);
}
Expand All @@ -1006,7 +1011,10 @@ void output_model::run_command(std::string command, device_models_list & device_
}
catch(const std::exception& ex)
{
add_log( RS2_LOG_SEVERITY_ERROR, __FILE__, __LINE__, ex.what() );
std::string error_string = rsutils::string::from() << ex.what();
if (opcode_error_as_string != "")
error_string = rsutils::string::from() << error_string << " (" << opcode_error_as_string << ")";
add_log( RS2_LOG_SEVERITY_ERROR, __FILE__, __LINE__, error_string);
}
}

Expand Down
5 changes: 3 additions & 2 deletions common/subdevice-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ namespace rs2
}
catch (...) {}

auto filters = s->get_recommended_filters();

for (auto&& f : s->get_recommended_filters())
{
auto shared_filter = std::make_shared<filter>(f);
Expand All @@ -215,6 +213,9 @@ namespace rs2
model->enable(false);
}

if( shared_filter->is< rotation_filter >() )
model->enable( false );

if (shared_filter->is<threshold_filter>())
{
if (s->supports(RS2_CAMERA_INFO_PRODUCT_ID))
Expand Down
91 changes: 91 additions & 0 deletions doc/build-flags.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* This file is used in lrs_options-to-html, creating the html build-flags.html file we use to keep
the flags updated */
body {
font-family: 'Roboto', Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
}

.container {
width: 80%;
margin: 0 auto;
padding: 30px;
}

h1 {
text-align: center;
margin-bottom: 20px;
}

h2 {
text-align: center;
margin-bottom: 30px;
}

table {
width: 100%;
border-collapse: collapse;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
border-radius: 8px;
overflow: visible;
}

th, td {
padding: 16px;
text-align: left;
border: 1px solid #ddd;
}

th {
background-color: #5873e0;
color: white;
}

tr:hover {
background-color: #f0f0f0;
}

code {
padding: 2px 4px;
border-radius: 4px;
font-family: 'Roboto Mono', monospace;
}
/* --- Tooltip --- */
.tooltip {
position: relative;
display: block;
}

.tooltip .tooltip-text {
visibility: hidden;
/*width: 120px;*/
background-color: #555;
color: #fff;
text-align: center;
padding: 5%;
border-radius: 6px;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}

.tooltip .tooltip-text::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
visibility: visible;
opacity: 1;
}
Binary file added doc/build-flags.ico
Binary file not shown.
35 changes: 26 additions & 9 deletions examples/post-processing/rs-post-processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct filter_slider_ui
std::string description;
bool is_int;
float value;
float step;
rs2::option_range range;

bool render(const float3& location, bool enabled);
Expand Down Expand Up @@ -71,6 +72,7 @@ int main(int argc, char * argv[]) try

// Declare filters
rs2::decimation_filter dec_filter; // Decimation - reduces depth frame density
rs2::rotation_filter rot_filter; // Rotation - rotates frames
rs2::threshold_filter thr_filter; // Threshold - removes values outside recommended range
rs2::spatial_filter spat_filter; // Spatial - edge-preserving spatial smoothing
rs2::temporal_filter temp_filter; // Temporal - reduces temporal noise
Expand All @@ -85,6 +87,7 @@ int main(int argc, char * argv[]) try

// The following order of emplacement will dictate the orders in which filters are applied
filters.emplace_back("Decimate", dec_filter);
filters.emplace_back("Rotate", rot_filter);
filters.emplace_back("Threshold", thr_filter);
filters.emplace_back(disparity_filter_name, depth_to_disparity);
filters.emplace_back("Spatial", spat_filter);
Expand Down Expand Up @@ -115,11 +118,12 @@ int main(int argc, char * argv[]) try
/* Apply filters.
The implemented flow of the filters pipeline is in the following order:
1. apply decimation filter
2. apply threshold filter
3. transform the scene into disparity domain
4. apply spatial filter
5. apply temporal filter
6. revert the results back (if step Disparity filter was applied
2. apply rotation filter
3. apply threshold filter
4. transform the scene into disparity domain
5. apply spatial filter
6. apply temporal filter
7. revert the results back (if step Disparity filter was applied
to depth domain (each post processing block is optional and can be applied independantly).
*/
bool revert_disparity = false;
Expand Down Expand Up @@ -269,11 +273,12 @@ void render_ui(float w, float h, std::vector<filter_options>& filters)
ImGui::Checkbox(filter.filter_name.c_str(), &tmp_value);
filter.is_enabled = tmp_value;
ImGui::PopStyleColor();

if (filter.supported_options.size() == 0)
if( filter.supported_options.size() == 0 )
{
offset_y += elements_margin;
}

// Draw a slider for each of the filter's options
for (auto& option_slider_pair : filter.supported_options)
{
Expand Down Expand Up @@ -316,11 +321,21 @@ bool filter_slider_ui::render(const float3& location, bool enabled)
{
int value_as_int = static_cast<int>(value);
value_changed = ImGui::SliderInt(("##" + name).c_str(), &value_as_int, static_cast<int>(range.min), static_cast<int>(range.max), "%.0f");
if( step > 1 )
{
value_as_int = static_cast< int >( range.min )
+ ( ( value_as_int - static_cast< int >( range.min ) ) / static_cast< int >( step ) )
* static_cast< int >( step );
}
value = static_cast<float>(value_as_int);
}
else
{
value_changed = ImGui::SliderFloat(("##" + name).c_str(), &value, range.min, range.max, "%.3f", 1.0f);
if( step > 0.0f )
{
value = range.min + round( ( value - range.min ) / step ) * step;
}
}

ImGui::PopItemWidth();
Expand Down Expand Up @@ -356,12 +371,13 @@ filter_options::filter_options(const std::string name, rs2::filter& flt) :
filter(flt),
is_enabled(true)
{
const std::array<rs2_option, 5> possible_filter_options = {
const std::array<rs2_option, 6> possible_filter_options = {
RS2_OPTION_FILTER_MAGNITUDE,
RS2_OPTION_FILTER_SMOOTH_ALPHA,
RS2_OPTION_MIN_DISTANCE,
RS2_OPTION_MAX_DISTANCE,
RS2_OPTION_FILTER_SMOOTH_DELTA
RS2_OPTION_FILTER_SMOOTH_DELTA,
RS2_OPTION_ROTATION
};

//Go over each filter option and create a slider for it
Expand All @@ -378,6 +394,7 @@ filter_options::filter_options(const std::string name, rs2::filter& flt) :
supported_options[opt].name = name + "_" + opt_name;
std::string prefix = "Filter ";
supported_options[opt].label = opt_name;
supported_options[opt].step = range.step;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions include/librealsense2/h/rs_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ extern "C" {
RS2_OPTION_SOC_PVT_TEMPERATURE, /**< Temperature of PVT SOC */
RS2_OPTION_GYRO_SENSITIVITY,/**< Control of the gyro sensitivity level, see rs2_gyro_sensitivity for values */
RS2_OPTION_REGION_OF_INTEREST,/**< The rectangular area used from the streaming profile */
RS2_OPTION_ROTATION,/**Rotates frames*/
RS2_OPTION_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */
} rs2_option;

Expand Down
6 changes: 6 additions & 0 deletions include/librealsense2/h/rs_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ rs2_processing_block* rs2_create_align(rs2_stream align_to, rs2_error** error);
*/
rs2_processing_block* rs2_create_decimation_filter_block(rs2_error** error);

/**
* Creates post-processing filter block. This block accepts frames and applies rotation filter
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
*/
rs2_processing_block * rs2_create_rotation_filter_block( rs2_error ** error );

/**
* Creates Depth post-processing filter block. This block accepts depth frames, applies temporal filter
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
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 @@ -161,6 +161,7 @@ typedef enum rs2_extension
RS2_EXTENSION_SOFTWARE_DEVICE,
RS2_EXTENSION_SOFTWARE_SENSOR,
RS2_EXTENSION_DECIMATION_FILTER,
RS2_EXTENSION_ROTATION_FILTER,
RS2_EXTENSION_THRESHOLD_FILTER,
RS2_EXTENSION_DISPARITY_FILTER,
RS2_EXTENSION_SPATIAL_FILTER,
Expand Down
8 changes: 8 additions & 0 deletions include/librealsense2/hpp/rs_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,14 @@ namespace rs2

return results;
}

std::string get_opcode_string(int opcode)
{
rs2_error* e = nullptr;
char buffer[1024];
rs2_hw_monitor_get_opcode_string(opcode, buffer, sizeof(buffer), _dev.get(), &e);
return std::string(buffer);
}
};

class device_list
Expand Down
42 changes: 42 additions & 0 deletions include/librealsense2/hpp/rs_processing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,48 @@ namespace rs2
}
};

class rotation_filter : public filter
{
public:
/**
* Create rotation filter
* Rotation filter performs rotation of the frames
*/
rotation_filter()
: filter( init(), 1 )
{
}

rotation_filter( float value )
: filter( init(), 1 )
{
set_option( RS2_OPTION_ROTATION, value );
}

rotation_filter( filter f )
: filter( f )
{
rs2_error * e = nullptr;
if( ! rs2_is_processing_block_extendable_to( f.get(), RS2_EXTENSION_ROTATION_FILTER, &e ) && ! e )
{
_block.reset();
}
error::handle( e );
}

private:
friend class context;

std::shared_ptr< rs2_processing_block > init()
{
rs2_error * e = nullptr;
auto block = std::shared_ptr< rs2_processing_block >( rs2_create_rotation_filter_block( &e ),
rs2_delete_processing_block );
error::handle( e );
return block;
}
};

class temporal_filter : public filter
{
public:
Expand Down
2 changes: 2 additions & 0 deletions include/librealsense2/rs.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ float rs2_depth_frame_get_distance(const rs2_frame* frame_ref, int x, int y, rs2
*/
rs2_time_t rs2_get_time( rs2_error** error);

void rs2_hw_monitor_get_opcode_string(int opcode, char* buffer, size_t buffer_size,rs2_device* device, rs2_error** error);

#ifdef __cplusplus
}
#endif
Expand Down
Loading

0 comments on commit 0af8a6f

Please sign in to comment.