-
Notifications
You must be signed in to change notification settings - Fork 1.4k
create extrinsic from eye point #65
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
create extrinsic from eye point #65
Conversation
BlendParams background_color is immutable , type hint as a sequence allows setting new values in constructor.
background_color type hint
return R, t from a camera eye point and look at target.
@davegreenwood, as per the the guidelines in
|
pytorch3d/renderer/cameras.py
Outdated
T = -torch.bmm(R.transpose(1, 2), eye[:, :, None])[:, :, 0] | ||
return R, T | ||
|
||
|
||
def look_at_view_transform( | ||
dist, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating a new function, I would suggest passing in the camera_position
as an input to look_at_view_transform
. Then we can check if either the spherical angles have been provided or the camera position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikhilaravi - that's a good idea - I'll make that change.
tests/test_cameras.py
Outdated
if __name__ == "__main__": | ||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these two lines.
@davegreenwood thanks for making the updates. I added a few more comments to the tests. Please make these changes and then I think we can merge this PR. |
tests/test_cameras.py
Outdated
R, t = look_at_view_transform(dist, elev, azim) | ||
# Using default dist=1.0, elev=0.0, azim=0.0 | ||
R_default, t_default = look_at_view_transform() | ||
# R should be identity, t should be (0, 0, 1) | ||
R_expected = torch.tensor([np.eye(3)], dtype=torch.float32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this test it is sufficient to just check the default matches the expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, I trimmed those unnecessary lines.
@davegreenwood apologies for the delay, this looks good - I will merge the PR! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikhilaravi has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
tests/test_cameras.py
Outdated
dist = math.sqrt(2) | ||
elev = math.pi / 4 | ||
azim = 0.0 | ||
eye = ((0.0, 1.0, -1.0), ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the camera_position_from_spherical_angles
function has been modified so that z is positive, you will need to change eye to eye = ((0.0, 1.0, 1.0), )
in order for the tests to pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @nikhilaravi, I've made that required change. The test does not pass in my branch, but if I did a rebase it would, due to line 947 in cameras.py.
@davegreenwood can you please make the one small change requested? After that I can merge your PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikhilaravi has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@nikhilaravi merged this pull request in 2480723. |
Create extrinsic parameters from eye point.
Create the rotation and translation from an eye point, look-at point and up vector.
see:
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluLookAt.xml
It is arguably easier to initialise a camera position as a point in the world rather than an angle.