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

[PointCloud] Set texel intrinsic & extrinsic based on selected stream #12576

Merged
merged 2 commits into from
Jan 18, 2024

Conversation

Arun-Prasad-V
Copy link
Contributor

@Arun-Prasad-V Arun-Prasad-V commented Jan 16, 2024

Tracked on LRS-514.

The PointCloud filter supports generating rs2::points for below scenarios:

  1. Input: Depth frame and Color frame
  2. Input: Depth frame and Colorized depth frame

Overview of the issue:

  • Scenario 2 works fine if only Depth stream is enabled.
  • If the user enables both Color and Depth streams and want to generate pointcloud for scenario 2, then the output doesn't look good.

Rootcause:

  • Whenever Color stream is enabled, Color sensor's texel intrinsic and extrinsic is getting used instead of Depth sensor's.

@Arun-Prasad-V Arun-Prasad-V marked this pull request as ready for review January 16, 2024 07:24
@@ -141,7 +141,8 @@ namespace librealsense
sensor_interface & s = dev->get_sensor( x );
for( auto const & sp : s.get_active_streams() )
{
if( sp->get_stream_type() == RS2_STREAM_COLOR )
if(( sp->get_stream_type() == RS2_STREAM_COLOR ) &&
( _prev_stream_filter.stream == RS2_STREAM_COLOR ))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we want the prev filter to be color?

Copy link
Contributor

@maloel maloel Jan 16, 2024

Choose a reason for hiding this comment

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

The way I read it:

  • Whenever Color stream is enabled, Color sensor's texel intrinsic and extrinsic is getting used instead of Depth sensor's.

That means that we want to take the color intrinsics only when we have scenario 1: we actually want to use Color.

What I don't quite understand is why that's reflected in _prev_stream_filter, but I guess we just have to stare at the code some more :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way I read it:

  • Whenever Color stream is enabled, Color sensor's texel intrinsic and extrinsic is getting used instead of Depth sensor's.

That means that we want to take the color intrinsics only when we have scenario 1: we actually want to use Color.

Yes, @maloel. That's right.

What I don't quite understand is why that's reflected in _prev_stream_filter, but I guess we just have to stare at the code some more :)

If we look at this function inspect_other_frame(...) , user will pass the required frame:

  • Color frame for scenario 1
  • Colorized depth frame for scenario 2
  • or even Infrared frame also possible I think

Some default intrinsic and extrinsic values are set for the first time at line 191 and 192 in this same function.
Then, later in this callback, if the Color stream is enabled, they are overwritten by Color sensor's intrinsic and extrinsic.
So, to prevent this overwrite, added a condition to check whether the user want's Color stream or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

This code surrounding _prev_stream_filter is very fishy:

  • Not initialized that I can see...
  • I'm still unclear about its usage -- is it simply a way of saying "we want to do this only once and never again"??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we see the flow of the API calls:

Top level API is map_to(frame mapped). refer rs_processing.h

  • Here _stream_filter will be set as per user's need
    • Color for scenario 1
    • Depth for scenario 2
  • Then, process(...) function is called
    • which in turn calls inspect_other_frame(...) and it sets _prev_stream_filter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

at line 115 in this same function, it is initialized.

Copy link
Contributor

Choose a reason for hiding this comment

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

But it's used in line 113 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like, it is getting initialized with default values (RS2_STREAM_ANY, RS2_FORMAT_ANY, ...) in the constructor stream_filter class in synthetic-stream.h

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm right you are.
Then why compare the previous stream filter and not simply _stream_filter? I think that would be preferable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, that makes sense. will update.

@Arun-Prasad-V Arun-Prasad-V requested a review from Nir-Az January 18, 2024 09:44
@Nir-Az Nir-Az merged commit 80c4ae3 into IntelRealSense:development Jan 18, 2024
17 checks passed
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.

3 participants