@@ -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-
5750ProjectionMethod
5851resolveProjectionMethod (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
346339GaussianSplat3d::ProjectedGaussianSplats
347340GaussianSplat3d::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
658649GaussianSplat3d::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;
0 commit comments