Skip to content

Add RealSense post-processing filters to RSBagReader - #7519

Open
aekanman wants to merge 1 commit into
isl-org:mainfrom
aekanman:issue-6164-rsbag-post-processing
Open

Add RealSense post-processing filters to RSBagReader#7519
aekanman wants to merge 1 commit into
isl-org:mainfrom
aekanman:issue-6164-rsbag-post-processing

Conversation

@aekanman

Copy link
Copy Markdown

Add RealSense post-processing filters to RSBagReader

Type

Motivation and Context

This adds libRealSense depth post-processing support to o3d.t.io.RSBagReader() playback.

RealSense bag playback already reads and aligns depth/color frames, but users could not apply the standard libRealSense depth filters during bag reading. This PR adds an ordered Python filters argument to RSBagReader.open() so depth post-processing can be configured before depth is aligned to color. This resolves #6164 by adding libRealSense depth post-processing support to o3d.t.io.RSBagReader() playback.

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Description

Changes:

  • Adds RSBagReader::Open(filename, filters) for ordered RealSense depth post-processing filters.
  • Adds Python overload:
    reader.open(filename, {"decimation": {"filter_magnitude": 2}}).
  • Supports decimation, spatial, temporal, and hole_filling.
  • Supports common libRealSense options:
    filter_magnitude, filter_smooth_alpha, filter_smooth_delta, and holes_fill.
  • Applies filters before aligning depth to the color frame.
  • Validates unsupported filters/options before playback thread startup.
  • Preserves filter configuration across EOF seek restart.
  • Adds tutorial docs, changelog entry, and a software-only Python test using SampleL515Bag.

Test results:

PATH=/opt/anaconda3/lib/python3.12/site-packages/clang_format/data/bin:$PATH python util/check_style.py --no_parallel
# All files passed style check

git diff --check
# passed

python -m pytest python/test/t/io/test_realsense.py::test_RSBagReader_post_processing_filters -q
# 1 xpassed

python -m pytest python/test/t/io/test_realsense.py::test_RSBagReader -q
# 1 xfailed, matching the existing RealSense bag-reader test marker

@aekanman
aekanman force-pushed the issue-6164-rsbag-post-processing branch from 6d2dca4 to acc8f3d Compare July 11, 2026 21:08
@ssheorey
ssheorey requested a review from Copilot August 2, 2026 06:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds libRealSense depth post-processing support to o3d.t.io.RSBagReader() bag playback, allowing callers to configure an ordered filter chain (e.g., decimation/spatial/temporal/hole-filling) applied before depth-to-color alignment.

Changes:

  • Add C++ RSBagReader::Open(filename, filters) API and apply configured filters during playback.
  • Add Python RSBagReader.open(filename, filters_dict) overload with dict-to-filter-config conversion and updated docstrings.
  • Add tutorial documentation, changelog entry, and a Python test covering the new behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
python/test/t/io/test_realsense.py Adds a Python test exercising filter configuration during bag playback.
docs/tutorial/sensor/realsense.rst Documents the new filters argument and supported filters/options.
cpp/pybind/t/io/sensor.cpp Adds Python binding overload and dict→C++ filter config conversion.
cpp/open3d/t/io/sensor/realsense/RSBagReader.h Introduces PostProcessingFilter config type and new Open() overload.
cpp/open3d/t/io/sensor/realsense/RSBagReader.cpp Implements filter validation/creation and applies filters before alignment.
CHANGELOG.md Notes the new RSBagReader depth post-processing feature.

Comment on lines +30 to +43
rs2_option GetPostProcessingOption(const std::string &option_name) {
static const std::unordered_map<std::string, rs2_option> options = {
{"filter_magnitude", RS2_OPTION_FILTER_MAGNITUDE},
{"filter_smooth_alpha", RS2_OPTION_FILTER_SMOOTH_ALPHA},
{"filter_smooth_delta", RS2_OPTION_FILTER_SMOOTH_DELTA},
{"holes_fill", RS2_OPTION_HOLES_FILL},
};
const auto it = options.find(option_name);
if (it == options.end()) {
utility::LogError("Unsupported RealSense post-processing option: {}",
option_name);
}
return it->second;
}
Comment on lines +62 to +79
rs2::filter MakePostProcessingFilter(
const RSBagReader::PostProcessingFilter &filter_config) {
if (filter_config.filter_name_ == "decimation") {
return ConfigurePostProcessingFilter(rs2::decimation_filter(),
filter_config);
} else if (filter_config.filter_name_ == "spatial") {
return ConfigurePostProcessingFilter(rs2::spatial_filter(),
filter_config);
} else if (filter_config.filter_name_ == "temporal") {
return ConfigurePostProcessingFilter(rs2::temporal_filter(),
filter_config);
} else if (filter_config.filter_name_ == "hole_filling") {
return ConfigurePostProcessingFilter(rs2::hole_filling_filter(),
filter_config);
}
utility::LogError("Unsupported RealSense post-processing filter: {}",
filter_config.filter_name_);
}
Comment on lines +37 to +48
if (!py::isinstance<py::dict>(filter_item.second)) {
utility::LogError(
"RealSense post-processing filter '{}' options must be a "
"dict.",
filter_config.filter_name_);
}
const auto options =
py::reinterpret_borrow<py::dict>(filter_item.second);
for (const auto &option_item : options) {
filter_config.options_[py::cast<std::string>(option_item.first)] =
py::cast<float>(option_item.second);
}
Comment on lines +84 to +89
@pytest.mark.xfail(strict=False, reason="May fail depending on test state.")
@pytest.mark.skipif(os.getenv('GITHUB_SHA') is not None or
not hasattr(o3d.t.io, 'RSBagReader'),
reason="Hangs in Github Actions, succeeds locally or "
"not built with librealsense")
def test_RSBagReader_post_processing_filters():
frame is aligned to the color frame. Supported filters are ``decimation``,
``spatial``, ``temporal``, and ``hole_filling``.

.. code-block:: Python
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.

o3d.t.io.RSBagReader() with libRealSense Depth Post-Processing

2 participants