Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions zod/visualization/bev_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Utilities for creating point cloud input representation."""

from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import List, Tuple

import numpy as np
Expand All @@ -25,8 +25,8 @@ class BEVSettings:

# pylint: disable=too-many-instance-attributes
# General settings
grid_min: np.ndarray = np.array([-50.0, 0.0])
grid_max: np.ndarray = np.array([50.0, 100.0])
grid_min: np.ndarray = field(default_factory=lambda: np.array([-50.0, 0.0]))
grid_max: np.ndarray = field(default_factory=lambda: np.array([50.0, 100.0]))
grid_cell_size: float = 0.1 # Default in PIXOR: 0.1

# Pixor settings
Expand Down Expand Up @@ -94,7 +94,7 @@ def _create_pointcloud_input_pixor(
A PIXOR style BEV projection of the input point cloud.

"""
point_indices_c = np.cast["int32"]((points[:, 2] - settings.pixor_z_min) / settings.grid_cell_size)
point_indices_c = np.asarray((points[:, 2] - settings.pixor_z_min) / settings.grid_cell_size, dtype="int32")
point_indices_c = 1 + np.clip(
point_indices_c,
a_min=-1,
Expand Down Expand Up @@ -156,7 +156,7 @@ def get_grid_indices_xy(cloud: np.ndarray, settings: BEVSettings) -> np.ndarray:

"""
# Convert points to indices
indices_xy = np.cast["int32"]((cloud[:, :2] - settings.grid_min) / settings.grid_cell_size)
indices_xy = np.asarray((cloud[:, :2] - settings.grid_min) / settings.grid_cell_size, dtype="int32")
return indices_xy


Expand Down
4 changes: 2 additions & 2 deletions zod/visualization/lidar_bev.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _add_object(
)

# Add arrow in the direction of the object
arrow_length = int(np.cast["float32"](dimension[0]) * 0.8)
arrow_length = int(np.asarray(dimension[0]) * 0.8, dtype="float32")
end_point = np.array([arrow_length, 0, 0])
end_point = rotation.rotate(end_point)[:2] + position
fig.add_annotation(
Expand Down Expand Up @@ -156,6 +156,6 @@ def _activate_legend(self, fig):
@staticmethod
def _create_od_vis_background(input_array: np.ndarray) -> np.ndarray:
"""Create a gray occupancy grid as background to visualize over."""
occupancy = np.maximum.reduce(np.cast["float32"](np.abs(input_array) > 0.0), axis=0, keepdims=True)
occupancy = np.maximum.reduce(np.asarray(np.abs(input_array) > 0.0, dtype="float32"), axis=0, keepdims=True)
vis_bg = np.transpose(np.repeat(occupancy * 77, 3, axis=0), [2, 1, 0])
return vis_bg