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
refactor homogeneous transforms module #79
Conversation
@versatran01 this is a first proposal for #74 . |
@edgarriba Thanks for your effort. I have a few suggestions.
should become
then this can be implemented using inverse and compose instead having its own implementation. |
Codecov Report
@@ Coverage Diff @@
## master #79 +/- ##
==========================================
+ Coverage 99.28% 99.28% +<.01%
==========================================
Files 21 21
Lines 976 985 +9
==========================================
+ Hits 969 978 +9
Misses 7 7
Continue to review full report at Codecov.
|
@versatran01 @tiancheng-zhi could you do a quick review before I merge ? this are the basics, we can fix/improve later. |
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.
I don't think it's necessary to convert to homogeneous in transform points. Just do R*p + t. Also that eps in convert from homogeneous should go.
@edgarriba The current implementation contains bug. I tested DepthWarper and found it cannot warp the image correctly. I'm not sure where the bug is currently (maybe in DepthWarper, or other functions). I'm investigating this and will come back later. |
@edgarriba @versatran01 I found the bug: From my point of view, trans_02=compose_transformation(trans_01, trans_12) should equal trans_02=torch.matmul(trans_12, trans_01). Right? But the current code does not perform like this. |
@tiancheng-zhi I don't think that's the bug. From my guess (I haven't looked at the code), before the code could be using extrinsics which is T_c_w, with the refactor of transformation, all transformation are poses which means they are T_w_c, so some care has to be taken when using these new functions. |
I assume the extrinsic matrix in DepthWarper is "world-to-camera" rather than "camera-to-world". Looking at how DepthWarper calls relative_transformation, I guess the main issue is the definition of "trans_AB". Does it mean the matrix transforms a point from the view of A to the view of B? If so, then what @versatran01 mentioned: def relative_transformation(T_0_1, T_0_2) -> T_1_2: is incorrect. The correct one should be: def relative_transformation(T_0_1, T_0_2) -> T_1_2: |
@edgarriba @versatran01
It looks like all the problems come from the unclear definitions. |
@tiancheng-zhi
Read more here |
@versatran01 Thanks very much for your clarification. |
hey, thanks for the review. Just few things:
@tiancheng-zhi the convention I was using is the one that @versatran01 points out. Just to make it clear again: transformation from B to A == T_A_B == trans_ab. We read it from right to left and to make the code more readable I prefer to name the transformation variables Regarding, the issue you mention in @versatran01 @tiancheng-zhi Besides, I would like to hear your opinion about the |
@edgarriba Plase see https://github.com/tiancheng-zhi/reproduce_bug to reproduce the bug. The images, depth map, and poses are taken from ScanNet dataset. About the depthWarper API, I feel that there's no need to input a list of cameras. If the user wanna do so, he/she can make it a batch or use a for-loop by himself/herself. |
I assume this code is taken and adapted from sfmlearner-pytorch? warp(images: [B3HW], idepths: [B1HW], cameras: [B4], poses [B44]) -> warped [B3HW] where camera is [fx,fy,cx,cy]. |
@versatran01 right, I took the code from there. Actually, @ClementPinard helped with that porting and he's willing to contribute with some stuff as well. So, do you think is it worth to reimplement using idepth instead ? Do you have the code anywhere to take a look at it ? I actually like the pattern of having the warpers as modules since that's how we have been using it for a while at arraiy, but it can be discussed. BTW, @versatran01 @tiancheng-zhi I invite you to join the pytorch slack channel |
My code is currently private, but I'm willing to share it once I clean it up a bit. |
@versatran01 sounds good. I guess that the inverse depth feature can be a future improvement. Let me learn about the signature name but I prefer to improve it later as well. If you don't mind could you open tickets to keep tracked about this so that we can organize ourselves and assign tasks ? |
Hi thanks for this contribution. It's worth noting though that this implies at some point the existence of two [B,H,W,3] arrays : R*(u,v,1) and 1/z * (Tx, Tz, Tz) while before we could broadcast the point cloud with the [B,3] translation tensor and have only one. Don't know how it would result memory wise for GPUs. |
Also regarding the eps parameter, I don't advocate for its application like this, but you still have to treat the case where the resulting depth goes to negative values, for example in the case of big rotations. otherwise, the grid_sample might output garbage while it just should output 0. (Note that this does not imply adding an eps values, but rather clamping the depth values to a minimum of eps >0) With the current implementation how can we know from homogeneous coordinates that the points did have a valid depth (or inverse depth) ? |
@ClementPinard thanks for the feedback. I will open a ticket to state this. I guess this feature might be included after the v0.1.2 release. |
refactor homogeneous transforms module
This PR tries to fulfill the feature request in #74
Implements:
relative_transformation
inverse_transformation
compose_transformations
.Moves
transform_points
from moduleconversions
totransformations
.