pmh47 / dirt

DIRT: a fast differentiable renderer for TensorFlow
MIT License
312 stars 63 forks source link

Change position and angle of camera and get the intrinsic and extrinsic matrices of the camera #81

Closed vangoghcat closed 4 years ago

vangoghcat commented 4 years ago

Thx for awesome work you did ! I have got the depth map of the object sucessfully, but now I want to render it from mutil-views . Is there any way to change position and angle of camera or can I transform the object and fix the camera to achieve the goal? And i need the intrinsic and extrinsic matrices of the camera, how to get them from the code?

pmh47 commented 4 years ago

OpenGL (and therefore DIRT) does not distinguish between the camera extrinsic matrix and the object's world transform / pose. There is just some matrix applied to the vertices, that maps them into view space. And view space by definition has the camera fixed to the origin and looking along the negative z-axis (before the projection matrix is applied). So in short, yes, just transform the object according to the inverse of the camera transform.

The intrinsic matrix is defined by the projection matrix (e.g. returned by dirt.matrices.perspective_projection) but the relationship is non-trivial; there is a helpful discussion here of how to convert between Hartley-Zisserman and OpenGL camera conventions.