Skip to content

[ICRA'23] DytanVO: Visual Odometry in Dynamic Environments

License

Notifications You must be signed in to change notification settings

castacks/DytanVO

Repository files navigation

DytanVO: Joint Refinement of Visual Odometry and Motion Segmentation in Dynamic Environments

DytanVO: Joint Refinement of Visual Odometry and Motion Segmentation in Dynamic Environments (ICRA 2023)
By Shihao Shen, Yilin Cai, Wenshan Wang, and Sebastian Scherer.

What's new.

  • 01-17-2023: Our paper has been accepted to ICRA 2023!

  • 01-05-2023: Clean up and upload the codebase for DytanVO. Pretrained weights and datasets are also ready.

  • 09-20-2022: Remove Dynamic Dense RGB-D SLAM with Learning-Based Visual Odometry. The repo will be used to release codebase for the most recent ICRA 2023 submission.

Introduction

DytanVO is a learning-based visual odometry (VO) based on its precursor, TartanVO. It is the first supervised learning-based VO method that deals with dynamic environments. It takes two consecutive monocular frames in real-time and predicts camera ego-motion in an iterative fashion. It achieves an average improvement of 27.7% over state-of-the-art VO solutions in real-world dynamic environments, and even performs competitively among dynamic visual SLAM systems which optimize the trajectory on the backend. Experiments on plentiful unseen environments also demonstrate its generalizability.

Installation

We provide an environment file using anaconda. The code has been tested on an RTX 2080Ti with CUDA 11.4.

conda env create -f environment.yml
conda activate dytanvo

Compile DCNv2.

cd Network/rigidmask/networks/DCNv2/; python setup.py install; cd -

Models and Data

Pretrained weights

Download here and unzip it to the models folder.

KITTI dynamic sequences

Original sequences in KITTI Odometry are trimmed into sub-sequences which contain moving pedestrians, vehicles and cyclists so that VO's robustness to dynamic objects can be explicitly evaluated. Download DynaKITTI and unzip it to the data folder. Please cite this paper if you find it useful in your work.

AirDOS-Shibuya

Follow tartanair-shibuya and download it to the data folder.

(Optional) Scene Flow

One can also test the model on Scene Flow datasets, which was used to train both the VO and the segmentation networks. Scene Flow datasets have very challenging sequences with large areas of dynamic objects in image frames.

You can create symbolic links to wherever the datasets were downloaded in the data folder.

├── data
    ├── AirDOS_shibuya
        ├── RoadCrossing03
            ├── image_0
            ├── ...
            ├── gt_pose.txt
        ├── RoadCrossing04
        ├── ...
    ├── DynaKITTI
        ├── 00_1
            ├── image_2
            ├── ...
            ├── pose_left.txt
            ├── calib.txt
        ├── 01_0
        ├── ...
    ├── SceneFlow
        ├── FlyThings3D
            ├── frames_cleanpass
            ├── frames_finalpass
            ├── optical_flow
            ├── camera_data
        ├── Driving
        ├── Monkaa
    ├── ...

Evaluation

Create a folder to save output flow, segmentation, or poses.

mkdir results

Dynamic sequences in KITTI (loading the finetuned VO model at once)

traj=00_1
python -W ignore::UserWarning vo_trajectory_from_folder.py --vo-model-name vonet_ft.pkl  \
							   --seg-model-name segnet-kitti.pth  \
							   --kitti --kitti-intrinsics-file data/DynaKITTI/$traj/calib.txt  \
							   --test-dir data/DynaKITTI/$traj/image_2  \
							   --pose-file data/DynaKITTI/$traj/pose_left.txt 

AirDOS-Shibuya (loading FlowNet and PoseNet separately)

traj=RoadCrossing03
python -W ignore::UserWarning vo_trajectory_from_folder.py --flow-model-name flownet.pkl  \
							   --pose-model-name posenet.pkl  \
							   --seg-model segnet-sf.pth  \
							   --airdos  \
							   --test-dir data/AirDOS_shibuya/$traj/image_0  \
							   --pose-file data/AirDOS_shibuya/$traj/gt_pose.txt 

Scene Flow

img=Driving/frames_finalpass/15mm_focallength/scene_forwards/fast/left
pose=Driving/camera_data/15mm_focallength/scene_forwards/fast/camera_data.txt
python -W ignore::UserWarning vo_trajectory_from_folder.py --flow-model-name flownet.pkl  \
							   --pose-model-name posenet.pkl  \
							   --seg-model segnet-sf.pth  \
							   --sceneflow  \
							   --test-dir data/SceneFlow/$img  \
							   --pose-file data/SceneFlow/$pose

Add --save-flow tag to save intermediate optical flow outputs into the results folder.

Adjust the batch size and the worker number by --batch-size 10, --worker-num 5.

(Optional) Segmentation Mask Ground Truth

If your dataset has ground truth for camera motion, optical flow and disparity change across consecutive frames, we provide an example script to automatically generate ground truth of segmentation mask given these two modalities based on the pure geometry for the Scene Flow datasets.

python Datasets/segmask_gt.py --database data/SceneFlow --frames_pass clean --dataset FlyingThings3D

Add --debug flag to save visualizations of the generated masks.

Citation

If you find our code, paper or dataset useful, please cite

@inproceedings{shen2023dytanvo,
  title={Dytanvo: Joint refinement of visual odometry and motion segmentation in dynamic environments},
  author={Shen, Shihao and Cai, Yilin and Wang, Wenshan and Scherer, Sebastian},
  booktitle={2023 IEEE International Conference on Robotics and Automation (ICRA)},
  pages={4048--4055},
  year={2023},
  organization={IEEE}
}

Acknowledgement

We built DytanVO on top of TartanVO. We implemented the segmentation network by adapting rigidmask. We thank Gengshan Yang for his code and suggestions.

License

This software is BSD licensed.

Copyright (c) 2020, Carnegie Mellon University All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.