question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mistakes in the docstrings of cam2pixel and pixel2cam

See original GitHub issue

Hey everyone. I was going through the codebase and I noticed a few mistakes in the docstrings of the functions cam2pixel and pixel2cam which are available in kornia/geometry/camera/pinhole.py.

The function cam2pixel mentions the following about the return value in its docstring: https://github.com/kornia/kornia/blob/9d594687db704845c3668d76b6e481666277e375/kornia/geometry/camera/pinhole.py#L582-L584

But on reading the code of the function cam2pixel, it looks like the output is in pixel coordinates. The output can exceed the range [-1, 1]. The function cam2pixel is used in kornia/geometry/depth.py. Here, we can see that the range normalization is applied to pixel_coords_src, which is the output of cam2pixel.

https://github.com/kornia/kornia/blob/9d594687db704845c3668d76b6e481666277e375/kornia/geometry/depth.py#L304-L310

Also, the function pixel2cam mentions the following about the return value in its docstring: https://github.com/kornia/kornia/blob/9d594687db704845c3668d76b6e481666277e375/kornia/geometry/camera/pinhole.py#L557-L559

But on reading the code of the function pixel2cam, it seems like the output is in XYZ camera coordinates. The docstring mentioned that the output would be a tensor of (u, v, 1) cam coordinates which does not make sense. The output seems to be (x, y, z) cam coordinates.

In summary, I think the return value descriptions in the docstrings of cam2pixel and pixel2cam are incorrect. I have not tried running the code though, I’m just mentioning my observations based on my reading. Do let me know your thoughts! I would be happy to send in a PR to fix this if the issue is verified.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
thatbrguycommented, Aug 24, 2021

Closing since issue was handled in #1211.

1reaction
thatbrguycommented, Aug 3, 2021

Sure, will do!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mistakes in the docstrings of cam2pixel and pixel2cam issue ...
Hey everyone. I was going through the codebase and I noticed a few mistakes in the docstrings of the functions cam2pixel and pixel2cam...
Read more >
Python Docstrings Tutorial : Examples & Format for Pydoc ...
See Python Docstrings. Learn about the different types of docstrings & various docstring formats like Sphinx, Numpy, and Pydoc with examples now.
Read more >
pandas docstring guide — pandas 1.5.2 documentation
A Python docstring is a string used to document a Python module, class, function or method, so programmers can ... With several mistakes...
Read more >
kornia - bytemeta
Mistakes in the docstrings of cam2pixel and pixel2cam · [docs] Missing range of Lab image in rgb_to_lab conversion.
Read more >
Python Docstrings (With Examples) - Programiz
Python docstrings are the string literals that appear right after the definition of a function, method, class, or module. Let's take an example....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found