File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed 
depth_image_proc/src/nodelets Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -224,10 +224,17 @@ bool transform_depth(
224224
225225  //  Transform to RGB camera frame
226226  Eigen::Vector4d xyz_rgb = depth_to_rgb * xyz_depth;
227-   //  TODO(lucasw) return false if xyz_rgb.z() < 0.0 - or is that okay for some < 0 fx/fy?
227+   new_depth = static_cast <T>(xyz_rgb.z ());
228+   //  TODO(lucasw) is the intent to simulate what a real depth camera would see?  If so reject negative depth
229+   //  but if want to preserve as much data as possible it may make sense to pass through negative values
230+   //  (though don't overwrite positive values, use abs in the z buffer test)
231+   if  (new_depth < 0.0 )
232+   {
233+     return  false ;
234+   }
228235
229236  //  Project to (u,v) in RGB image
230-   const  double  inv_Z = 1.0  / xyz_rgb. z () ;
237+   const  double  inv_Z = 1.0  / new_depth ;
231238
232239  u_rgb = (rgb_fx*xyz_rgb.x () + rgb_Tx)*inv_Z + rgb_cx + 0.5 ;
233240  if  (u_rgb < 0  || u_rgb >= width)
@@ -237,8 +244,6 @@ bool transform_depth(
237244  if  (v_rgb < 0  || v_rgb >= height)
238245    return  false ;
239246
240-   new_depth = static_cast <T>(xyz_rgb.z ());
241- 
242247  return  true ;
243248}
244249
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments