Skip to content

Repository files navigation

SuperVINS-DPL: Deep Learning Enhanced Visual-Inertial Navigation System

License: GPL-3.0 Platform C++ CMake

项目简介

SuperVINS-DPL 是一个基于深度学习的实时视觉惯性导航系统(VINS),它结合了传统几何视觉与现代深度学习特征提取技术。该项目在原始 SuperVINS 架构基础上,集成了 SuperPointDISK 深度学习特征检测与描述算法,显著提高了特征提取的鲁棒性和匹配精度。

核心特性

  • 双模式特征提取:支持传统几何方法(FAST + BRIEF)和深度学习方法(SuperPoint/DISK)
  • 单目/双目/RGB-D 支持:兼容多种相机配置
  • 紧耦合 VIO 融合:基于滑动窗口的视觉-惯性紧耦合优化
  • 实时回环检测:使用 DBoW3 词袋模型进行位置识别
  • 位姿图优化:检测到回环时自动执行全局优化
  • 跨平台支持:支持 Windows 和 Linux 系统
  • ONNX Runtime 推理:使用 ONNX Runtime 进行高效的深度学习推理

系统架构

┌─────────────────────────────────────────────────────────────┐
│                    SuperVINS-DPL System                      │
├─────────────────────────────────────────────────────────────┤
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────┐  │
│  │  Image Input │  │  IMU Input   │  │  Camera Models   │  │
│  └──────┬───────┘  └──────┬───────┘  └────────┬─────────┘  │
│         │                 │                    │            │
│  ┌──────▼─────────────────▼────────────────────▼─────────┐  │
│  │           Feature Tracking Module                      │  │
│  │  ┌────────────────┐         ┌──────────────────────┐  │  │
│  │  │ Traditional    │   OR    │  Deep Learning (DPL) │  │  │
│  │  │ (FAST+BRIEF)   │         │  (SuperPoint/DISK)   │  │  │
│  │  └────────────────┘         └──────────────────────┘  │  │
│  └──────────────────────────┬────────────────────────────┘  │
│                             │                               │
│  ┌──────────────────────────▼────────────────────────────┐  │
│  │           Estimator Module (Sliding Window)            │  │
│  │  - IMU Preintegration                                 │  │
│  │  - Visual Measurement Factors                          │  │
│  │  - Marginalization                                     │  │
│  └──────────────────────────┬────────────────────────────┘  │
│                             │                               │
│  ┌──────────────────────────▼────────────────────────────┐  │
│  │           Loop Closure Detection                       │  │
│  │  - DBoW3 Bag-of-Words                                  │  │
│  │  - Geometric Verification                              │  │
│  │  - Pose Graph Optimization                             │  │
│  └──────────────────────────┬────────────────────────────┘  │
│                             │                               │
│  ┌──────────────────────────▼────────────────────────────┐  │
│  │           Output: 6-DoF Pose & Trajectory              │  │
│  └───────────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────┘

环境依赖

必需依赖

依赖库 版本 说明
CMake >= 3.14 构建系统
C++ 编译器 C++17 支持 MSVC 2019+ / GCC 7+
Eigen3 3.4.0 线性代数库
OpenCV 4.6.0 计算机视觉库
Ceres Solver 2.1.0 非线性优化库
ONNX Runtime 1.16.3 深度学习推理引擎
glog 0.6.0+ 日志库

可选依赖

依赖库 用途
Boost 用于 DBoW3(可用 std 替代)
ROS/ROS2 机器人操作系统(可选,用于消息传递)

Windows 环境配置

在 Windows 上,推荐使用 C:\ThirdParty 目录安装所有第三方库:

C:\ThirdParty\
├── Eigen3_3.4.0\
├── opencv4.6.0+vs2019\
├── Ceres2.1.0_nocuda_nosparse\
├── onnxruntime-win-x64-gpu-1.16.3\
└── glog\

安装与编译

1. 克隆仓库

git clone https://github.com/<your-username>/SuperVINS-DPL.git
cd SuperVINS-DPL

2. 安装依赖

Windows (使用 vcpkg 或手动安装)

# 使用 vcpkg 安装依赖(推荐)
vcpkg install eigen3 opencv4 ceres-suitesparse glog onnxruntime

# 或手动下载各库并放置到 C:\ThirdParty

Ubuntu Linux

# 安装系统依赖
sudo apt-get update
sudo apt-get install -y \
    cmake \
    libeigen3-dev \
    libopencv-dev \
    libceres-dev \
    libgoogle-glog-dev \
    libboost-all-dev

# 安装 ONNX Runtime
# 从 https://github.com/microsoft/onnxruntime/releases 下载并解压

3. 准备深度学习模型

下载预训练的 ONNX 模型并放置到 weights_dpl 目录:

mkdir -p weights_dpl
cd weights_dpl

# 下载 SuperPoint 模型
wget https://example.com/superpoint.onnx

# 下载 DISK 模型(可选)
wget https://example.com/disk.onnx

4. 编译项目

Windows

# 使用提供的批处理脚本
build_windows.bat

# 或手动编译
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -A x64
cmake --build . --config Release

Linux

# 使用提供的脚本
./build_ubuntu.sh

# 或手动编译
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)

使用方法

基本用法

# Windows
build\Release\supervins.exe <config_file> <input_bag_or_dir>

# Linux
./build/supervins <config_file> <input_bag_or_dir>

配置文件说明

配置文件位于 config/ 目录,主要参数包括:

# 相机配置
cam0_calib: "cam0.yaml"
cam1_calib: "cam1.yaml"  # 双目配置

# 特征提取配置
feature_tracker:
  # 选择特征提取方法: "traditional" 或 "deep"
  method: "deep"
  
  # 深度学习模型路径
  superpoint_model: "weights_dpl/superpoint.onnx"
  disk_model: "weights_dpl/disk.onnx"
  
  # 特征点参数
  max_cnt: 300          # 最大特征点数量
  min_dist: 20          # 最小像素距离
  tracking_min_cnt: 50  # 最小追踪数量

# IMU 配置
imu: 1                  # 0: 纯视觉, 1: 视觉+惯性
imu_topic: "/imu0"
acc_n: 0.08             # 加速度计噪声
gyr_n: 0.004            # 陀螺仪噪声
acc_w: 0.00004          # 加速度计偏置随机游走
gyr_w: 0.000006         # 陀螺仪偏置随机游走

# 外参标定
extrinsicTrans: [0.0, 0.0, 0.0]
extrinsicRot: [1, 0, 0, 0, 1, 0, 0, 0, 1]

# 回环检测
loop_closure:
  enable: 1
  vocab_file: "vocab.txt"
  min_score: 0.05       # 最小回环分数

运行示例

1. 使用 EuRoC 数据集

# 下载 EuRoC MH_01 数据集
# https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets

# 运行 SuperVINS
./build/supervins config/euroc/euroc_stereo_imu_config.yaml /path/to/mh_01_easy/mav0/

2. 使用单目 + IMU

./build/supervins config/euroc/euroc_mono_imu_config.yaml /path/to/dataset/

3. 仅使用视觉(无 IMU)

./build/supervins config/euroc/euroc_stereo_config.yaml /path/to/dataset/

输出结果

系统会输出以下结果:

  • 轨迹文件/tmp/vins_result/trajectory.txt

    timestamp tx ty tz qx qy qz qw
    
  • 可视化(如果启用):

    • 特征追踪图像
    • 3D 轨迹
    • 回环连接可视化

代码结构

