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

Camera HFOV always returns same value even if it changed #500

Closed
chapulina opened this issue Dec 3, 2021 · 3 comments
Closed

Camera HFOV always returns same value even if it changed #500

chapulina opened this issue Dec 3, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@chapulina
Copy link
Contributor

Environment

  • OS Version: Ubuntu Focal
  • Source or binary build? Source, ign-rendering6
  • If this is a GUI or sensor rendering bug, describe your GPU and rendering system. Otherwise delete this section.
    • Rendering plugin: Both ogre and ogre2

Description

  • Expected behavior: Camera::HFOV returns the current angle
  • Actual behavior: Always returns the initial angle

Steps to reproduce

On a Gazebo or GUI plugin, print the camera's HFOV at every frame. The number is constant.

However, looking at the 3D view, it looks like the HFOV varies a lot when the image size changes, but the VFOV remains about the same:

hfov_vfov

Additional info

I believe what happens is that ign-rendering's API exposes HFOV, but Ogre uses VFOV. So when the user sets HFOV, we store it, then calculate VFOV to pass to Ogre:

https://github.com/ignitionrobotics/ign-rendering/blob/ae292a88bd752822e0c0f6ed6fd6029e3fc64d0e/ogre2/src/Ogre2Camera.cc#L75-L81

Then when the image size changes, Ogre keeps the VFOV fixed and changes the HFOV to compensate, but our API doesn't pick that up.

I think that a solution would be to override Camera::HFOV and return the current angle calculated from VFOV. I haven't opened a PR because I wanted to check that all my assumptions are correct and I'm not missing some important detail.

@chapulina chapulina added the bug Something isn't working label Dec 3, 2021
@iche033
Copy link
Contributor

iche033 commented Dec 3, 2021

yeah I think that's what's happening. Alternatively, we can try to maintain the HFOV by calculating the new VFOV based on the new aspect ratio whenever window size changes. Either way works.

@chapulina
Copy link
Contributor Author

Alternatively, we can try to maintain the HFOV by calculating the new VFOV based on the new aspect ratio whenever window size changes.

I thought of that, but I assumed that the current behaviour was preferred because I feel like most simulations are spread horizontally rather than vertically.

I'll look into fixing the returned value.

@azeey
Copy link
Contributor

azeey commented May 31, 2024

Fixed by #636

@azeey azeey closed this as completed May 31, 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
None yet
Development

No branches or pull requests

3 participants