-
Notifications
You must be signed in to change notification settings - Fork 17
Gaussian Projection with the Unscented Transform #420
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
Merged
Merged
Changes from 26 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
aef98a6
Add GaussianProjectionUT for 3D to 2D Gaussian projection
fwilliams 1938d8a
Add rotation matrix to quaternion conversion function
fwilliams f96a05d
Add pose interpolation functionality and related tests
fwilliams 39a1cac
Remove unused Tensor.h include from GaussianProjectionUTTest.cpp
fwilliams a9baa6f
comments
fwilliams 37a879d
why not more functions?
fwilliams 3930fd4
checkpoint
fwilliams 7a31ae3
checkpoint
fwilliams 35ee440
enum
fwilliams 6c00b10
rm enum
fwilliams 1e262ad
clang format
fwilliams c5d4e00
clang format
fwilliams 64904bf
clang format
fwilliams e78a670
format
fwilliams b022698
fix bug
fwilliams 9936c0d
fix clang format
fwilliams 61d1352
logscales
fwilliams b2cad81
address copilot comments
fwilliams 4813306
clang format
fwilliams b40d20d
Update src/fvdb/detail/ops/gsplat/GaussianProjectionUT.h
fwilliams d6e8739
Update src/fvdb/detail/ops/gsplat/GaussianProjectionUT.h
fwilliams b1f981b
Update src/fvdb/detail/ops/gsplat/GaussianUtils.cuh
fwilliams c9bd1a2
rm
fwilliams ff11d66
fix copilot
fwilliams ec68cc5
clang format
fwilliams 97828b1
rolling shutter issue
fwilliams c8a3bae
clang format
fwilliams 1a236c0
remove (void)
fwilliams b5c981e
tests use accessors
fwilliams e77db1f
Update src/CMakeLists.txt
fwilliams c9a3b2b
fix segfault
fwilliams 7eada65
Merge branch 'fw/ut2' of github.com:fwilliams/fvdb-core into fw/ut2
fwilliams 9e8e1bf
fixed
fwilliams 2fcf679
host side check for num sigma points
fwilliams c09877f
robustness
fwilliams 7215540
no sync
fwilliams c79b88f
docstring
fwilliams ff5c7aa
move a lot of code into a camera model
fwilliams e44bd79
opencv camera model
fwilliams f7e5498
clean up pose stuff
fwilliams f3eb963
refactor
fwilliams d49655b
refactor
fwilliams 6856d68
rename
fwilliams bb44edc
cleanup
fwilliams 84050f6
more refactoring
fwilliams f8359b7
revert accessor helper changes
fwilliams ba96359
camera model
fwilliams 7e85a0e
orthographic
fwilliams 5c15eee
comments
fwilliams c325096
docstrings
fwilliams f8f65ce
accessorhelpers
fwilliams 30d5a5c
fix UB
fwilliams 352ee00
format
fwilliams 44d3864
cache R
fwilliams b2a3465
fix copilot comments
fwilliams 0862255
std exp
fwilliams 6a8afb0
fix
fwilliams 2678db1
Enhance documentation for rotationMatrixToQuaternion function with de…
fwilliams ec6fb21
clang format
fwilliams d211647
remove raw pointers where applicable
fwilliams 1715910
format
fwilliams fb51967
fix copilot issue
fwilliams c68e34d
clang format
fwilliams 5bdcbd3
rerun CI
fwilliams 2b2acae
rerun CI?
fwilliams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| // Copyright Contributors to the OpenVDB Project | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| #ifndef FVDB_DETAIL_OPS_GSPLAT_GAUSSIANPROJECTIONUT_H | ||
| #define FVDB_DETAIL_OPS_GSPLAT_GAUSSIANPROJECTIONUT_H | ||
|
|
||
| #include <ATen/core/TensorBody.h> | ||
| #include <torch/types.h> | ||
|
|
||
| #include <tuple> | ||
|
|
||
| namespace fvdb { | ||
| namespace detail { | ||
| namespace ops { | ||
|
|
||
| enum class RollingShutterType { NONE = 0, VERTICAL = 1, HORIZONTAL = 2 }; | ||
|
|
||
| // Distortion model for camera projection in the UT kernel. | ||
| // | ||
| // Distortion coefficients are supplied as a single tensor `distortionCoeffs` and interpreted | ||
| // according to this enum. | ||
| enum class DistortionModel : int32_t { | ||
| NONE = 0, | ||
|
|
||
| // OpenCV variants (all use the same [C,12] coefficient layout): | ||
| // [k1,k2,k3,k4,k5,k6,p1,p2,s1,s2,s3,s4] | ||
| // | ||
| // The enum exists mostly for clarity + runtime validation of coefficient usage. | ||
| OPENCV_RADTAN_5 = 1, // polynomial radial (k1,k2,k3) + tangential (p1,p2) | ||
| OPENCV_RATIONAL_8 = 2, // rational radial (k1..k6) + tangential (p1,p2) | ||
| OPENCV_RADTAN_THIN_PRISM_9 = 3, // polynomial radial + tangential + thin-prism (s1..s4) | ||
| OPENCV_THIN_PRISM_12 = 4, // rational radial + tangential + thin-prism (s1..s4) | ||
| }; | ||
|
|
||
| struct UTParams { | ||
| float alpha = 0.1f; // Blending parameter for UT | ||
| float beta = 2.0f; // Scaling parameter for UT | ||
| float kappa = 0.0f; // Additional scaling parameter for UT | ||
| // For a 3D Unscented Transform with the standard \(2D+1\) formulation, D=3 => 7 points. | ||
| // This implementation currently supports only this 3D case. | ||
| int numSigmaPoints = 7; | ||
| float inImageMargin = 0.1f; // Margin for in-image check | ||
| bool requireAllSigmaPointsInImage = | ||
| true; // Require all sigma points to be in image to consider a Gaussian valid | ||
| }; | ||
|
|
||
| /// @brief Project 3D Gaussians to 2D screen space pixel coordinates for rendering | ||
| /// | ||
| /// This function transforms 3D Gaussians to 2D screen space by applying camera projections. | ||
| /// It computes the 2D means, depths, 2D covariance matrices (conics), and potentially compensation | ||
| /// factors to accurately represent the 3D Gaussians in 2D for later rasterization. | ||
| /// | ||
| /// The origin of the 2D pixel coordinates is the top-left corner of the image, with positive x-axis | ||
| /// pointing to the right and positive y-axis pointing downwards. | ||
| /// | ||
| /// @attention The output radii of 3D Gaussians that are discarded (due to clipping or projection | ||
| /// too small) are set to zero, but the other output values of discarded Gaussians are uninitialized | ||
| /// (undefined). | ||
| /// | ||
| /// @tparam DeviceType Device type template parameter (torch::kCUDA or torch::kCPU) | ||
| /// | ||
| /// @param[in] means 3D positions of Gaussians [N, 3] where N is number of Gaussians | ||
| /// @param[in] quats Quaternion rotations of Gaussians [N, 4] in format (w, x, y, z) | ||
| /// @param[in] logScales Log-scale factors of Gaussians [N, 3] (natural log), representing extent in | ||
| /// each dimension | ||
| /// @param[in] worldToCamMatricesStart Camera view matrices at the start of the frame. Shape [C, 4, | ||
| /// 4] where C is number of cameras | ||
| /// @param[in] worldToCamMatricesEnd Camera view matrices at the end of the frame. Shape [C, 4, 4] | ||
| /// where C is number of cameras | ||
| /// @param[in] projectionMatrices Camera intrinsic matrices [C, 3, 3] | ||
| /// @param[in] rollingShutterType Type of rolling shutter effect to apply | ||
| /// @param[in] utParams Unscented Transform parameters | ||
| /// @param[in] distortionModel Distortion model used to interpret `distortionCoeffs`. | ||
| /// @param[in] distortionCoeffs Distortion coefficients for each camera. | ||
| /// - DistortionModel::NONE: ignored (use [C,0] or [C,K] tensor). | ||
| /// - DistortionModel::OPENCV_*: expects [C,12] coefficients in the following order: | ||
| /// [k1,k2,k3,k4,k5,k6,p1,p2,s1,s2,s3,s4] | ||
| /// where k1..k6 are radial (rational), p1,p2 are tangential, and s1..s4 are thin-prism. | ||
| /// @param[in] imageWidth Width of the output image in pixels | ||
| /// @param[in] imageHeight Height of the output image in pixels | ||
| /// @param[in] eps2d 2D projection epsilon for numerical stability | ||
| /// @param[in] nearPlane Near clipping plane distance | ||
| /// @param[in] farPlane Far clipping plane distance | ||
| /// @param[in] minRadius2d Minimum 2D radius threshold; Gaussians with projected radius <= this | ||
| /// value are clipped/discarded | ||
| /// @param[in] calcCompensations Whether to calculate view-dependent compensation factors | ||
| /// @param[in] ortho Whether to use orthographic projection instead of perspective | ||
| /// | ||
| /// @return std::tuple containing: | ||
| /// - Radii of 2D Gaussians [C, N] | ||
| /// - 2D projected Gaussian centers [C, N, 2] | ||
| /// - Depths of Gaussians [C, N] | ||
| /// - Covariance matrices in conic form [C, N, 3] representing (a, b, c) in ax² + 2bxy + cy² | ||
| /// - Compensation factors [C, N] (if calc_compensations is true, otherwise empty tensor) | ||
| template <torch::DeviceType> | ||
| std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor> | ||
| dispatchGaussianProjectionForwardUT( | ||
| const torch::Tensor &means, // [N, 3] | ||
| const torch::Tensor &quats, // [N, 4] | ||
| const torch::Tensor &logScales, // [N, 3] | ||
| const torch::Tensor &worldToCamMatricesStart, // [C, 4, 4] | ||
| const torch::Tensor &worldToCamMatricesEnd, // [C, 4, 4] | ||
| const torch::Tensor &projectionMatrices, // [C, 3, 3] | ||
| const RollingShutterType rollingShutterType, | ||
| const UTParams &utParams, | ||
| const DistortionModel distortionModel, | ||
| const torch::Tensor &distortionCoeffs, // [C, 12] for OPENCV_*, or [C, 0] for NONE | ||
| const int64_t imageWidth, | ||
| const int64_t imageHeight, | ||
| const float eps2d, | ||
| const float nearPlane, | ||
| const float farPlane, | ||
| const float minRadius2d, | ||
| const bool calcCompensations, | ||
| const bool ortho); | ||
|
|
||
| } // namespace ops | ||
| } // namespace detail | ||
| } // namespace fvdb | ||
|
|
||
| #endif // FVDB_DETAIL_OPS_GSPLAT_GAUSSIANPROJECTIONUT_H |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.