Skip to content
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

Bug in buildHashAllocAndVisibleTypePP: offset missing. #145

Open
Algomorph opened this issue Nov 26, 2019 · 2 comments
Open

Bug in buildHashAllocAndVisibleTypePP: offset missing. #145

Algomorph opened this issue Nov 26, 2019 · 2 comments

Comments

@Algomorph
Copy link

Algomorph commented Nov 26, 2019

Because your voxel coordinates represent voxel centers, i.e. they're projected directly onto the image and then rounded to get the depth, your actual hash blocks actually start with a 1/2 voxel offset from the whole coordinate.

You don't take this into account when allocating hash blocks, which results in missing blocks in certain situations and contributes drift/noise. The easy fix is to add the offset to the segment along camera ray that's marched on during hash block allocation.

Simply replace these lines:

pt_buff = pt_camera_f * (1.0f - mu / norm); pt_buff.w = 1.0f;
point = TO_VECTOR3(invM_d * pt_buff) * oneOverVoxelSize;
pt_buff = pt_camera_f * (1.0f + mu / norm); pt_buff.w = 1.0f;
point_e = TO_VECTOR3(invM_d * pt_buff) * oneOverVoxelSize;

With this:

        pt_buff = pt_camera_f * (1.0f - mu / norm); pt_buff.w = 1.0f;
	point = TO_VECTOR3(invM_d * pt_buff) * oneOverVoxelSize + Vector3f(1.0f / (2.0f * VOXEL_BLOCK_SIZE));

	pt_buff = pt_camera_f * (1.0f + mu / norm); pt_buff.w = 1.0f;
	point_e = TO_VECTOR3(invM_d * pt_buff) * oneOverVoxelSize + Vector3f(1.0f / (2.0f * VOXEL_BLOCK_SIZE));

Also, your variable names could be a bit more descriptive and not use acronyms, and calling the inverse of hash block size in meters "oneOverVoxelSize" is misleading. I suggest "oneOverVoxelBlockSize_Meters".

@Mad-Thanos
Copy link

Mad-Thanos commented May 26, 2020

VOXEL_BLOCK_SIZE

Hi, @ Algomorph What is VOXEL_BLOCK_SIZE in your code?

@Algomorph
Copy link
Author

@GucciPrada ,

In my code,

these lines

#define VOXEL_BLOCK_SIZE 8
// VOXEL_BLOCK_SIZE3 = VOXEL_BLOCK_SIZE * VOXEL_BLOCK_SIZE * VOXEL_BLOCK_SIZE
#define VOXEL_BLOCK_SIZE3 512

correspond to these lines in the original InfiniTAM repo:

#define SDF_BLOCK_SIZE 8 // SDF block size
#define SDF_BLOCK_SIZE3 512 // SDF_BLOCK_SIZE3 = SDF_BLOCK_SIZE * SDF_BLOCK_SIZE * SDF_BLOCK_SIZE

Since I have other kinds of voxels beside TSDF, it didn't make sense to refer to voxel hash blocks as "SDF blocks", so I refactored these and other things accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants