1. 22 Sep, 2022 1 commit
    • Jeremy Reizenstein's avatar
      Fix camera clone() with torch.save · efea540b
      Jeremy Reizenstein authored
      Summary:
      User reported that cloned cameras fail to save. The error with latest PyTorch is
      
      ```
      pickle.PicklingError: Can't pickle ~T_destination: attribute lookup T_destination on torch.nn.modules.module failed
      ```
      
      This fixes it.
      
      Reviewed By: btgraham
      
      Differential Revision: D39692258
      
      fbshipit-source-id: 75bbf3b8dfa0023dc28bf7d4cc253ca96e46a64d
      efea540b
  2. 31 Aug, 2022 1 commit
    • Jiali Duan's avatar
      Amend D38407094: Fisheye Camera for PyTorch3D · b0515e14
      Jiali Duan authored
      Summary:
      Amend FisheyeCamera by adding tests for all
      combination of params and for different batch_sizes.
      
      Reviewed By: kjchalup
      
      Differential Revision: D39176747
      
      fbshipit-source-id: 830d30da24beeb2f0df52db0b17a4303ed53b59c
      b0515e14
  3. 28 Aug, 2022 2 commits
    • Jiali Duan's avatar
      Benchmark Cameras · 03562d87
      Jiali Duan authored
      Summary: Address comments to add benchmarkings for cameras and the new fisheye cameras. The dependency functions in test_cameras have been updated in Diff 1. The following two snapshots show benchmarking results.
      
      Reviewed By: kjchalup
      
      Differential Revision: D38991914
      
      fbshipit-source-id: 51fe9bb7237543e4ee112c9f5068a4cf12a9d482
      03562d87
    • Jiali Duan's avatar
      Fisheye Camera for PyTorch3D · 2283c292
      Jiali Duan authored
      Summary:
      1. A Fisheye camera model that generalizes pinhole camera by considering distortions (i.e. radial, tangential and thin-prism distortions).
      
      2. Added tests against perspective cameras when distortions are off and Aria data points when distortions are on.
      
      3. Address comments to test unhandled shapes between points and transforms. Added tests for __FIELDS, shape broadcasts, cuda etc.
      
      4. Address earlier comments for code efficiency (e.g., adopted torch.norm; torch.solve for matrix inverse; removed inplace operations; unnecessary clone; expand in place of repeat etc).
      
      Reviewed By: jcjohnson
      
      Differential Revision: D38407094
      
      fbshipit-source-id: a3ab48c85c496ac87af692d5d461bb3fc2a2db13
      2283c292
  4. 16 Aug, 2022 1 commit
    • Roman Shapovalov's avatar
      Boolean indexing of cameras · b7c826b7
      Roman Shapovalov authored
      Summary: Reasonable to expect bool indexing.
      
      Reviewed By: bottler, kjchalup
      
      Differential Revision: D38741446
      
      fbshipit-source-id: 22b607bf13110043c5624196c66ca1484fdbce6c
      b7c826b7
  5. 25 May, 2022 1 commit
    • Jeremy Reizenstein's avatar
      move targets · 34f648ed
      Jeremy Reizenstein authored
      Summary: Move testing targets from pytorch3d/tests/TARGETS to pytorch3d/TARGETS.
      
      Reviewed By: shapovalov
      
      Differential Revision: D36186940
      
      fbshipit-source-id: a4c52c4d99351f885e2b0bf870532d530324039b
      34f648ed
  6. 13 Apr, 2022 1 commit
    • Tim Hatch's avatar
      apply import merging for fbcode/vision/fair (2 of 2) · 34bbb3ad
      Tim Hatch authored
      Summary:
      Applies new import merging and sorting from µsort v1.0.
      
      When merging imports, µsort will make a best-effort to move associated
      comments to match merged elements, but there are known limitations due to
      the diynamic nature of Python and developer tooling. These changes should
      not produce any dangerous runtime changes, but may require touch-ups to
      satisfy linters and other tooling.
      
      Note that µsort uses case-insensitive, lexicographical sorting, which
      results in a different ordering compared to isort. This provides a more
      consistent sorting order, matching the case-insensitive order used when
      sorting import statements by module name, and ensures that "frog", "FROG",
      and "Frog" always sort next to each other.
      
      For details on µsort's sorting and merging semantics, see the user guide:
      https://usort.readthedocs.io/en/stable/guide.html#sorting
      
      Reviewed By: bottler
      
      Differential Revision: D35553814
      
      fbshipit-source-id: be49bdb6a4c25264ff8d4db3a601f18736d17be1
      34bbb3ad
  7. 28 Feb, 2022 1 commit
  8. 21 Jan, 2022 1 commit
    • Jeremy Reizenstein's avatar
      Join cameras as batch · 39bb2ce0
      Jeremy Reizenstein authored
      Summary:
      Function to join a list of cameras objects into a single batched object.
      
      FB: In the next diff I will remove the `concatenate_cameras` function in implicitron and update the callsites.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D33198209
      
      fbshipit-source-id: 0c9f5f5df498a0def9dba756c984e6a946618158
      39bb2ce0
  9. 04 Jan, 2022 1 commit
    • Jeremy Reizenstein's avatar
      More company name & License · 741777b5
      Jeremy Reizenstein authored
      Summary: Manual adjustments for license changes.
      
      Reviewed By: patricklabatut
      
      Differential Revision: D33405657
      
      fbshipit-source-id: 8a21735726f3aece9f9164da9e3b272b27db8032
      741777b5
  10. 21 Dec, 2021 2 commits
    • Nikhila Ravi's avatar
      Enable __getitem__ for Cameras to return an instance of Cameras · 28ccdb73
      Nikhila Ravi authored
      Summary:
      Added a custom `__getitem__` method to `CamerasBase` which returns an instance of the appropriate camera instead of the `TensorAccessor` class.
      
      Long term we should deprecate the `TensorAccessor` and the `__getitem__` method on `TensorProperties`
      
      FB: In the next diff I will update the uses of `select_cameras` in implicitron.
      
      Reviewed By: bottler
      
      Differential Revision: D33185885
      
      fbshipit-source-id: c31995d0eb126981e91ba61a6151d5404b263f67
      28ccdb73
    • Jeremy Reizenstein's avatar
      screen space docstrings fix · eb2bbf84
      Jeremy Reizenstein authored
      Summary: Fix some comments to match the recent change to transform_points_screen.
      
      Reviewed By: patricklabatut
      
      Differential Revision: D33243697
      
      fbshipit-source-id: dc8d182667a9413bca2c2e3657f97b2f7a47c795
      eb2bbf84
  11. 07 Dec, 2021 1 commit
    • Jeremy Reizenstein's avatar
      screen cameras lose -1 · bf3bc6f8
      Jeremy Reizenstein authored
      Summary:
      All the renderers in PyTorch3D (pointclouds including pulsar, meshes, raysampling) use align_corners=False style. NDC space goes between the edges of the outer pixels. For a non square image with W>H, the vertical NDC space goes from -1 to 1 and the horizontal from -W/H to W/H.
      
      However it was recently pointed out that functionality which deals with screen space inside the camera classes is inconsistent with this. It unintentionally uses align_corners=True. This fixes that.
      
      This would change behaviour of the following:
      - If you create a camera in screen coordinates, i.e. setting in_ndc=False, then anything you do with the camera which touches NDC space may be affected, including trying to use renderers. The transform_points_screen function will not be affected...
      - If you call the function “transform_points_screen” on a camera defined in NDC space results will be different. I have illustrated in the diff how to get the old results from the new results but this probably isn’t the right long-term solution..
      
      Reviewed By: gkioxari
      
      Differential Revision: D32536305
      
      fbshipit-source-id: 377325a9137282971dcb7ca11a6cba3fc700c9ce
      bf3bc6f8
  12. 02 Aug, 2021 1 commit
    • Georgia Gkioxari's avatar
      NDC/screen cameras API fix, compatibility with renderer · 0c32f094
      Georgia Gkioxari authored
      Summary:
      API fix for NDC/screen cameras and compatibility with PyTorch3D renderers.
      
      With this new fix:
      * Users can define cameras and `transform_points` under any coordinate system conventions. The transformation applies the camera K and RT to the input points, not regarding for PyTorch3D conventions. So this makes cameras completely independent from PyTorch3D renderer.
      
      * Cameras can be defined either in NDC space or screen space. For existing ones, FoV cameras are in NDC space. Perspective/Orthographic can be defined in NDC or screen space.
      
      * The interface with PyTorch3D renderers happens through `transform_points_ndc` which transforms points to the NDC space and assumes that input points are provided according to PyTorch3D conventions.
      
      * Similarly, `transform_points_screen` transforms points to screen space and again assumes that input points are under PyTorch3D conventions.
      
      * For Orthographic/Perspective cameras, if they are defined in screen space, the `get_ndc_camera_transform` allows points to be converted to NDC for use for the renderers.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D26932657
      
      fbshipit-source-id: 1a964e3e7caa54d10c792cf39c4d527ba2fb2e79
      0c32f094
  13. 28 Jun, 2021 1 commit
    • Patrick Labatut's avatar
      Deprecate so3_exponential_map · 5284de6e
      Patrick Labatut authored
      Summary: Deprecate the `so3_exponential_map()` function in favor of its alias `so3_exp_map()`: this aligns with the naming of `so3_log_map()` and the recently introduced `se3_exp_map()` / `se3_log_map()` pair.
      
      Reviewed By: bottler
      
      Differential Revision: D29329966
      
      fbshipit-source-id: b6f60b9e86b2995f70b1fbeb16f9feea05c55de9
      5284de6e
  14. 22 Jun, 2021 1 commit
    • Patrick Labatut's avatar
      License lint codebase · af93f348
      Patrick Labatut authored
      Summary: License lint codebase
      
      Reviewed By: theschnitz
      
      Differential Revision: D29001799
      
      fbshipit-source-id: 5c59869911785b0181b1663bbf430bc8b7fb2909
      af93f348
  15. 08 Feb, 2021 1 commit
  16. 24 Dec, 2020 1 commit
    • Jeremy Reizenstein's avatar
      lint · b9562157
      Jeremy Reizenstein authored
      Summary: Allowing usort, isort and black to coexist without fighting means we can't have imports commented as deprecated from the same module as other imports.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D25372970
      
      fbshipit-source-id: 637f5a0025c0df9fbec47cba73ce5387f4f8b467
      b9562157
  17. 11 Nov, 2020 1 commit
  18. 30 Oct, 2020 1 commit
    • Dave Schnizlein's avatar
      Update cameras to accept projection matrix as input · 36fb257e
      Dave Schnizlein authored
      Summary: To initialize the Cameras class currently we require the principal point, focal length and other parameters to be specified from which we calculate the intrinsic matrix. In some cases the matrix might be directly available e.g. from a dataset and the associated metadata for an image.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D24489509
      
      fbshipit-source-id: 1b411f19c5f6c8074bcfbf613f3339d5e242c119
      36fb257e
  19. 10 Sep, 2020 1 commit
    • Amitav Baruah's avatar
      Fix look_at corner case · eb517dd7
      Amitav Baruah authored
      Summary: When the camera is vertically oriented, calculating the look_at x-axis (also known as the "right" vector) does not succeed, resulting in the x-axis being placed at the origin. Adds a check to correctly calculate the x-axis if this case occurs.
      
      Reviewed By: nikhilaravi, sbranson
      
      Differential Revision: D23511859
      
      fbshipit-source-id: ee5145cdbecdbe2f7c7d288588bd0899480cb327
      eb517dd7
  20. 03 Sep, 2020 1 commit
    • David Novotny's avatar
      Camera alignment · 316b7778
      David Novotny authored
      Summary:
      adds `corresponding_cameras_alignment` function that estimates a similarity transformation between two sets of cameras.
      
      The function is essential for computing camera errors in SfM pipelines.
      
      ```
      Benchmark                                                   Avg Time(μs)      Peak Time(μs) Iterations
      --------------------------------------------------------------------------------
      CORRESPONDING_CAMERAS_ALIGNMENT_10_centers_False                32219           36211             16
      CORRESPONDING_CAMERAS_ALIGNMENT_10_centers_True                 32429           36063             16
      CORRESPONDING_CAMERAS_ALIGNMENT_10_extrinsics_False              5548            8782             91
      CORRESPONDING_CAMERAS_ALIGNMENT_10_extrinsics_True               6153            9752             82
      CORRESPONDING_CAMERAS_ALIGNMENT_100_centers_False               33344           40398             16
      CORRESPONDING_CAMERAS_ALIGNMENT_100_centers_True                34528           37095             15
      CORRESPONDING_CAMERAS_ALIGNMENT_100_extrinsics_False             5576            7187             90
      CORRESPONDING_CAMERAS_ALIGNMENT_100_extrinsics_True              6256            9166             80
      CORRESPONDING_CAMERAS_ALIGNMENT_1000_centers_False              32020           37247             16
      CORRESPONDING_CAMERAS_ALIGNMENT_1000_centers_True               32776           37644             16
      CORRESPONDING_CAMERAS_ALIGNMENT_1000_extrinsics_False            5336            8795             94
      CORRESPONDING_CAMERAS_ALIGNMENT_1000_extrinsics_True             6266            9929             80
      --------------------------------------------------------------------------------
      ```
      
      Reviewed By: shapovalov
      
      Differential Revision: D22946415
      
      fbshipit-source-id: 8caae7ee365b304d8aa1f8133cf0dd92c35bc0dd
      316b7778
  21. 22 Aug, 2020 1 commit
    • Eduardo Henrique Arnold's avatar
      Fix look_at_view_transform when object location is not (0,0,0) (#230) · d0cec028
      Eduardo Henrique Arnold authored
      Summary:
      The look_at_view_transform did not give the correct results when the object location `at` was not (0,0,0).
      
      The problem was on computing the cameras' location in world's coordinate `C`. It only took into account the camera position from spherical angles, but ignored the object location in the world's coordinate system. I simply modified the C tensor to take into account the object's location which is not necessarily in the origin.
      
      I ran unit tests and all but 4 failed with the same error message: `RuntimeError: CUDA error: invalid device ordinal`. However the same happens before this patch, so I believe these errors are unrelated.
      
      Pull Request resolved: https://github.com/facebookresearch/pytorch3d/pull/230
      
      Reviewed By: gkioxari
      
      Differential Revision: D23278126
      
      Pulled By: nikhilaravi
      
      fbshipit-source-id: c06e891bc46de8222325ee7b37aa43cde44648e8
      d0cec028
  22. 21 Aug, 2020 1 commit
    • Georgia Gkioxari's avatar
      camera refactoring · 57a22e73
      Georgia Gkioxari authored
      Summary:
      Refactor cameras
      * CamerasBase was enhanced with `transform_points_screen` that transforms projected points from NDC to screen space
      * OpenGLPerspective, OpenGLOrthographic -> FoVPerspective, FoVOrthographic
      * SfMPerspective, SfMOrthographic -> Perspective, Orthographic
      * PerspectiveCamera can optionally be constructred with screen space parameters
      * Note on Cameras and coordinate systems was added
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D23168525
      
      fbshipit-source-id: dd138e2b2cc7e0e0d9f34c45b8251c01266a2063
      57a22e73
  23. 04 May, 2020 1 commit
    • Nikhila Ravi's avatar
      lint fixes · 0eca74fa
      Nikhila Ravi authored
      Summary:
      Ran the linter.
      TODO: need to update the linter as per D21353065.
      
      Reviewed By: bottler
      
      Differential Revision: D21362270
      
      fbshipit-source-id: ad0e781de0a29f565ad25c43bc94a19b1828c020
      0eca74fa
  24. 17 Apr, 2020 1 commit
    • David Novotny's avatar
      Camera inheritance + unprojections · 7788a380
      David Novotny authored
      Summary: Made a CameraBase class. Added `unproject_points` method for each camera class.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D20373602
      
      fbshipit-source-id: 7e3da5ae420091b5fcab400a9884ef29ad7a7343
      7788a380
  25. 15 Apr, 2020 1 commit
  26. 29 Mar, 2020 1 commit
    • Patrick Labatut's avatar
      Address black + isort fbsource linter warnings · d57daa6f
      Patrick Labatut authored
      Summary: Address black + isort fbsource linter warnings from D20558374 (previous diff)
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D20558373
      
      fbshipit-source-id: d3607de4a01fb24c0d5269634563a7914bddf1c8
      d57daa6f
  27. 23 Mar, 2020 1 commit
    • Jeremy Reizenstein's avatar
      use assertClose · 595aca27
      Jeremy Reizenstein authored
      Summary: use assertClose in some tests, which enforces shape equality. Fixes some small problems, including graph_conv on an empty graph.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D20556912
      
      fbshipit-source-id: 60a61eafe3c03ce0f6c9c1a842685708fb10ac5b
      595aca27
  28. 22 Mar, 2020 1 commit
    • Georgia Gkioxari's avatar
      run lint · 03f441e7
      Georgia Gkioxari authored
      Summary: Run `/dev/linter.sh` to fix linting
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D20584037
      
      fbshipit-source-id: 69e45b33d22e3d54b6d37c3c35580bb3e9dc50a5
      03f441e7
  29. 18 Mar, 2020 1 commit
  30. 12 Mar, 2020 1 commit
    • Patrick Labatut's avatar
      Remove shebang line when not strictly required · 3c71ab64
      Patrick Labatut authored
      Summary: The shebang line `#!<path to interpreter>` is only required for Python scripts, so remove it on source files for class or function definitions. Additionally explicitly mark as executable the actual Python scripts in the codebase.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D20095778
      
      fbshipit-source-id: d312599fba485e978a243292f88a180d71e1b55a
      3c71ab64
  31. 06 Mar, 2020 1 commit
    • Nikhila Ravi's avatar
      Fix coordinate system conventions in renderer · 15c72be4
      Nikhila Ravi authored
      Summary:
      ## Updates
      
      - Defined the world and camera coordinates according to this figure. The world coordinates are defined as having +Y up, +X left and +Z in.
      
      {F230888499}
      
      - Removed all flipping from blending functions.
      - Updated the rasterizer to return images with +Y up and +X left.
      - Updated all the mesh rasterizer tests
          - The expected values are now defined in terms of the default +Y up, +X left
          - Added tests where the triangles in the meshes are non symmetrical so that it is clear which direction +X and +Y are
      
      ## Questions:
      - Should we have **scene settings** instead of raster settings?
          - To be more correct we should be [z clipping in the rasterizer based on the far/near clipping planes](https://github.com/ShichenLiu/SoftRas/blob/master/soft_renderer/cuda/soft_rasterize_cuda_kernel.cu#L400) - these values are also required in the blending functions so should we make these scene level parameters and have a scene settings tuple which is available to the rasterizer and shader?
      
      Reviewed By: gkioxari
      
      Differential Revision: D20208604
      
      fbshipit-source-id: 55787301b1bffa0afa9618f0a0886cc681da51f3
      15c72be4
  32. 23 Jan, 2020 1 commit