Jump to content
  • Advertisement
Sign in to follow this  
run_g

OpenGL simulating Camera's Focal length in OpenGL

This topic is 3034 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am trying to create a virtual camera from an actual real camera. The focal length of the real camera is 7.9 - 23.7 mm. But OpenGL defines its camera parameters in terms of :-
gluPerspective(  fovy,     aspect,    near,    far  );

gluLookAt(  camera_Position( x, y, z ),    center_Of_ScreenPos( x, y, z),  up_Vector( x, y, z) );


So how can I translate the focal length of the real camera to the virtual camera in terms of the these OpenGL camera parameters so as to simulate the real camera? Thanks

Share this post


Link to post
Share on other sites
Advertisement
You only need to calculate the corresponding field of view. If the focal length is f, and the height of the projection plane (corresponding to the height of the film/sensor) is h, then the vertical FOV is fovy = 2*atan(h/2/f). You need to know the size of your camera's projection plane though.

Share this post


Link to post
Share on other sites
I think this should give you what you want, roughly. Don't forget to convert to degrees. If you want a fisheye lens you could try setting fov to 180.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!