Skip to content

Commit 888c603

Browse files
committed
don't pass through negative depth values for now
1 parent c9a6f6e commit 888c603

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

depth_image_proc/src/nodelets/register.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,17 @@ bool transform_depth(
227227

228228
// Transform to RGB camera frame
229229
Eigen::Vector4d xyz_rgb = depth_to_rgb * xyz_depth;
230-
// TODO(lucasw) return false if xyz_rgb.z() < 0.0 - or is that okay for some < 0 fx/fy?
230+
new_depth = static_cast<T>(xyz_rgb.z());
231+
// TODO(lucasw) is the intent to simulate what a real depth camera would see? If so reject negative depth
232+
// but if want to preserve as much data as possible it may make sense to pass through negative values
233+
// (though don't overwrite positive values, use abs in the z buffer test)
234+
if (new_depth < 0.0)
235+
{
236+
return false;
237+
}
231238

232239
// Project to (u,v) in RGB image
233-
const double inv_Z = 1.0 / xyz_rgb.z();
240+
const double inv_Z = 1.0 / new_depth;
234241

235242
u_rgb = (rgb_fx*xyz_rgb.x() + rgb_Tx)*inv_Z + rgb_cx + 0.5;
236243
if (u_rgb < 0 || u_rgb >= width)
@@ -240,8 +247,6 @@ bool transform_depth(
240247
if (v_rgb < 0 || v_rgb >= height)
241248
return false;
242249

243-
new_depth = static_cast<T>(xyz_rgb.z());
244-
245250
return true;
246251
}
247252

0 commit comments

Comments
 (0)