victorprad / InfiniTAM

A Framework for the Volumetric Integration of Depth Images
http://www.infinitam.org
Other
918 stars 351 forks source link

computeNormalAndWeight uses intrinparam wrongly #41

Open Masterxilo opened 8 years ago

Masterxilo commented 8 years ago

The method uses the focal length fx, fy in a wrong way to unproject points:

x_yp1.x = x_yp1.z * (x - intrinparam.z) * intrinparam.x;
x_yp1.y = x_yp1.z * ((y + 1.0f) - intrinparam.w) * intrinparam.y;

This is only valid when intrinparam.x and intrinparam.y have been inverted (so that they are 1/fx, 1/fy). But this does not happen anywhere in the calls to that function. As a result, the x_y.xy values are extremely large.

The fix is to compute

Vector4f projParams = projectionParamsSimple.all;
Vector4f invProjParams = projParams;
invProjParams.x = 1.0f / invProjParams.x;
invProjParams.y = 1.0f / invProjParams.y;

like AllocateSceneFromDepth does for example and then pass those.

Or we could correct the formula to:

x_yp1.x = x_yp1.z * (x - intrinparam.z) / intrinparam.x;
x_yp1.y = x_yp1.z * ((y + 1.0f) - intrinparam.w) / intrinparam.y;

Interestingly, the TRACKER_WICP still seems to work fine.

Masterxilo commented 8 years ago

Screenshot with the fix:

with_inv_intrin_param (not sure if it should look this way, but the tracker also works with the fix)

Without the fix:

without_inv_intrin_param

carlren commented 8 years ago

@victorprad @olafkaehler blame is on me, please fix :)

WICP can still work since we have a min weight threshold.