Skip to content

Commit

Permalink
Miscellaneous improvements: Plot settings, default number of sweeps (n…
Browse files Browse the repository at this point in the history
…utonomy#215)

* Don't include pycache folders in pip package, added new author

* Include license in pip package

* Improve evaluation plot limits

* Use known stable Docker build

* Fixed deprecated link

* Changed default number of sweeps to 5, cleanup

* added typing
  • Loading branch information
holger-motional authored Sep 2, 2019
1 parent f157d00 commit c480b4f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ To install this expansion, please follow these steps:

## Devkit setup
The devkit is tested for Python 3.6 and Python 3.7.
To install Python, please check [here](https://github.com/nutonomy/nuscenes-devkit/blob/master/installation.md#install-python).
To install Python, please check [here](https://github.com/nutonomy/nuscenes-devkit/blob/master/setup/installation.md#install-python).

Our devkit is available and can be installed via [pip](https://pip.pypa.io/en/stable/installing/) :
```
Expand Down
4 changes: 3 additions & 1 deletion python-sdk/nuscenes/eval/detection/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ def class_tp_curve(md_list: MetricDataList,
md = md_list[(detection_name, dist_th_tp)]
min_recall_ind = round(100 * min_recall)
if min_recall_ind <= md.max_recall_ind:
ylimit = max([max(getattr(md, metric)[min_recall_ind:md.max_recall_ind + 1]) for metric in TP_METRICS]) * 1.1
# For traffic_cone and barrier only a subset of the metrics are plotted.
rel_metrics = [m for m in TP_METRICS if not np.isnan(metrics.get_label_tp(detection_name, m))]
ylimit = max([max(getattr(md, metric)[min_recall_ind:md.max_recall_ind + 1]) for metric in rel_metrics]) * 1.1
else:
ylimit = 1.0

Expand Down
41 changes: 20 additions & 21 deletions python-sdk/nuscenes/utils/data_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,36 @@ def from_file_multisweep(cls,
sample_rec: Dict,
chan: str,
ref_chan: str,
nsweeps: int = 26,
nsweeps: int = 5,
min_distance: float = 1.0) -> Tuple['PointCloud', np.ndarray]:
"""
Return a point cloud that aggregates multiple sweeps.
As every sweep is in a different coordinate frame, we need to map the coordinates to a single reference frame.
As every sweep has a different timestamp, we need to account for that in the transformations and timestamps.
:param nusc: A NuScenes instance.
:param sample_rec: The current sample.
:param chan: The radar channel from which we track back n sweeps to aggregate the point cloud.
:param chan: The lidar/radar channel from which we track back n sweeps to aggregate the point cloud.
:param ref_chan: The reference channel of the current sample_rec that the point clouds are mapped to.
:param nsweeps: Number of sweeps to aggregated.
:param min_distance: Distance below which points are discarded.
:return: (all_pc, all_times). The aggregated point cloud and timestamps.
"""

# Init
# Init.
points = np.zeros((cls.nbr_dims(), 0))
all_pc = cls(points)
all_times = np.zeros((1, 0))

# Get reference pose and timestamp
# Get reference pose and timestamp.
ref_sd_token = sample_rec['data'][ref_chan]
ref_sd_rec = nusc.get('sample_data', ref_sd_token)
ref_pose_rec = nusc.get('ego_pose', ref_sd_rec['ego_pose_token'])
ref_cs_rec = nusc.get('calibrated_sensor', ref_sd_rec['calibrated_sensor_token'])
ref_time = 1e-6 * ref_sd_rec['timestamp']

# Homogeneous transform from ego car frame to reference frame
# Homogeneous transform from ego car frame to reference frame.
ref_from_car = transform_matrix(ref_cs_rec['translation'], Quaternion(ref_cs_rec['rotation']), inverse=True)

# Homogeneous transformation matrix from global to _current_ ego car frame
# Homogeneous transformation matrix from global to _current_ ego car frame.
car_from_global = transform_matrix(ref_pose_rec['translation'], Quaternion(ref_pose_rec['rotation']),
inverse=True)

Expand All @@ -116,7 +115,7 @@ def from_file_multisweep(cls,

# Remove close points and add timevector.
current_pc.remove_close(min_distance)
time_lag = ref_time - 1e-6 * current_sd_rec['timestamp'] # positive difference
time_lag = ref_time - 1e-6 * current_sd_rec['timestamp'] # Positive difference.
times = time_lag * np.ones((1, current_pc.nbr_points()))
all_times = np.hstack((all_times, times))

Expand Down Expand Up @@ -182,31 +181,31 @@ def transform(self, transf_matrix: np.ndarray) -> None:
def render_height(self,
ax: Axes,
view: np.ndarray = np.eye(4),
x_lim: Tuple = (-20, 20),
y_lim: Tuple = (-20, 20),
x_lim: Tuple[float, float] = (-20, 20),
y_lim: Tuple[float, float] = (-20, 20),
marker_size: float = 1) -> None:
"""
Very simple method that applies a transformation and then scatter plots the points colored by height (z-value).
:param ax: Axes on which to render the points.
:param view: <np.float: n, n>. Defines an arbitrary projection (n <= 4).
:param x_lim: (min <float>, max <float>). x range for plotting.
:param y_lim: (min <float>, max <float>). y range for plotting.
:param x_lim: (min, max). x range for plotting.
:param y_lim: (min, max). y range for plotting.
:param marker_size: Marker size.
"""
self._render_helper(2, ax, view, x_lim, y_lim, marker_size)

def render_intensity(self,
ax: Axes,
view: np.ndarray = np.eye(4),
x_lim: Tuple = (-20, 20),
y_lim: Tuple = (-20, 20),
x_lim: Tuple[float, float] = (-20, 20),
y_lim: Tuple[float, float] = (-20, 20),
marker_size: float = 1) -> None:
"""
Very simple method that applies a transformation and then scatter plots the points colored by intensity.
:param ax: Axes on which to render the points.
:param view: <np.float: n, n>. Defines an arbitrary projection (n <= 4).
:param x_lim: (min <float>, max <float>).
:param y_lim: (min <float>, max <float>).
:param x_lim: (min, max).
:param y_lim: (min, max).
:param marker_size: Marker size.
"""
self._render_helper(3, ax, view, x_lim, y_lim, marker_size)
Expand All @@ -215,16 +214,16 @@ def _render_helper(self,
color_channel: int,
ax: Axes,
view: np.ndarray,
x_lim: Tuple,
y_lim: Tuple,
x_lim: Tuple[float, float],
y_lim: Tuple[float, float],
marker_size: float) -> None:
"""
Helper function for rendering.
:param color_channel: Point channel to use as color.
:param ax: Axes on which to render the points.
:param view: <np.float: n, n>. Defines an arbitrary projection (n <= 4).
:param x_lim: (min <float>, max <float>).
:param y_lim: (min <float>, max <float>).
:param x_lim: (min, max).
:param y_lim: (min, max).
:param marker_size: Marker size.
"""
points = view_points(self.points[:3, :], view, normalize=False)
Expand Down Expand Up @@ -555,7 +554,7 @@ def render(self,
view: np.ndarray = np.eye(3),
normalize: bool = False,
colors: Tuple = ('b', 'r', 'k'),
linewidth: float = 2):
linewidth: float = 2) -> None:
"""
Renders the box in the provided Matplotlib axis.
:param axis: Axis onto which the box should be drawn.
Expand Down
7 changes: 6 additions & 1 deletion setup/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ def get_dirlist(_rootdir):
rootdir = 'python-sdk'
packages = [d.replace('/', '.').replace('{}.'.format(rootdir), '') for d in get_dirlist(rootdir)]

# Filter out Python cache folders
packages = [p for p in packages if not p.endswith('__pycache__')]

setuptools.setup(
name='nuscenes-devkit',
version='1.0.2',
author='Holger Caesar, Oscar Beijbom, Qiang Xu, Varun Bankiti, Alex H. Lang, Sourabh Vora, Venice Erin Liong, '
'Chris Li, Sergi Widjaja et al.',
'Chris Li, Sergi Widjaja, Kiwoo Shin et al.',
author_email='nuscenes@nutonomy.com',
description='The official devkit of the nuScenes dataset (www.nuscenes.org).',
long_description=long_description,
Expand All @@ -45,5 +48,7 @@ def get_dirlist(_rootdir):
classifiers=[
'Programming Language :: Python :: 3.6',
'Operating System :: OS Independent',
'License :: Free for non-commercial use'
],
license='cc-by-nc-sa-4.0'
)

0 comments on commit c480b4f

Please sign in to comment.