Open Unturned3 opened 6 months ago
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!