Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CODa to KITTI converter improved #11

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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: 10 additions & 0 deletions cuda_11.3_env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CUDAVER=cuda-11.3
CUDA_ABS_PATH=/usr/local/$CUDAVER
export PATH=$CUDA_ABS_PATH/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_ABS_PATH/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$CUDA_ABS_PATH/lib64:$LD_LIBRARY_PATH
export CUDADIR=$CUDA_ABS_PATH
export CUDA_PATH=$CUDA_ABS_PATH
export CUDA_ROOT=$CUDA_ABS_PATH
export CUDA_HOME=$CUDA_ABS_PATH
export CUDA_HOST_COMPILER=/usr/bin/gcc
81 changes: 60 additions & 21 deletions docs/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,28 @@ We describe how to prepare the other datasets in the [preparing external dataset

### Campus Object Dataset (CODa)

Please download the official CODa using the [dataset development kit](https://github.com/ut-amrl/coda-devkit)
and link it in the data directory in this repo as follows. You may need to symlink the `3d_raw` directory
to the `3d_comp` directory if you downloaded CODa by split rather than by sequence.

Please download the official CODa using the [dataset development kit](https://github.com/ut-amrl/coda-devkit) with the command:
```bashrc
python scripts/download_split.py -d data/coda -t split --split full
```
Link it in the data directory `coda_original_format` in this repo as follows. You may need to symlink the `3d_raw` directory to the `3d_comp` directory.

Next, download the `2d_bbox` folder from the [url](https://web.corral.tacc.utexas.edu/texasrobotics/web_CODa/CODa_models/). Unzip and arrange as follows:

```bash
coda-models
├── data
│ ├── coda_original_format
│ └── coda_original_format
│ ├── 2d_bbox
│ ├── 2d_rect
| ├── 3d_raw
│ ├── 3d_bbox
│ ├── 3d_comp
│ ├── 3d_raw # soft-link to 3d_comp
│ ├── 3d_semantic
│ ├── calibrations
│ ├── metadata
│ ├── poses
| ── timestamps
── timestamps
├── pcdet
├── tools
```
Expand All @@ -32,33 +40,64 @@ coda-models
python tools/create_data.py coda
```

You should now see the following file structure:

```bash
coda-models
├── data
│ ├── coda_original_format
│ │ ├── 2d_bbox
│ │ ├── 2d_rect
│ │ ├── 3d_bbox
│ │ ├── 3d_comp
│ │ ├── 3d_raw # soft-link to 3d_comp
│ │ ├── 3d_semantic
│ │ ├── calibrations
│ │ ├── metadata
│ │ ├── poses
│ │ └── timestamps
│ │
│ └── coda128_allclass_full
│ ├── ImageSets
│ ├── testing
│ └── training
├── pcdet
├── tools
```


* Generate the data infos by running the following command:
```python
python -m pcdet.datasets.coda.coda_dataset create_coda_infos tools/cfgs/dataset_configs/da_coda_oracle_dataset_full.yaml
```

You should now see the following file structure.
You should now see the following file structure:

```
```bash
coda-models
├── data
│ ├── coda_original_format
│ ├── 2d_rect
| ├── 3d_raw
│ ├── calibrations
│ ├── metadata
│ ├── poses
| ├── timestamps
│ ├── coda128_allclass_full
│ │ ├── 2d_bbox
│ │ ├── 2d_rect
│ │ ├── 3d_bbox
│ │ ├── 3d_comp
│ │ ├── 3d_raw # soft-link to 3d_comp
│ │ ├── 3d_semantic
│ │ ├── calibrations
│ │ ├── metadata
│ │ ├── poses
│ │ └── timestamps
│ │
│ └── coda128_allclass_full
│ ├── gt_database
| ├── ImageSets
├── ImageSets
│ ├── testing
│ ├── training
│ ├── coda_dbinfos_train.pkl
| ├── coda_infos_test.pkl
| ├── coda_infos_train.pkl
| ├── coda_infos_trainval.pkl
| ── coda_infos_val.pkl
├── coda_infos_test.pkl
├── coda_infos_train.pkl
├── coda_infos_trainval.pkl
── coda_infos_val.pkl
├── pcdet
├── tools
```
Expand Down
14 changes: 13 additions & 1 deletion docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,19 @@ pip install spconv-cu113
pip install -r requirements.txt
```

c. Install this repository
c. Link to cuda_11.3 on your machine and use correct GCC/G++

```bashrc
source cuda_11.3_env

sudo apt-get install gcc-9 g++-9 -y
sudo ln -sfn /usr/bin/gcc-9 /usr/bin/gcc
sudo ln -sfn /usr/bin/gcc-9 /usr/bin/cc
sudo ln -sfn /usr/bin/g++-9 /usr/bin/g++
sudo ln -sfn /usr/bin/g++-9 /usr/bin/c++
```

d. Install this repository

```
python setup.py develop
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ dependencies:
- stack-data==0.6.2
- tensorboardx==2.6.2.2
- threadpoolctl==3.2.0
- tifffile==2023.8.30
- tqdm==4.66.1
- traitlets==5.9.0
- tzdata==2023.3
Expand Down
4 changes: 3 additions & 1 deletion tools/create_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (c) OpenMMLab. All rights reserved.
import os, sys
sys.path.append(os.getcwd())
import argparse
from os import path as osp

Expand Down Expand Up @@ -35,8 +37,8 @@ def coda_data_prep(root_path,
split=split,
channels=channels
)
print("CODa Split= {} Length = {}".format(split, len(converter)))
converter.convert()
print("length dataset ", len(converter))

parser = argparse.ArgumentParser(description='Data converter arg parser')
parser.add_argument('dataset', metavar='coda', help='name of the dataset')
Expand Down
33 changes: 25 additions & 8 deletions tools/data_converter/coda_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ def __init__(self,
'cam1': 1,
'os1': 2
}
# CODA Camera to KITTI Camera
# 0 is 2
# 1 is 3
# 2 is assumed 4
self.coda_to_kitti_id = {
0: 2,
1: 3,
2: 4
}

# Used to downsample lidar vertical channels
self.channels = channels
Expand All @@ -232,7 +241,7 @@ def process_metadata(self):
label_list = meta_json["ObjectTracking"][self.split]
self.bbox_label_files.extend(label_list)

lidar_list = [label_path.replace('3d_label', '3d_raw').replace('.json', '.bin')
lidar_list = [label_path.replace('3d_label', '3d_comp').replace('.json', '.bin')
for label_path in label_list]
self.lidar_files.extend(lidar_list)

Expand Down Expand Up @@ -285,10 +294,10 @@ def get_filename_info(filename):
@staticmethod
def set_filename_by_prefix(modality, sensor_name, trajectory, frame):
if "2d_rect"==modality:
filetype = "jpg" # change to jpg later
filetype = "png" # change to jpg later
elif "2d_bbox"==modality:
filetype = "txt"
elif "3d_raw"==modality:
elif "3d_comp"==modality or "3d_raw"==modality:
filetype = "bin"
elif "3d_bbox"==modality:
filetype = "json"
Expand Down Expand Up @@ -381,7 +390,7 @@ def save_image(self, traj, src_img_path, cam_id, frame_idx, file_idx):
frame_idx (int): Current frame index.
"""
assert isfile(src_img_path), "Image file does not exist: %s" % src_img_path
kitti_img_path = f'{self.image_save_dir}{str(cam_id)}/' + \
kitti_img_path = f'{self.image_save_dir}{str(self.coda_to_kitti_id[cam_id])}/' + \
f'{str(traj).zfill(2)}{str(frame_idx).zfill(5)}.jpg'
shutil.copyfile(src_img_path, kitti_img_path)

Expand Down Expand Up @@ -424,10 +433,18 @@ def save_calib(self, traj, frame_idx, file_idx):
for cam_id in self.cam_ids:
calib_context += 'P' + str(cam_id) + ': ' + \
' '.join(camera_calibs[cam_id]) + '\n'
# Also map cam_id to KITTI camera ids
for cam_id in self.cam_ids:
calib_context += 'P' + str(self.coda_to_kitti_id[cam_id]) + ': ' + \
' '.join(camera_calibs[cam_id]) + '\n'
calib_context += 'R0_rect' + ': ' + ' '.join(R0_rect) + '\n'
for cam_id in self.cam_ids:
calib_context += 'Tr_velo_to_cam_' + str(cam_id) + ': ' + \
' '.join(Tr_os1_to_cams[cam_id]) + '\n'
if cam_id == 0:
calib_context += 'Tr_velo_to_cam' + ': ' + \
' '.join(Tr_os1_to_cams[cam_id]) + '\n'
else:
calib_context += 'Tr_velo_to_cam_' + str(cam_id) + ': ' + \
' '.join(Tr_os1_to_cams[cam_id]) + '\n'

with open(
f'{self.calib_save_dir}/' +
Expand All @@ -442,7 +459,7 @@ def save_lidar(self, traj, frame_idx, file_idx, channels=128):
traj (int): Current trajectory index.
frame_idx (int): Current frame index.
"""
bin_file = self.set_filename_by_prefix("3d_raw", "os1", traj, frame_idx)
bin_file = self.set_filename_by_prefix("3d_comp", "os1", traj, frame_idx)
bin_path = join(self.load_dir, "3d_raw", "os1", traj, bin_file)
assert isfile(bin_path), "Bin file for traj %s frame %s does not exist: %s" % (traj, frame_idx, bin_path)
point_cloud = np.fromfile(bin_path, dtype=np.float32).reshape(-1, 4)
Expand Down Expand Up @@ -554,7 +571,7 @@ def save_label(self, traj, cam_id, frame_idx, file_idx):
line_all = line[:-1] + '\n'

fp_label = open(
f'{self.label_save_dir}{cam_id}/' +
f'{self.label_save_dir}{self.coda_to_kitti_id[cam_id]}/' +
f'{str(traj).zfill(2)}{str(frame_idx).zfill(5)}.txt', 'a')
fp_label.write(line)
fp_label.close()
Expand Down
Loading