[Bug] relative_transformation returns wrong transformation
See original GitHub issue🐛 Bug
The function relative_transformation
is not returning the correct relative transform given two random input transforms. We might have to take a look at compose_transformations
and inverse_transformation
too.
To Reproduce
Use this colab link: https://colab.research.google.com/drive/104_T6Jfqyq_cy3xTYd_Qo6g6dCYAiL8H?usp=sharing
or run:
Steps to reproduce the behavior:
import torch
import kornia as K
def to_homogeneous(x):
x_out = torch.nn.functional.pad(x, (0, 0, 0, 1), "constant", 0.)
x_out[..., -1, -1] += 1.
return x_out
B = 1 # batch size
rtmat_a = torch.rand(B, 3, 4)
rtmat_b = torch.rand(B, 3, 4)
w_trans_a = to_homogeneous(rtmat_a)
w_trans_b = to_homogeneous(rtmat_b)
print("cam1")
print(w_trans_a)
print("cam2")
print(w_trans_b)
# compute relative motion using kornia with transpose
rtmat_ab = K.relative_transformation(w_trans_a[:, :3], w_trans_b[:, :3])
b_trans_a_kornia = to_homogeneous(rtmat_ab)
# compute relative motion using direct way
b_trans_a_torch = (w_trans_b).inverse() @ w_trans_a
# try to reconstruct cameras
print("rec cam1 kornia")
print(w_trans_b @ b_trans_a_kornia)
print("rec cam1 torch")
print(w_trans_b @ b_trans_a_torch)
print("rec cam2 kornia")
print(w_trans_a @ b_trans_a_kornia.inverse())
print("rec cam2 torch")
print(w_trans_a @ b_trans_a_torch.inverse())
Expected behavior
Environment
Please copy and paste the output from our environment collection script (or fill out the checklist below manually).
You can get the script and run it with:
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
- PyTorch Version (e.g., 1.0):
- OS (e.g., Linux):
- How you installed PyTorch (
conda
,pip
, source): - Build command you used (if compiling from source):
- Python version:
- CUDA/cuDNN version:
- GPU models and configuration:
- Any other relevant information:
Additional context
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Computing relative transformations between objects / How ...
Hi, I'm trying to compute the relative transformation between two actors in Carla Actor A and Actor B. To do this I take...
Read more >relative transformation of coordinates on a flat surface
This code is not working right, for instance, if I insert this test just before the return... print(domain * np.array([[1],[0],[0]]).T) print( ...
Read more >Why are my Relative Transformation Values not 0? | PluginCafé
... an issue where I'm trying to compare an object's relative transformation Vectors ... Position to a Vector with 0 values, however, it...
Read more >math - Trying to find the relative transformation between to two ...
I have overlaid 3D axes onto the image as shown above using XNA so I assume the rotation and translation relative to the...
Read more >Wrong rendering of transformed fonts on Windows with Java 6
2, only with Java 6. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Normal string "3 500" ACTUAL - Expected string with skewed numbers....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
gotcha - I think it’s worth having a utility function to create random orthogonal rotation matrices similar to
scipy.stats.special_ortho_group
https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.special_ortho_group.htmlYeah I think such a function would be nice to have in kornia for testing purposes