facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.7k stars 1.3k forks source link

Questions on Camera Configurations (Focal Length, FoV, etc) #1695

Closed The-Nerd-AI closed 9 months ago

The-Nerd-AI commented 9 months ago

After reading the document, I have questions on camera configurations in PyTorch3D.

Suppose image_resolution=(256,256) and focal_length_ndc_space=1.0. When I use PerspectiveCameras,

(1) focal_length_screen_space==128, right? What is the unit of the value? Is it mm? For example, the default focal length is 50mm in blender.

(2) What is the FoV (Field of View) in this case? The default FoV value is 60 in FoVPerspectiveCameras. In the above setting, what is the value of FoV in PerspectiveCameras?

(3) What is the sensor size(mm) in PerspectiveCameras?

(4) When I obtain R and T from look_at_view_transform(dist=1.0), what is the distance of the camera from the object? Is it 1m? What is the unit of the distance value?

Thank you for this amazing project!

bottler commented 9 months ago

(1) The units in screen space are pixels.

(2) The simple relation is that focal length is 1/tan(fov / 2) so focal_length_ndc_space=1.0 corresponds to FoV=90°.

(3) PerspectiveCameras is an ideal mathematical pinhole camera. The sensor size would be zero.

(4) World space has whatever units you want. The distance is 1.0 in world space. That could be mm or any other unit, whatever your data is using.

The-Nerd-AI commented 9 months ago

@bottler Thank you for the explanations! My questions in (1-3) are resolved.

For (4), I have further questions. Since the function transforms coordinates from world space to camera-view space, the camera distance is defined in world space. What is the default unit of the distance in PyTorch3D? When I use look_at_view_transform(dist=1.0), is ths default unit mm?

Or, is it related to the objects to be rendered? For example, if I render an object whose coordinate values are described in unit of cm, then would the distance 1.0 also have the same unit cm?

Thank you in advance :D

bottler commented 9 months ago

It's the second possibility, i.e. whatever unit the objects are described in.

The-Nerd-AI commented 9 months ago

I got it. Thank you! :D