Skip to content

Commit e0d4c71

Browse files
committed
remove projectiontype
Signed-off-by: Francis Williams <francis@fwilliams.info>
1 parent 50dd01f commit e0d4c71

File tree

3 files changed

+30
-35
lines changed

3 files changed

+30
-35
lines changed

src/fvdb/GaussianSplat3d.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ usesOpenCVDistortion(const CameraModel cameraModel) {
4747
cameraModel == CameraModel::OPENCV_THIN_PRISM_12;
4848
}
4949

50-
fvdb::detail::ops::ProjectionType
51-
projectionTypeForCameraModel(const CameraModel cameraModel) {
52-
return cameraModel == CameraModel::ORTHOGRAPHIC
53-
? fvdb::detail::ops::ProjectionType::ORTHOGRAPHIC
54-
: fvdb::detail::ops::ProjectionType::PERSPECTIVE;
55-
}
56-
5750
ProjectionMethod
5851
resolveProjectionMethod(const CameraModel cameraModel, const ProjectionMethod projectionMethod) {
5952
if (projectionMethod == ProjectionMethod::AUTO) {
@@ -346,9 +339,10 @@ GaussianSplat3d::loadStateDict(const std::unordered_map<std::string, torch::Tens
346339
GaussianSplat3d::ProjectedGaussianSplats
347340
GaussianSplat3d::projectGaussiansImpl(const torch::Tensor &worldToCameraMatrices,
348341
const torch::Tensor &projectionMatrices,
349-
const RenderSettings &settings) {
342+
const RenderSettings &settings,
343+
const CameraModel cameraModel) {
350344
FVDB_FUNC_RANGE();
351-
const bool ortho = settings.projectionType == fvdb::detail::ops::ProjectionType::ORTHOGRAPHIC;
345+
const bool ortho = cameraModel == CameraModel::ORTHOGRAPHIC;
352346
const int C = worldToCameraMatrices.size(0); // number of cameras
353347
const int N = mMeans.size(0); // number of gaussians
354348

@@ -361,10 +355,8 @@ GaussianSplat3d::projectGaussiansImpl(const torch::Tensor &worldToCameraMatrices
361355
TORCH_CHECK(projectionMatrices.is_contiguous(), "projectionMatrices must be contiguous");
362356

363357
ProjectedGaussianSplats ret;
364-
ret.mRenderSettings = settings;
365-
ret.mCameraModel = settings.projectionType == fvdb::detail::ops::ProjectionType::ORTHOGRAPHIC
366-
? CameraModel::ORTHOGRAPHIC
367-
: CameraModel::PINHOLE;
358+
ret.mRenderSettings = settings;
359+
ret.mCameraModel = cameraModel;
368360
ret.mProjectionMethod = ProjectionMethod::ANALYTIC;
369361

370362
// Track gradients for the 2D means in the backward pass if you're optimizing
@@ -475,11 +467,10 @@ GaussianSplat3d::projectGaussiansForCameraImpl(
475467
resolveProjectionMethod(cameraModel, projectionMethod);
476468

477469
RenderSettings settingsForProjection = settings;
478-
settingsForProjection.projectionType = projectionTypeForCameraModel(cameraModel);
479470

480471
if (resolvedProjectionMethod == ProjectionMethod::ANALYTIC) {
481472
auto ret =
482-
projectGaussiansImpl(worldToCameraMatrices, projectionMatrices, settingsForProjection);
473+
projectGaussiansImpl(worldToCameraMatrices, projectionMatrices, settingsForProjection, cameraModel);
483474
ret.mCameraModel = cameraModel;
484475
ret.mProjectionMethod = resolvedProjectionMethod;
485476
return ret;
@@ -658,9 +649,10 @@ GaussianSplat3d::SparseProjectedGaussianSplats
658649
GaussianSplat3d::sparseProjectGaussiansImpl(const JaggedTensor &pixelsToRender,
659650
const torch::Tensor &worldToCameraMatrices,
660651
const torch::Tensor &projectionMatrices,
661-
const RenderSettings &settings) {
652+
const RenderSettings &settings,
653+
const CameraModel cameraModel) {
662654
FVDB_FUNC_RANGE();
663-
const bool ortho = settings.projectionType == fvdb::detail::ops::ProjectionType::ORTHOGRAPHIC;
655+
const bool ortho = cameraModel == CameraModel::ORTHOGRAPHIC;
664656
const int C = worldToCameraMatrices.size(0); // number of cameras
665657
const int N = mMeans.size(0); // number of gaussians
666658

@@ -680,7 +672,9 @@ GaussianSplat3d::sparseProjectGaussiansImpl(const JaggedTensor &pixelsToRender,
680672
" cameras. ");
681673

682674
SparseProjectedGaussianSplats ret;
683-
ret.mRenderSettings = settings;
675+
ret.mRenderSettings = settings;
676+
ret.mCameraModel = cameraModel;
677+
ret.mProjectionMethod = ProjectionMethod::ANALYTIC;
684678

685679
// Deduplicate pixel coordinates. computeSparseInfo requires unique pixels because its
686680
// tile bitmask has one bit per pixel position. We scatter results back after rendering.
@@ -814,11 +808,10 @@ GaussianSplat3d::sparseProjectGaussiansForCameraImpl(
814808
resolveProjectionMethod(cameraModel, projectionMethod);
815809

816810
RenderSettings settingsForProjection = settings;
817-
settingsForProjection.projectionType = projectionTypeForCameraModel(cameraModel);
818811

819812
if (resolvedProjectionMethod == ProjectionMethod::ANALYTIC) {
820813
auto ret = sparseProjectGaussiansImpl(
821-
pixelsToRender, worldToCameraMatrices, projectionMatrices, settingsForProjection);
814+
pixelsToRender, worldToCameraMatrices, projectionMatrices, settingsForProjection, cameraModel);
822815
ret.mCameraModel = cameraModel;
823816
ret.mProjectionMethod = resolvedProjectionMethod;
824817
return ret;

src/fvdb/GaussianSplat3d.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,8 @@ class GaussianSplat3d {
14431443

14441444
ProjectedGaussianSplats projectGaussiansImpl(const torch::Tensor &worldToCameraMatrices,
14451445
const torch::Tensor &projectionMatrices,
1446-
const fvdb::detail::ops::RenderSettings &settings);
1446+
const fvdb::detail::ops::RenderSettings &settings,
1447+
const CameraModel cameraModel);
14471448

14481449
ProjectedGaussianSplats
14491450
projectGaussiansForCameraImpl(const torch::Tensor &worldToCameraMatrices,
@@ -1463,7 +1464,8 @@ class GaussianSplat3d {
14631464
sparseProjectGaussiansImpl(const JaggedTensor &pixelsToRender,
14641465
const torch::Tensor &worldToCameraMatrices,
14651466
const torch::Tensor &projectionMatrices,
1466-
const fvdb::detail::ops::RenderSettings &settings);
1467+
const fvdb::detail::ops::RenderSettings &settings,
1468+
const CameraModel cameraModel);
14671469

14681470
SparseProjectedGaussianSplats
14691471
sparseProjectGaussiansForCameraImpl(const JaggedTensor &pixelsToRender,

src/fvdb/detail/ops/gsplat/GaussianRenderSettings.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
#ifndef FVDB_DETAIL_OPS_GSPLAT_GAUSSIANRENDERSETTINGS_H
55
#define FVDB_DETAIL_OPS_GSPLAT_GAUSSIANRENDERSETTINGS_H
66

7+
#include <fvdb/detail/ops/gsplat/GaussianCameras.cuh>
8+
79
#include <cstdint>
810

911
namespace fvdb {
1012
namespace detail {
1113
namespace ops {
12-
enum ProjectionType { PERSPECTIVE, ORTHOGRAPHIC };
1314

1415
struct RenderWindow2D {
1516
std::uint32_t width = 0;
@@ -42,18 +43,17 @@ struct RenderSettings {
4243

4344
std::uint32_t imageWidth;
4445
std::uint32_t imageHeight;
45-
std::uint32_t imageOriginW = 0;
46-
std::uint32_t imageOriginH = 0;
47-
ProjectionType projectionType = ProjectionType::PERSPECTIVE;
48-
RenderMode renderMode = RenderMode::RGB;
49-
float nearPlane = 0.01;
50-
float farPlane = 1e10;
51-
std::uint32_t tileSize = 16;
52-
float radiusClip = 0.0;
53-
float eps2d = 0.3;
54-
bool antialias = false;
55-
int shDegreeToUse = -1;
56-
int numDepthSamples = -1;
46+
std::uint32_t imageOriginW = 0;
47+
std::uint32_t imageOriginH = 0;
48+
RenderMode renderMode = RenderMode::RGB;
49+
float nearPlane = 0.01;
50+
float farPlane = 1e10;
51+
std::uint32_t tileSize = 16;
52+
float radiusClip = 0.0;
53+
float eps2d = 0.3;
54+
bool antialias = false;
55+
int shDegreeToUse = -1;
56+
int numDepthSamples = -1;
5757
};
5858
} // namespace ops
5959
} // namespace detail

0 commit comments

Comments
 (0)