SuperVINS-DPL/
├── config/                     # 配置文件
│   ├── euroc/                 # EuRoC 数据集配置
│   └── tum/                   # TUM 数据集配置
│
├── src/
│   ├── estimator/             # 核心估计器
│   │   ├── estimator.cpp      # 主估计器实现
│   │   ├── parameters.cpp     # 参数管理
│   │   └── feature_manager.cpp # 特征管理器
│   │
│   ├── feature_tracker/       # 特征追踪模块
│   │   ├── feature_tracker.cpp       # 传统特征追踪
│   │   ├── feature_tracker_dpl.cpp   # 深度学习特征追踪
│   │   └── extractor_matcher_dpl.cpp # 特征提取与匹配
│   │
│   ├── factor/                # 优化因子
│   │   ├── projectionTwoFrameOneCamFactor.cpp   # 单目投影因子
│   │   ├── projectionTwoFrameTwoCamFactor.cpp   # 双目投影因子
│   │   ├── pose_local_parameterization.cpp      # 位姿参数化
│   │   └── marginalization_factor.cpp           # 边缘化因子
│   │
│   ├── initial/               # 初始化模块
│   │   ├── initial_aligment.cpp   # 视觉-惯性对齐
│   │   ├── initial_sfm.cpp        # 运动恢复结构
│   │   └── solve_5pts.cpp         # 5点法本质矩阵求解
│   │
│   ├── loop_fusion/           # 回环检测模块(待完善)
│   │   ├── keyframe.cpp       # 关键帧管理
│   │   ├── pose_graph.cpp     # 位姿图优化
│   │   └── ThirdParty/        # DBoW3 等第三方库
│   │
│   ├── camera_models/         # 相机模型
│   │   └── camera_models/
│   │       ├── PinholeCamera.cc
│   │       └── CataCamera.cc
│   │
│   └── utility/               # 工具函数
│       └── utility.cpp
│
├── include/                   # 头文件
├── weights_dpl/               # 深度学习模型权重
├── cmake/                     # CMake 模块
├── CMakeLists.txt             # CMake 构建配置
├── build_windows.bat          # Windows 构建脚本
├── build_ubuntu.sh            # Linux 构建脚本
└── README.md                  # 本文档

深度学习特征提取模块

SuperPoint 特征检测器

SuperPoint 是一个自监督训练的深度学习模型,能够同时检测兴趣点并计算描述子。

优势

  • 对光照变化、运动模糊更具鲁棒性
  • 在纹理稀少区域也能提取稳定特征
  • 重复检测率高,特征分布均匀

使用方式

feature_tracker:
  method: "deep"
  superpoint_model: "weights_dpl/superpoint.onnx"
  max_cnt: 300

DISK 特征描述子

DISK(Differentiable Keypoint and Descriptor)是一个端到端的深度学习特征提取器。

优势

  • 描述子更具判别性
  • 匹配准确率更高
  • 支持亚像素级精度

特征匹配流程

Input Images
    │
    ▼
┌───────────────┐
│  ONNX Model   │  ← SuperPoint/DISK
│  Inference    │
└───────┬───────┘
        │
        ▼
┌───────────────┐
│  Keypoint     │  ← 提取特征点
│  Detection    │
└───────┬───────┘
        │
        ▼
┌───────────────┐
│  Descriptor   │  ← 计算描述子
│  Extraction   │
└───────┬───────┘
        │
        ▼
┌───────────────┐
│  Feature      │  ← 帧间匹配
│  Matching     │
└───────┬───────┘
        │
        ▼
┌───────────────┐
│  Outlier      │  ← RANSAC 过滤
│  Rejection    │
└───────┬───────┘
        │
        ▼
  Output Matches

双目视觉惯性导航系统工作原理

1. 系统概述

SuperVINS-DPL 实现了一个紧耦合的视觉惯性导航系统,通过将相机图像与 IMU 测量值融合,实现鲁棒且精确的 6-DoF 位姿估计。

2. 核心组件

视觉前端

  • 特征提取:使用 SuperPoint/DISK 或传统方法提取特征点
  • 特征追踪:使用光流法进行帧间追踪
  • 立体匹配:双目相机之间的特征匹配
  • 三角化:从立体匹配中恢复 3D 点

IMU 预积分

  • 预积分理论:在两帧之间对 IMU 测量值进行积分
  • 偏置估计:在线估计加速度计和陀螺仪偏置
  • 协方差传播:追踪预积分测量的不确定性

紧耦合优化

  • 滑动窗口:维护最近 N 帧的滑动窗口
  • 联合优化:同时优化视觉残差和 IMU 残差
  • 边缘化:移除旧帧以保持计算效率

3. 状态估计

系统状态向量包括:

X = [x_0, x_1, ..., x_n, x_c, λ_0, λ_1, ..., λ_m]

其中:
x_k = [p_wb_k, v_wb_k, q_wb_k, b_a, b_g]  # IMU 状态
  - p_wb_k: 世界坐标系下的位置
  - v_wb_k: 世界坐标系下的速度
  - q_wb_k: 世界坐标系下的旋转四元数
  - b_a: 加速度计偏置
  - b_g: 陀螺仪偏置

x_c = [p_b_c, q_b_c]  # 相机-IMU 外参
λ_l: 第 l 个逆深度特征

4. 优化残差

IMU 残差

r_I(z_{k+1}^k, X) = [r_p, r_q, r_v, r_ba, r_bg]

视觉残差

r_C(z_l^c, X) = [u - proj(P_c), v - proj(P_c)]

目标函数

X* = argmin { ||r_p - μ_p||^2 + Σ ||r_I||^2 + Σ ||r_C||^2 }
           MAP      k        l

5. 初始化流程

  1. 纯视觉 SfM:使用运动恢复结构初始化
  2. 视觉-惯性对齐:估计尺度、重力方向和速度
  3. 联合优化:启动完整的紧耦合优化

已知问题和限制

  1. loop_fusion 模块:Windows 平台的回环检测模块暂时禁用,需要进一步修复 VLA 和 ROS 依赖问题
  2. GPU 加速:当前版本使用 CPU 推理,GPU 加速需要额外配置
  3. 实时性能:深度学习特征提取可能影响实时性能,建议根据硬件调整参数

未来改进计划

  • 完成 loop_fusion 模块的 Windows 兼容性
  • 添加 TensorRT 推理加速支持
  • 支持更多深度学习模型(如 ALIKE, KeyPointNet)
  • 改进初始化流程的鲁棒性
  • 添加在线外参标定

许可证

本项目基于 GNU General Public License v3.0 发布。详见 LICENSE 文件。

引用

如果您在研究中使用此代码,请引用原始 VINS 论文:

@article{qin2018vins,
  title={VINS-Mono: A Robust and Versatile Monocular Visual-Inertial State Estimator},
  author={Qin, Tong and Li, Peiliang and Shen, Shaojie},
  journal={IEEE Transactions on Robotics},
  volume={34},
  number={4},
  pages={1004--1020},
  year={2018},
  publisher={IEEE}
}

@article{qin2019vins,
  title={VINS-Fusion: A Flexible Optimization Framework for Vision-Inertial-Lidar Odometry and Mapping},
  author={Qin, Tong and Cao, Shangjie and Pan, Jiarong and Shen, Shaojie},
  journal={IEEE Robotics and Automation Letters},
  year={2019},
  publisher={IEEE}
}

如果您使用了深度学习特征提取模块,也请引用相应的论文:

@inproceedings{detone2018superpoint,
  title={SuperPoint: Self-supervised interest point detection and description},
  author={DeTone, Daniel and Malisiewicz, Tomasz and Rabinovich, Andrew},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops},
  pages={224--236},
  year={2018}
}

@inproceedings{tonioni2021real,
  title={Real-time self-supervised deep visual features for robotics},
  author={Tonioni, Alessio and Tosi, Fabio and Poggi, Matteo and Mattoccia, Stefano and Di Stefano, Luigi},
  booktitle={IEEE Robotics and Automation Letters},
  year={2021}
}

贡献

欢迎提交 Issue 和 Pull Request!

  1. Fork 本仓库
  2. 创建您的特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交您的更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 开启一个 Pull Request

联系方式

致谢


注意: 本项目仅用于学术研究和教育目的。

About

Deep Learning Enhanced Visual-Inertial Navigation System with SuperPoint/DISK feature extraction without ros

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages