class_docstr: Volumetric TSDF Fusion of RGB-D Images.
      
docstr: Integrate an RGB-D frame into the TSDF volume.
  Args:
  depth_im (ndarray): A depth image of shape (H, W).
  cam_intr (ndarray): The camera intrinsics matrix of shape (3, 3).
  cam_pose (ndarray): The camera pose (i.e. extrinsics) of shape (4, 4).
  obs_weight (float): The weight to assign for the current observation. A higher
  value
docstr_tok: ["Integrate","an","RGB-D","frame","into","the","TSDF","volume",".","Args",":","depth_im","(","ndarray",")",":","A","depth","image","of","shape","(","H",",","W",")",".","cam_intr","(","ndarray",")",":","The","camera","intrinsics","matrix","of","shape","(","3",",","3",")",".","cam_pose","(","ndarray",")",":","The","camera","pose","(","i.e",".","extrinsics",")","of","shape","(","4",",","4",")",".","obs_weight","(","float",")",":","The","weight","to","assign","for","the","current","observation",".","A","higher","value"]
code: def integrate(self, depth_im, cam_intr, cam_pose, obs_weight=1.0):
      """Integrate an RGB-D frame into the TSDF volume.
      Args:
      depth_im (ndarray): A depth image of shape (H, W).
      cam_intr (ndarray): The camera intrinsics matrix of shape (3, 3).
      cam_pose (ndarray): The camera pose (i.e. extrinsics) of shape (4, 4).
      obs_weight (float): The weight to assign for the current observation. A higher
      value
      """
      im_h, im_w = depth_im.shape
      if (
          self.gpu_mode
      ):  # GPU mode: integrate voxel volume (calls CUDA kernel)
          for gpu_loop_idx in range(self._n_gpu_loops):
              self._cuda_integrate(
                  self._tsdf_vol_gpu,
                  self._weight_vol_gpu,
                  cuda.InOut(self._vol_dim.astype(np.float32)),
                  cuda.InOut(self._vol_origin.astype(np.float32)),
                  cuda.InOut(cam_intr.reshape(-1).astype(np.float32)),
                  cuda.InOut(cam_pose.reshape(-1).astype(np.float32)),
                  cuda.InOut(
                      np.asarray(
                          [
                              gpu_loop_idx,
                              self._voxel_size,
                              im_h,
                              im_w,
                              self._trunc_margin,
                              obs_weight,
                          ],
                          np.float32,
                      )
                  ),
                  cuda.InOut(depth_im.reshape(-1).astype(np.float32)),
                  block=(self._max_gpu_threads_per_block, 1, 1),
                  grid=(
                      int(self._max_gpu_grid_dim[0]),
                      int(self._max_gpu_grid_dim[1]),
                      int(self._max_gpu_grid_dim[2]),
                  ),
              )
      else:  # CPU mode: integrate voxel volume (vectorized implementation)
          # Convert voxel grid coordinates to pixel coordinates
          cam_pts = self.vox2world(
              self._vol_origin, self.vox_coords, self._voxel_size
          )
          cam_pts = rigid_transform(cam_pts, np.linalg.inv(cam_pose))
          pix_z = cam_pts[:, 2]
          pix = self.cam2pix(cam_pts, cam_intr)
          pix_x, pix_y = pix[:, 0], pix[:, 1]
  
          # Eliminate pixels outside view frustum
          valid_pix = np.logical_and(
              pix_x >= 0,
              np.logical_and(
                  pix_x < im_w,
                  np.logical_and(
                      pix_y >= 0,
                      np.logical_and(pix_y < im_h, pix_z > 0),
                  ),
              ),
          )
          depth_val = np.zeros(pix_x.shape)
          depth_val[valid_pix] = depth_im[
              pix_y[valid_pix], pix_x[valid_pix]
          ]
  
          # Integrate TSDF
          depth_diff = depth_val - pix_z
          valid_pts = np.logical_and(
              depth_val > 0, depth_diff >= -self._trunc_margin
          )
          dist = np.minimum(1, depth_diff / self._trunc_margin)
          valid_vox_x = self.vox_coords[valid_pts, 0]
          valid_vox_y = self.vox_coords[valid_pts, 1]
          valid_vox_z = self.vox_coords[valid_pts, 2]
          w_old = self._weight_vol_cpu[
              valid_vox_x, valid_vox_y, valid_vox_z
          ]
          tsdf_vals = self._tsdf_vol_cpu[
              valid_vox_x, valid_vox_y, valid_vox_z
          ]
          valid_dist = dist[valid_pts]
          tsdf_vol_new, w_new = self.integrate_tsdf(
              tsdf_vals, valid_dist, w_old, obs_weight
          )
          self._weight_vol_cpu[
              valid_vox_x, valid_vox_y, valid_vox_z
          ] = w_new
          self._tsdf_vol_cpu[
              valid_vox_x, valid_vox_y, valid_vox_z
          ] = tsdf_vol_new
  
file_path: torch-points3d/torch_points3d/datasets/registration/fusion.py
imports: import numpy
  from numba import njit, prange
  from skimage import measure
label_desc: Use image node_id 5 for calling the TSDFVolume obj's underlying member method code with example usage: obj.integrate(depth_im, cam_intr, cam_pose, obs_weight) without return types