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

Published CameraInfo does not contain correct information #423

Closed
wittenator opened this issue Apr 4, 2024 · 3 comments
Closed

Published CameraInfo does not contain correct information #423

wittenator opened this issue Apr 4, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@wittenator
Copy link

Environment

  • OS Version: Ubuntu 22.04
  • Source or binary build?
    Binary: Harmonic

Description

  • Expected behavior: The camera info topic should correctly reflect the intrinsic properties of the camera
  • Actual behavior: The camera info contains default values that do no get changed.

Steps to reproduce and output

  1. Insert a camera sensor with non-default parameters e.g.
<sensor name="camera" type="camera">
          <gz_frame_id>camera_link_optical</gz_frame_id>
          <camera>
            <horizontal_fov>1.478294</horizontal_fov>
            <vertical_fov>1.153663</vertical_fov>
            <image>
              <width>640</width>
              <height>480</height>
            </image>
            <clip>
              <near>0.01</near>
              <far>60</far>
            </clip>
          </camera>
          <always_on>1</always_on>
          <update_rate>20</update_rate>
          <visualize>false</visualize>
        </sensor>
  1. Subscribe to the /camera_info topic. This yields the following message:
header {
  stamp {
    sec: 47
  }
  data {
    key: "frame_id"
    value: "camera_link_optical"
  }
}
width: 640
height: 480
distortion {
  k: 0
  k: 0
  k: 0
  k: 0
  k: 0
}
intrinsics {
  k: 277
  k: 0
  k: 160
  k: 0
  k: 277
  k: 120
  k: 0
  k: 0
  k: 1
}
projection {
  p: 277
  p: 0
  p: 160
  p: 0
  p: 0
  p: 277
  p: 120
  p: 0
  p: 0
  p: 0
  p: 1
  p: 0
}
rectification_matrix: 1
rectification_matrix: 0
rectification_matrix: 0
rectification_matrix: 0
rectification_matrix: 1
rectification_matrix: 0
rectification_matrix: 0
rectification_matrix: 0
rectification_matrix: 1

The correct intrinsic matrix would look like this though:

[[351.05947319   0.         320.        ]
 [  0.         368.86247951 240.        ]
 [  0.           0.           1.        ]]
@wittenator wittenator added the bug Something isn't working label Apr 4, 2024
@wittenator wittenator changed the title Published CameraInfo does not contain proper information Published CameraInfo does not contain correct information Apr 4, 2024
@azeey
Copy link
Contributor

azeey commented Apr 4, 2024

I'm not able to reproduce this. After removing vertical_fov, since it's not in the SDF spec, with gz-sim 8.2.0, I get:


header {
  stamp {
    sec: 49
    nsec: 300000000
  }
  data {
    key: "frame_id"
    value: "camera_link_optical"
  }
}
width: 640
height: 480
distortion {
  k: 0
  k: 0
  k: 0
  k: 0
  k: 0
}
intrinsics {
  k: 351.05941772460938
  k: 0
  k: 320
  k: 0
  k: 351.05941772460938
  k: 240
  k: 0
  k: 0
  k: 1
}
projection {
  p: 351.05941772460938
  p: 0
  p: 320
  p: 0
  p: 0
  p: 351.05941772460938
  p: 240
  p: 0
  p: 0
  p: 0
  p: 1
  p: 0
}
rectification_matrix: 1
rectification_matrix: 0
rectification_matrix: 0
rectification_matrix: 0
rectification_matrix: 1
rectification_matrix: 0
rectification_matrix: 0
rectification_matrix: 0
rectification_matrix: 1

@wittenator
Copy link
Author

Oh wow, I don't know where I got this property from. Thanks for the quick fix! I assume that the vertical fov is computed via the horizontal fov and the image width and height given that the virtual sensor has quadratic pixels?

@azeey
Copy link
Contributor

azeey commented Apr 4, 2024

I wasn't able to reproduce the issue even with <vertical_fov> in there. I just thought I would mention it.

I assume that the vertical fov is computed via the horizontal fov and the image width and height given that the virtual sensor has quadratic pixels?

I believe the vertical fov is determined by the horizontal fov and the aspect ratio (see https://gazebosim.org/api/rendering/8/classgz_1_1rendering_1_1Camera.html#adc6fc0b99e5c81f89408f0a69693f155), which is set to width/height:

this->dataPtr->camera->SetAspectRatio(static_cast<double>(width)/height);

I'll go ahead and close this issue since it doesn't appear to be a bug in gz-sensors

@azeey azeey closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2024
@github-project-automation github-project-automation bot moved this from Inbox to Done in Core development Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants