Skip to content

Commit

Permalink
Misc cleanups (nutonomy#2)
Browse files Browse the repository at this point in the history
* renamed folders, updated README and requirements.

* typo

* another typo

* Deleted notebook checkpoint

* added types and missing params for nuscenes explorer methods

* updated import according to the renamed utils folder
  • Loading branch information
sourabh-nutonomy authored and holger-motional committed Sep 14, 2018
1 parent dc943fa commit f7f057c
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 32 deletions.
51 changes: 46 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,59 @@ cd && git clone https://github.com/nutonomy/nuscenes-devkit.git
```
The dev-kit is tested for Python 3.7.
We may add backward compatibility in future releases.
To install the required packages, run the following in your favourite virtual environment:
To install the required packages, run the following command in your favourite virtual environment. If you need help in
installing Python3.7 or in setting up a new virtual environment, you can look at [these instructions](#setup-new-virtual-environment):
```
pip install -r requirements.txt
```
Also add the `nuscenes_python` directory to your `PYTHONPATH` environmental variable, e.g. by adding the following to your `~/.bashrc`:
Also add the `python-sdk` directory to your `PYTHONPATH` environmental variable, e.g. by adding the
following to your `~/.bashrc`:
```
export PYTHONPATH="${PYTHONPATH}:$HOME/nuscenes-devkit/nuscenes_python"
export PYTHONPATH="${PYTHONPATH}:$HOME/nuscenes-devkit/python-sdk"
```

## Getting started
To get started with the nuScenes devkit, please run the tutorial as an IPython notebook:
```
jupyter notebook $HOME/nuscenes-devkit/nuscenes_python/nuscenes_tutorial.ipynb
jupyter notebook $HOME/nuscenes-devkit/python-sdk/tutorial.ipynb
```
In case you want to avoid downloading and setting up the data, you can also take a look at the same notebook on [Github](https://github.com/nutonomy/nuscenes-devkit/blob/master/nuscenes_python/nuscenes_tutorial.ipynb).
In case you want to avoid downloading and setting up the data, you can also take a look at the same notebook on
[Github](https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/tutorial.ipynb).

## Setup new virtual environment

It is recommended to install the devkit in a new virtual environment. Here are the steps you can follow to create one:

#### Python 3.7 installation

If you don't have Python 3.7 on your system, you can use the following steps to install it.

UBUNTU:
```
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.7
```

MACOS: Download from `https://www.python.org/downloads/mac-osx/` and install.

#### Install virtualenvwrapper
```
pip install virtualenvwrapper
```
Add these two lines to `~/.bashrc` (`~/.bash_profile` on MACOS) to set the location where the virtual environments
should live and the location of the script installed with this package:
```
export WORKON_HOME=$HOME/.virtualenvs
source [VIRTUAL_ENV_LOCATION]
```
Replace `[VIRTUAL_ENV_LOCATION]` with either `/usr/local/bin/virtualenvwrapper.sh` or `~/.local/bin/virtualenvwrapper.sh`
depending on where it is installed on your system.

After editing it, reload the shell startup file by running e.g. `source ~/.bashrc`.

#### Create the virtual environment
```
mkvirtualenv nuscenes --python [PYTHON_BINARIES]
```
PYTHON_BINARIES are typically at either `/usr/local/bin/python3.7` or `/usr/bin/python3.7`.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@
"304715 sample_data,\n",
"99952 sample_annotation,\n",
"12 map,\n",
"Done loading in 4.0 seconds.\n",
"Done loading in 4.3 seconds.\n",
"======\n",
"Reverse indexing ...\n",
"Done reverse indexing in 0.6 seconds.\n",
"Done reverse indexing in 1.3 seconds.\n",
"======\n"
]
}
],
"source": [
"# Let's start by initializing the database\n",
"%matplotlib inline\n",
"from nuscenes_utils.nuscenes import NuScenes\n",
"from utils.nuscenes import NuScenes\n",
"\n",
"nusc = NuScenes(version='v0.1', dataroot='/data/nuscenes', verbose=True)"
]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pyquaternion import Quaternion


