mmp / pbrt-v3

Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.
http://pbrt.org
BSD 2-Clause "Simplified" License
4.86k stars 1.18k forks source link

Focal length of rendered images #255

Open farhanrw opened 4 years ago

farhanrw commented 4 years ago

So, I was using my own scene and rendering it from different view points by tweaking the lookat values in the pbrt file. I have the 3D coordinates of the model that I am rendering so I would like to do a 3D to 2D projection to find out where some specific point lies on a rendered image. I am using the openCV projectPoints function however it requires to know the camera intrinsics and extrinsics. I know the extrinsics using the lookat matrix however i dont know the focal length / focal distance for the default camera in PBRT. As far as I am concerned the default camera in PBRT uses a Pinhole model where by default the focal length is 0. But using a value of 0 in the camera matrix does not make sense and also the values that I am getting for the 3D points are very close to the principal point. The principal point is half_width, half_height of my rendered images. So basically I am looking for a value for my focal lenght.

Can anyone help me with this? Or am I missing something?

Thanks for reading, any sort of help will be appreciated!

danielthompson commented 4 years ago

Assuming your Camera directive in your scene description specifies a perspective camera, it should take an fov parameter (see https://www.pbrt.org/fileformat-v3.html#cameras https://www.pbrt.org/fileformat-v3.html#cameras). You can then calculate the focal length by inserting your fov and solving for f in the equation here: https://photo.stackexchange.com/a/41280 https://photo.stackexchange.com/questions/41273/how-to-calculate-the-fov-in-degrees-from-focal-length-or-distance

On Oct 15, 2019, at 15:50, Farhan notifications@github.com wrote:

So, I was using my own scene and rendering it from different view points by tweaking the lookat values in the pbrt file. I have the 3D coordinates of the model that I am rendering so I would like to do a 3D to 2D projection to find out where some specific point lies on a rendered image. I am using the openCV projectPoints function however it requires to know the camera intrinsics and extrinsics. I know the extrinsics using the lookat matrix however i dont know the focal length / focal distance for the default camera in PBRT. As far as I am concerned the default camera in PBRT uses a Pinhole model where by default the focal length is 0. But using a value of 0 in the camera matrix does not make sense and also the values that I am getting for the 3D points are very close to the principal point. The principal point is half_width, half_height of my rendered images. So basically I am looking for a value for my focal lenght.

Can anyone help me with this? Or am I missing something?

Thanks for reading, any sort of help will be appreciated!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mmp/pbrt-v3/issues/255?email_source=notifications&email_token=AAGMZNG6PVQ5AVXHU2FKTRDQOYUIDA5CNFSM4JBC23M2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HR7OZ2A, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGMZNE3WRX5LRCXUB54WHLQOYUIDANCNFSM4JBC23MQ.

farhanrw commented 4 years ago

Thanks for the comment and also for the pointers. I saw this equation previously however I am not sure how I get the y1 value used there, "y1 is the half-size of your sensor."

farhanrw commented 4 years ago

Still waiting for something that would help.