torchdrivesim.rendering.base¶
Base class for renderers producing rasterized birdview images from given background meshes and agent positions.
Attributes¶
Classes¶
Determines behavior of the renderer. |
|
For DummyRenderer. |
|
Lightweight version of pytorch3d.renderer.FoVOrthographicCameras. |
|
A renderer producing simple 2D birdview images based on static background meshes and rectangular agents. |
|
Produces a black image of the required size. Mostly used for debugging and benchmarking. |
Functions¶
|
Produces the default rendering levels, mapping object categories |
|
Produces the default color map, mapping object categories |
Module Contents¶
- class torchdrivesim.rendering.base.RendererConfig[source]¶
Determines behavior of the renderer. Subclasses determine renderer class used.
- class torchdrivesim.rendering.base.DummyRendererConfig[source]¶
Bases:
RendererConfigFor DummyRenderer.
- class torchdrivesim.rendering.base.Cameras(xy: torch.Tensor, sc: torch.Tensor, scale: float)[source]¶
Lightweight version of pytorch3d.renderer.FoVOrthographicCameras. Used to define an interface that works without pytorch3d.
- transform_points_screen(points: torch.Tensor, res: torchdrivesim.utils.Resolution) torch.Tensor[source]¶
- reverse_transform_points_screen(points: torch.Tensor, res: torchdrivesim.utils.Resolution) torch.Tensor[source]¶
- class torchdrivesim.rendering.base.BirdviewRenderer(cfg: RendererConfig, color_map: Dict[str, Tuple[int, int, int]] | None = None, rendering_levels: Dict[str, float] | None = None, res: torchdrivesim.utils.Resolution = Resolution(64, 64), fov: float = 35)[source]¶
Bases:
abc.ABCA renderer producing simple 2D birdview images based on static background meshes and rectangular agents. Currently only square resolutions are supported. The renderer always operates in batch mode, with a single batch dimension on the left.
- Parameters:
cfg – configuration object, usually subclassed
color_map – a dictionary of RGB tuples in 0-255 range specifying colors of different rendered elements
res – default resolution
- render_frame(rgb_mesh: torchdrivesim.mesh.RGBMesh, camera_xy: torch.Tensor, camera_sc: torch.Tensor, res: torchdrivesim.utils.Resolution | None = None, fov: float | None = None)[source]¶
Renders a given rgb mesh according the camera position and rotation.
- Parameters:
rgb_mesh – the given rgb mesh to render which should be already expanded to match the number of cameras.
camera_xy – BxNcx2 tensor of camera positions, by default one camera placed on each agent
camera_sc – BxNcx2 tensor of camera orientations (sine and cosine), by default matching agent orientations
res – resolution HxW of the resulting image, currently only square resolutions are supported
fov – Field of view in meters
- Returns:
tensor image of float RGB values in [0,255] range with shape shape (B*Nc)xCxHxW
- abstract render_rgb_mesh(mesh: torchdrivesim.mesh.RGBMesh, res: torchdrivesim.utils.Resolution, cameras: Cameras) torch.Tensor[source]¶
Renders a given mesh, producing BxHxWxC tensor image of float RGB values in [0,255] range.
- class torchdrivesim.rendering.base.DummyRenderer(cfg: RendererConfig, color_map: Dict[str, Tuple[int, int, int]] | None = None, rendering_levels: Dict[str, float] | None = None, res: torchdrivesim.utils.Resolution = Resolution(64, 64), fov: float = 35)[source]¶
Bases:
BirdviewRendererProduces a black image of the required size. Mostly used for debugging and benchmarking.
- render_rgb_mesh(mesh: torchdrivesim.mesh.RGBMesh, res: torchdrivesim.utils.Resolution, cameras: Cameras) torch.Tensor[source]¶
Renders a given mesh, producing BxHxWxC tensor image of float RGB values in [0,255] range.