ravens/utils.py
def unproject_vectorized(uv_coordinates: np.ndarray, depth_values: np.ndarray,
                         intrinsic: np.ndarray,
                         distortion: np.ndarray) -> np.ndarray:
  """Vectorized version of unproject(), for N points.

  Args:
    uv_coordinates: pixel coordinates to unproject of shape (n, 2).
    depth_values: depth values corresponding index-wise to the uv_coordinates of
      shape (n).
    intrinsic: array of shape (3, 3). This is typically the return value
      of intrinsics_to_matrix.
    distortion: camera distortion parameters of shape (5,).

  Returns:
    xyz coordinates in camera frame of shape (n, 3).
  """
  cam_mtx = intrinsic  # shape [3, 3]
  cam_dist = np.array(distortion)  # shape [5]

  # shape of points_undistorted is [N, 2] after the squeeze().
  points_undistorted = cv2.undistortPoints(
      uv_coordinates.reshape((-1, 1, 2)), cam_mtx, cam_dist).squeeze()

  x = points_undistorted[:, 0] * depth_values
  y = points_undistorted[:, 1] * depth_values

  xyz = np.vstack((x, y, depth_values)).T
  return xyz
Vectorized version of unproject(), for N points.

  Args:
    uv_coordinates: pixel coordinates to unproject of shape (n, 2).
    depth_values: depth values corresponding index-wise to the uv_coordinates of
      shape (n).
    intrinsic: array of shape (3, 3). This is typically the return value
      of intrinsics_to_matrix.
    distortion: camera distortion parameters of shape (5,).

  Returns:
    xyz coordinates in camera frame of shape (n, 3).
  
Vectorized version of unproject(), for N points.
Vectorized version of unproject () for N points .
def unproject_vectorized(uv_coordinates: np.ndarray, depth_values: np.ndarray,
                         intrinsic: np.ndarray,
                         distortion: np.ndarray) -> np.ndarray:
  cam_mtx = intrinsic  
  cam_dist = np.array(distortion)  
  points_undistorted = cv2.undistortPoints(
      uv_coordinates.reshape((-1, 1, 2)), cam_mtx, cam_dist).squeeze()
  x = points_undistorted[:, 0] * depth_values
  y = points_undistorted[:, 1] * depth_values
  xyz = np.vstack((x, y, depth_values)).T
  return xyz
def unproject_vectorized ( uv_coordinates : np . ndarray , depth_values : np . ndarray , intrinsic : np . ndarray , distortion : np . ndarray ) -> np . ndarray : cam_mtx = intrinsic cam_dist = np . array ( distortion ) points_undistorted = cv2 . undistortPoints ( uv_coordinates . reshape ( ( - 1 , 1 , 2 ) ) , cam_mtx , cam_dist ) . squeeze ( ) x = points_undistorted [ : , 0 ] * depth_values y = points_undistorted [ : , 1 ] * depth_values xyz = np . vstack ( ( x , y , depth_values ) ) . T return xyz
Vectorized version of unproject(), for N points.
Vectorized version of unproject () for N points .
"""Vectorized version of unproject(), for N points.

  Args:
    uv_coordinates: pixel coordinates to unproject of shape (n, 2).
    depth_values: depth values corresponding index-wise to the uv_coordinates of
      shape (n).
    intrinsic: array of shape (3, 3). This is typically the return value
      of intrinsics_to_matrix.
    distortion: camera distortion parameters of shape (5,).

  Returns:
    xyz coordinates in camera frame of shape (n, 3).
  """ # shape [3, 3] # shape [5] # shape of points_undistorted is [N, 2] after the squeeze().
xyz coordinates in camera frame of shape (n, 3).
xyz coordinates in camera frame of shape ( n 3 ) .
uv_coordinates
np.ndarray
pixel coordinates to unproject of shape (n, 2).
pixel coordinates to unproject of shape ( n 2 ) .
depth_values
np.ndarray
depth values corresponding index-wise to the uv_coordinates of
shape (n).
depth values corresponding index - wise to the uv_coordinates of shape ( n ) .
intrinsic
np.ndarray
array of shape (3, 3). This is typically the return value
of intrinsics_to_matrix.
array of shape ( 3 3 ) . This is typically the return value of intrinsics_to_matrix .
distortion
np.ndarray
camera distortion parameters of shape (5,).
camera distortion parameters of shape ( 5 ) .