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

Expose stereo extrinsics #1242

Merged

Conversation

mindThomas
Copy link

  1. Expose the stereo extrinsics correctly within the Projection matrix
  2. Change the reported distortion model to equidistant when using Kannala Brandt model

These change will ensure that the camera_info includes the correct information expected by e.g. the stereo_undistort node in: https://github.com/ethz-asl/image_undistort

@doronhi
Copy link
Contributor

doronhi commented Jul 12, 2020

Thank you for this PR.
You present here with 2 issues. The first one, regarding the the equidistant distortion model, is true and is was dealt with, in #1225
As for the extrinsics, that is a complex issue. It was discussed shortly here: #901 . It may need to involve removing inra2_frame_id completely and treating the IR as a single sensor. You can follow the links in #901 for better explanation. Since it involves a sort of API change and it's not clear that its a practiced convention, I didn't rush to change it.

@mindThomas
Copy link
Author

@doronhi Why are you suggesting that it would require an API change?
I haven't tested the #901 PR, but it seems like this PR would achieve the same thing. This change of including the extrinsics within the camera_info is a necessity for stereo rectification modules such as stereo_image_proc, but I don't see why this change would require an API change?

@doronhi
Copy link
Contributor

doronhi commented Jul 13, 2020

If I understand correctly, what you've done here complies with the definition of cameraInfo.
If I understand @tykurtz correctly, since now R reflects a rotation to frame_id "infra1", in means that infra2 sensor frame_id's is also "infra1".
That means modifying the frame_id on the "/camera/infra2/image_rect_raw" and maybe the "/tf" too.
Although it may be the right thing to do, it means changing the way users have been so far treating this frame.
That's what I meant by "API change".

If indeed, a change in frame_id is needed, I would like to have it in the same PR.
If not, we can accept your PR (removing the distortion model part) and dismiss #901 as included in this one.

So far I did not manage to expert myself on this subject and therefor, a clear "official" reference, would help me commit. @tykurtz? @pavloblindnology ? @stwirth ? I would appreciate help. What is the the official, acceptable, convention regarding the frame id's of a stereo camera?

@doronhi
Copy link
Contributor

doronhi commented Jul 27, 2020

Hi,
Without further response I would like to approve this PR and keep the decision regarding the frame id of sensor infrared2 for a later date.
@mindThomas , could you please rebase this PR?

@doronhi
Copy link
Contributor

doronhi commented Jul 30, 2020

@mindThomas , would you be interested in checking @shirbarzel's experience and trouble with this PR? #1310

@doronhi doronhi closed this Oct 26, 2020
@doronhi doronhi reopened this Oct 26, 2020
@mindThomas mindThomas force-pushed the expose-stereo-extrinsics branch from fe4f21e to 471ab82 Compare November 8, 2020 17:57
@doronhi doronhi merged commit 05afecc into IntelRealSense:development Nov 16, 2020
@doronhi
Copy link
Contributor

doronhi commented Nov 16, 2020

@mindThomas ,
Sorry for getting to this PR so sporadically.
Thank you for taking the time and rebasing it.

@pavloblindnology
Copy link
Contributor

If I understand correctly, what you've done here complies with the definition of cameraInfo.
If I understand @tykurtz correctly, since now R reflects a rotation to frame_id "infra1", in means that infra2 sensor frame_id's is also "infra1".
That means modifying the frame_id on the "/camera/infra2/image_rect_raw" and maybe the "/tf" too.
Although it may be the right thing to do, it means changing the way users have been so far treating this frame.
That's what I meant by "API change".

If indeed, a change in frame_id is needed, I would like to have it in the same PR.
If not, we can accept your PR (removing the distortion model part) and dismiss #901 as included in this one.

So far I did not manage to expert myself on this subject and therefor, a clear "official" reference, would help me commit. @tykurtz? @pavloblindnology ? @stwirth ? I would appreciate help. What is the the official, acceptable, convention regarding the frame id's of a stereo camera?

Somehow I missed this PR discussion.
Having right camera frame_id equal to that of left camera is required by StereoCameraModel from image_geometry, stereo_image_proc which is based on the latter, and RViz Camera Display plugin. Probably there are other packages too.
So, it seems like it's a standard for stereo processing. And it sounds reasonable as right camera projection matrix P with P(0,3) set up corresponds to projecting from left camera frame.
As for TF, we can still publish right camera frame - for the purpose of URDF visualization, for example. It just won't be used by right image topic.
So, we can for example, add next line in updateExtrinsicsCalibData:
_camera_info[right].header.frame_id = _camera_info[left].header.frame_id;
and in publishFrame use camera info frame_id as image frame_id (actually, I don't know why it's not done like this, why do we need optical_frame_id at all);
img->header.frame_id = cam_info.header.frame_id;

And P(0,3) should be negative, as I mentioned here.

Another problem to note is that updateStreamCalibData appears 2 times in the code, the 2nd time in publishFrame

updateStreamCalibData(f.get_profile().as<rs2::video_stream_profile>());

which may reset changes done by updateExtrinsicsCalibData. So it needs to be called here too.

@mindThomas
Copy link
Author

mindThomas commented Mar 30, 2021

Another problem to note is that updateStreamCalibData appears 2 times in the code, the 2nd time in publishFrame which may reset changes done by updateExtrinsicsCalibData. So it needs to be called here too.

This is a good point.
If intrinsics are changed, calling that second updateStreamCalibData, the extrinsics will also have to be recomputed. This will however require a change to the current implementation since the two profiles are not stored so there is currently no way of recomputing the extrinsics within the publishFrame of a single frame.

@pavloblindnology
Copy link
Contributor

This is a good point.
If intrinsics are changed, calling that second updateStreamCalibData, the extrinsics will also have to be recomputed. This will however require a change to the current implementation since the two profiles are not stored so there is currently no way of recomputing the extrinsics within the publishFrame of a single frame.

BTW, no such problem in #901 :)

doronhi added a commit that referenced this pull request May 2, 2021
doronhi added a commit to doronhi/realsense that referenced this pull request May 5, 2021
Added filling correct Tx, Ty values in projection matrix of right camera.
Generalize solution to all stereo sensors (fisheye)
Fixed frame_id of right sensor to match left sensor in a stereo pair. Based on suggestion by @pavloblindnology (IntelRealSense#1242 (comment))
meyerj referenced this pull request Aug 23, 2022
Remove updateExtrinsicsCalibData function.
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