You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for this amazing piece of software, first of all!
I am trying to create an error function for use with th.AutoDiffCostFunction to measure the reprojection error from one camera to another, which involves computing a homography matrix in the form of Kj * Rj * Ri.inverse() * Ki.inverse(), where Ki and Ri are the intrinsic matrix and (rotation) pose of a camera respectively.
Ki is parameterized by a single variable: the camera's focal length f, and take the following form (due to some unfortunate coordinate system conventions):
[[-f, 0, 320],
[ 0, f, 240],
[ 0, 0, 1]]
I tried the following code for creating the custom Ki:
But when I tried to run the optimizer, Theseus gave the following error for the assignment K0[:, 0, 0] = -f0[:, 0]:
vmap: inplace arithmetic(self, *extra_args) is not possible because there exists a
Tensor `other` in extra_args that has more elements than `self`. This happened
due to `other` being vmapped over but `self` not being vmapped over in a vmap.
Please try to use out-of-place operators instead of inplace arithmetic.
It seems that I cannot do in-place operations like assignments. May I ask what is the proper/recommended way to create these custom matrices for use with an error function intended for th.AutoDiffCostFunction?
Thanks!
The text was updated successfully, but these errors were encountered:
Unturned3
changed the title
Creating custom intrinsic matrices
Creating custom intrinsic matrices for use in error_fn in AutoDiffCostFunction
May 14, 2024
Hi @Unturned3. Thanks for your interest in Theseus, and my sincere apologies for the long response time.
I'm not 100% sure, but it's possible that this error is the results of using torch.zeros(1, 3, 3) when creating K0. Inside functions being vmaped, usually the right thing to use is torch.new_zeros(), which vmap knows how to batch with the right dimensions. Does the error happen if you do K0 = torch.new_zeros(3, 3)?
You could also try without vmap, by setting autograd_mode="dense" when creating the autodiff cost function, although I suspect this would be too slow for your use case.
❓ Questions and Help
Thanks for this amazing piece of software, first of all!
I am trying to create an error function for use with
th.AutoDiffCostFunction
to measure the reprojection error from one camera to another, which involves computing a homography matrix in the form ofKj * Rj * Ri.inverse() * Ki.inverse()
, whereKi
andRi
are the intrinsic matrix and (rotation) pose of a camera respectively.Ki
is parameterized by a single variable: the camera's focal lengthf
, and take the following form (due to some unfortunate coordinate system conventions):I tried the following code for creating the custom
Ki
:But when I tried to run the optimizer, Theseus gave the following error for the assignment
K0[:, 0, 0] = -f0[:, 0]
:It seems that I cannot do in-place operations like assignments. May I ask what is the proper/recommended way to create these custom matrices for use with an error function intended for
th.AutoDiffCostFunction
?Thanks!
The text was updated successfully, but these errors were encountered: