Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for post processing filters #11566

Merged
merged 3 commits into from Mar 20, 2023
Merged

Conversation

OhadMeir
Copy link
Contributor

Enabling post processing filters for DDS devices.

Using filters name to create appropriate filters at the client side.

@OhadMeir OhadMeir marked this pull request as ready for review March 19, 2023 11:54
src/context.cpp Outdated
if( filter_name.compare( "Depth Huffman Decoder" ) == 0 )
current_filters.add_processing_block( std::make_shared< depth_decompression_huffman >() );
else if( filter_name.compare( "Decimation Filter" ) == 0 )
//TODO - set options? might be needed according to stream type
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this does not support setting internal options?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the comment - sensor.cpp sets format option based on sensor type, but the filter does not use it and selects the appropriate decimation algorithm based on processed frame profile format. No need to set the options

@@ -955,6 +1012,18 @@ namespace librealsense
std::map< std::string, frame_metadata_syncer< rs2_software_motion_frame > > _stream_name_to_motion_syncer;
};

// For cases when checking if this is< color_sensor > (like realsense-viewer::subdevice_model)
class dds_color_sensor_proxy : public dds_sensor_proxy, public color_sensor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check is we can add also depth_sensor
Can be on the todo list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@@ -301,7 +301,7 @@ bool dds_device::impl::init()
}
else if( state_type::WAIT_FOR_DEVICE_OPTIONS == state && id == "device-options" )
{
LOG_DEBUG( "... device-options: " << j["n-options"] << " options received" );
LOG_DEBUG( "... device-options: " << j["options"].size() << " options received" );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rsutils::json::has

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

filter_names.push_back( filter );
}

stream_it->second->set_recommended_filters( filter_names );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider std::move

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

}
}
server->init_options( options );
server->set_recommended_filters( filter_names );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider std::move

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@@ -943,6 +952,54 @@ namespace librealsense
throw std::runtime_error( "Could not find a stream that supports option " + name );
}

void add_processing_block( std::string filter_name )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file starts to be really long. If I read it correctly, most of it is dds_sensor_proxy class - please consider to add new h and cpp files for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already mentioned in a previous PR (about metadata support) that we intend to split the DDS to a different file, but because the changes we made broke the LibCI we address it first. After changes will be merged we will create a new PR to split this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

src/context.cpp Outdated
create_processing_block( filter_name );
}

bool processing_block_exists( processing_blocks const & blocks, std::string const & block_name )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this method be const?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

{
auto & current_filters = get_software_recommended_proccesing_blocks();

if( filter_name.compare( "Depth Huffman Decoder" ) == 0 )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing the "==0" and adding"!" instead. e.g:
if( !filter_name.compare( "Depth Huffman Decoder" ) )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that using ! is less readable, because compare returns 0 when it is true. !compare reads like it does not compare.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your style - ok

@@ -955,6 +1012,18 @@ namespace librealsense
std::map< std::string, frame_metadata_syncer< rs2_software_motion_frame > > _stream_name_to_motion_syncer;
};

// For cases when checking if this is< color_sensor > (like realsense-viewer::subdevice_model)
class dds_color_sensor_proxy : public dds_sensor_proxy, public color_sensor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider exporting this class to separate h, cpp files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be moved in a future PR. See previous comments

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

src/context.cpp Outdated
@@ -1093,7 +1162,10 @@ namespace librealsense
if( ! sensor_info.proxy )
{
// This is a new sensor we haven't seen yet
sensor_info.proxy = std::make_shared< dds_sensor_proxy >( stream->sensor_name(), this, _dds_dev );
if( stream->sensor_name().compare( "RGB Camera" ) == 0 )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it some member in the realdds::dds_stream class that can return the stream type (as RS2_STREAM_COLOR)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.
And we can't go over all the profiles and test if there is RGB8 one, because D405 has RGB8 but not a color_sensor.

Comparing sensor name to "RGB Camera" is also the way it was done in ROS wrapper.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor

@remibettan remibettan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few comments - great work!

@Nir-Az
Copy link
Collaborator

Nir-Az commented Mar 20, 2023

@remibetta pending your approval

@remibettan remibettan self-requested a review March 20, 2023 08:50
Copy link
Contributor

@remibettan remibettan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Nir-Az Nir-Az merged commit a4ea614 into IntelRealSense:dds Mar 20, 2023
13 checks passed
maloel added a commit to maloel/librealsense that referenced this pull request Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants