Skip to content

Commit

Permalink
updated to median depth
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathonLuiten committed Sep 19, 2023
1 parent 7a4c941 commit cb65e4b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ However, it has been edited by Jonathon Luiten to also render 'depth' as well as

This is needed for Jonathon's Dynamic 3D Gaussians work which can be found here: http://dynamic3dgaussians.github.io

By default, the depth is calculated as 'mean depth', but there is commented out code which also calculates 'median depth' if preferred.
By default, the depth is calculated as 'median depth', where the depth is the depth of the Gaussian center which causes the accumulated rays transmittance to drop below 0.5.
If a ray doesn't reach this threshold it is given a default depth of 15. This median depth avoids the depth floaters around depth boundaries that 'mean depth' would give.
If 'mean depth' is preffered, there is commented out code which also calculates 'mean depth'.
See lines 307-308 and 363-372 of cuda_rasterizer/forward.cu.

Note that the backward pass for the depth has not been implemented, so it won't work for training with depth ground-truth.

Note that the code in this repo follows the (non commercial) license of Inria as laid out in LICENSE.md

If you're using this as part of the Dynamic Gaussian code, just follow the installation instruction for that codebase.
If you're using this as part of the Dynamic 3D Gaussians code, just follow the installation instruction for that codebase.

To install this stand-alone I have been doing the following (although I don't think this is necessarily the best way):
```
Expand Down
22 changes: 11 additions & 11 deletions cuda_rasterizer/forward.cu
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ renderCUDA(
uint32_t contributor = 0;
uint32_t last_contributor = 0;
float C[CHANNELS] = { 0 };
float D = 0.0f; // Mean Depth
// float D = 1000.0f; // Median Depth. TODO: This is a hack setting max_depth to 1000
// float D = 0.0f; // Mean Depth
float D = 15.0f; // Median Depth. TODO: This is a hack setting max_depth to 15

// Iterate over batches until all done or range is complete
for (int i = 0; i < rounds; i++, toDo -= BLOCK_SIZE)
Expand Down Expand Up @@ -361,15 +361,15 @@ renderCUDA(
C[ch] += features[collected_id[j] * CHANNELS + ch] * alpha * T;

// Mean depth:
float dep = collected_depth[j];
D += dep * alpha * T;

// // Median depth:
// if (T > 0.5f && test_T < 0.5)
// {
// float dep = collected_depth[j];
// D = dep;
// }
// float dep = collected_depth[j];
// D += dep * alpha * T;

// Median depth:
if (T > 0.5f && test_T < 0.5)
{
float dep = collected_depth[j];
D = dep;
}


T = test_T;
Expand Down

0 comments on commit cb65e4b

Please sign in to comment.