smarts.core.utils.observations module

smarts.core.utils.observations.points_to_pixels(points: ndarray, center_position: ndarray, heading: float, width: int, height: int, resolution: float) ndarray[source]

Converts points into pixel coordinates in order to superimpose the points onto the RGB image.

Parameters:
  • points (np.ndarray) – Array of points. Shape (n,3).

  • center_position (np.ndarray) – Center position of image. Generally, this is equivalent to ego position. Shape = (3,).

  • heading (float) – Heading of image in radians. Generally, this is equivalent to ego heading.

  • width (int) – Width of RGB image

  • height (int) – Height of RGB image.

  • resolution (float) – Resolution of RGB image in meters/pixels. Computed as ground_size/image_size.

Returns:

Array of point coordinates on the RGB image. Shape = (m,3).

Return type:

np.ndarray

smarts.core.utils.observations.replace_rgb_image_color(rgb: ndarray, old_color: Sequence[ndarray], new_color: ndarray, mask: ndarray = False) ndarray[source]
Convert pixels of value old_color to new_color within the masked

region in the received RGB image.

Parameters:
  • rgb (np.ndarray) – RGB image. Shape = (m,n,3).

  • old_color (Sequence[np.ndarray]) – List of old colors to be removed from the RGB image. Shape = (3,).

  • new_color (np.ndarray) – New color to be added to the RGB image. Shape = (3,).

  • mask (np.ndarray, optional) – Valid regions for color replacement. Shape = (m,n,3). Defaults to np.ma.nomask .

Returns:

RGB image with old_color pixels changed to new_color

within the masked region. Shape = (m,n,3).

Return type:

np.ndarray

smarts.core.utils.observations.rotate_axes(points: ndarray, theta: float) ndarray[source]

A counterclockwise rotation of the x-y axes by an angle theta θ about the z-axis.

Parameters:
  • points (np.ndarray) – x,y,z coordinates in original axes. Shape = (n,3).

  • theta (np.float) – Axes rotation angle in radians.

Returns:

x,y,z coordinates in rotated axes. Shape = (n,3).

Return type:

np.ndarray