from nuscenes_utils.geometry_utils import view_points
from utils.geometry_utils import view_points


class PointCloud:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def view_points(points, view, normalize):

def box_in_image(box, intrinsic, imsize, vis_level=BoxVisibility.IN_FRONT):
"""
Check if a box in visible inside an image without accounting for occlusions.
Check if a box is visible inside an image without accounting for occlusions.
:param box: <Box>.
:param intrinsic: <float: 3, 3>. Intrinsic camera matrix.
:param imsize: (width <int>, height <int>).
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
from matplotlib.axes import Axes
from pyquaternion import Quaternion

from nuscenes_utils.map_mask import MapMask
from nuscenes_utils.data_classes import PointCloud, Box
from nuscenes_utils.geometry_utils import view_points, box_in_image, quaternion_slerp, BoxVisibility
from utils.map_mask import MapMask
from utils.data_classes import PointCloud, Box
from utils.geometry_utils import view_points, box_in_image, quaternion_slerp, BoxVisibility


PYTHON_VERSION = sys.version_info[0]
Expand Down Expand Up @@ -305,41 +305,43 @@ def get_boxes(self, sample_data_token: str) -> List[Box]:
boxes.append(box)
return boxes

def list_categories(self):
def list_categories(self) -> None:
self.explorer.list_categories()

def list_attributes(self):
def list_attributes(self) -> None:
self.explorer.list_attributes()

def list_scenes(self):
def list_scenes(self) -> None:
self.explorer.list_scenes()

def list_sample(self, sample_token):
def list_sample(self, sample_token: str) -> None:
self.explorer.list_sample(sample_token)

def render_pointcloud_in_image(self, sample_token):
self.explorer.render_pointcloud_in_image(sample_token)
def render_pointcloud_in_image(self, sample_token: str, dot_size: int=5) -> None:
self.explorer.render_pointcloud_in_image(sample_token, dot_size)

def render_sample(self, sample_token):
self.explorer.render_sample(sample_token)
def render_sample(self, sample_token: str, box_vis_level: BoxVisibility=BoxVisibility.IN_FRONT) -> None:
self.explorer.render_sample(sample_token, box_vis_level)

def render_sample_data(self, sample_data_token):
self.explorer.render_sample_data(sample_data_token)
def render_sample_data(self, sample_data_token: str, with_anns: bool=True, box_vis_level: BoxVisibility=3,
axes_limit: float=40, ax: Axes=None) -> None:
self.explorer.render_sample_data(sample_data_token, with_anns, box_vis_level, axes_limit, ax)

def render_annotation(self, sample_annotation_token):
self.explorer.render_annotation(sample_annotation_token)
def render_annotation(self, sample_annotation_token: str, margin: float=10, view: np.ndarray=np.eye(4),
box_vis_level: BoxVisibility=3) -> None:
self.explorer.render_annotation(sample_annotation_token, margin, view, box_vis_level)

def render_instance(self, instance_token):
def render_instance(self, instance_token: str) -> None:
self.explorer.render_instance(instance_token)

def render_scene(self, scene_token: str, freq: float=10, imsize: Tuple[float, float]=(640, 360),
out_path : str=None):
out_path : str=None) -> None:
self.explorer.render_scene(scene_token, freq, imsize, out_path)

def render_scene_channel(self, scene_token, channel='CAM_FRONT'):
self.explorer.render_scene_channel(scene_token, channel=channel)
def render_scene_channel(self, scene_token: str, channel: str='CAM_FRONT', imsize: Tuple[float, float] = (640, 360)):
self.explorer.render_scene_channel(scene_token, channel=channel, imsize=imsize)

def render_scene_on_map(self, scene_token):
def render_scene_on_map(self, scene_token: str) -> None:
self.explorer.render_scene_on_map(scene_token)


Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
easydict==1.8
jupyter==1.0.0
matplotlib==2.2.3
numpy==1.14.5
opencv-python==3.4.2.17
Pillow==5.2.0
pyquaternion==0.9.2
tqdm==4.25.0
opencv-python==3.4.2.17

0 comments on commit f7f057c

Please sign in to comment.