pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

EPnP: differences between paper and implementation?

Open javrtg opened this issue 3 years ago • 0 comments

❓ Questions about pytorch3d.ops.perspective_n_points.py

Thanks to the team for this really useful library.

My questions are in regards of the code implementation of "Epnp: An accurate o (n) solution to the pnp problem" that can be found at pytorch3d.ops.perspective_n_points.py.

I think I've noticed some differences w.r.t. paper that I'm curious to know the reasons behind them (I may have misunderstood the code, I apologize in advance if that's the case). Concretely:

  1. In all implemented cases within pytorch3d of $N$ (Sec. 3.3 of the paper), the final scaling computation of $\beta$ is done within the Umeyama alignment of the pointclouds:

https://github.com/facebookresearch/pytorch3d/blob/1bfe6bf20a1de877cc623d11c2eeed8c7091ae90/pytorch3d/ops/perspective_n_points.py#L161-L166

I believe this leads to using as error signal the norm of the difference between the coordinates of the point clouds (in cam. and world reference), while in the paper the norm of the relative differences between control points is used (Eq. 11 of the paper).

  1. In the docstring of the function _find_null_space_coords_1:

https://github.com/facebookresearch/pytorch3d/blob/1bfe6bf20a1de877cc623d11c2eeed8c7091ae90/pytorch3d/ops/perspective_n_points.py#L233-L236

is mentioned that B11, B12, B13, B14 are being solved. Why 4 coefficients need to be computed when the case $N=1$ only uses 1 $\beta$ (as noted in the paper in Eqs. 10-11)?

  1. Similarly, for the case $N=3$, the function _find_null_space_coords_3:

https://github.com/facebookresearch/pytorch3d/blob/1bfe6bf20a1de877cc623d11c2eeed8c7091ae90/pytorch3d/ops/perspective_n_points.py#L277-L280

Only computes 5 coefficients while 6 are proposed in the paper (B33 is added).

  1. Finally, is the case $N=4$ implemented in the code?

The differences above make me wonder if they are motivated by e.g. accuracy improvements or gradient-friendly computation.

Thanks in advance!

javrtg avatar Aug 23 '22 00:08 javrtg