Ubuntu18.04 VINS-FUSION OpenCV4适配.

VINS-FUSION 运行


相关链接:

卷帘快门(Rolling Shutter)与全局快门(Global Shutter)的区别


content


全局快门(Global Shutter, GS)和卷帘快门(Rolling Shutter, RS)是两种常见的CMOS传感器快门技术。它们的不同之处主要在于曝光方式,从而影响了成像效果及在实际应用中的适用性,特别是在SLAM(Simultaneous Localization and Mapping,即同时定位与建图)系统中有各自的优缺点。

一. 全局快门和卷帘快门的区别{#全局快门和卷帘快门的区别}

曝光方式:

全局快门:

传感器的所有像素在同一时刻同时曝光。这样生成的图像不会因运动而产生形变。

卷帘快门:

像素按行或列逐行依次曝光,通常是从上到下逐行读取,因此不同时刻的像素曝光会存在时间差。这种逐行读取方式容易在相机或物体运动时产生变形。

图像失真:

全局快门:

即使在高速运动情况下也能捕捉无形变的图像。

卷帘快门:

在运动中易出现“果冻效应”,即直线物体可能会变成弯曲的形状。此外,也可能导致旋转和倾斜物体的变形(如倾斜的水平线)。


查看OpenCV版本

opencv_version -v

General configuration for OpenCV 4.4.0 =====================================
  Version control:               unknown

  Platform:
    Timestamp:                   2024-10-23T04:11:48Z
    Host:                        Linux 4.15.0-213-generic x86_64
    CMake:                       3.10.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release
...

错误一:

  • CV4版本差异,需要修改宏定义

    CV_LOAD_IMAGE_GRAYSCALE修改为cv::IMREAD_GRAYSCALE

/home/dji/VINS_ws/src/VINS-Fusion/vins_estimator/src/KITTIOdomTest.cpp: In function ‘int main(int, char**)’:
/home/dji/VINS_ws/src/VINS-Fusion/vins_estimator/src/KITTIOdomTest.cpp:95:39: error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
    imLeft = cv::imread(leftImagePath, CV_LOAD_IMAGE_GRAYSCALE );
                                       ^~~~~~~~~~~~~~~~~~~~~~~
/home/dji/VINS_ws/src/VINS-Fusion/vins_estimator/src/KITTIGPSTest.cpp: In function ‘int main(int, char**)’:
/home/dji/VINS_ws/src/VINS-Fusion/vins_estimator/src/KITTIGPSTest.cpp:122:39: error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
    imLeft = cv::imread(leftImagePath, CV_LOAD_IMAGE_GRAYSCALE );
                                       ^~~~~~~~~~~~~~~~~~~~~~~
  • 修改完后,编译成功,存在警告,警告表明系统中有两个不同版本的OpenCV库,它们之间存在冲突,这里不影响
#继续编译
catkin_make -j4
 
...
[100%] Linking CXX executable /home/dji/VINS_ws/devel/lib/vins/kitti_gps_test
/usr/bin/ld: warning: libopencv_core.so.4.4, needed by /home/dji/VINS_ws/devel/lib/libvins_lib.so, may conflict with libopencv_core.so.3.2
/usr/bin/ld: warning: libopencv_imgcodecs.so.3.2, needed by /opt/ros/melodic/lib/libcv_bridge.so, may conflict with libopencv_imgcodecs.so.4.4
[100%] Built target kitti_gps_test

更新工作空间源

source devel/setup.bash

修改输出目录– **config 目录下所有子模块的–** xxx_config.yaml

根据使用需求修改对应的文件夹下的xxx_config.yaml

cd catkin_ws/src/VINS-Fusion/config/[对应文件夹下的xxx_config.yaml]
#xxx_config.yaml
%YAML:1.0
imu: 0         
num_of_cam: 2  

imu_topic: "/imu0"
image0_topic: "/cam0/image_raw"
image1_topic: "/cam1/image_raw"
#修改输出目录
output_path: /home/dji/VINS_ws/src/VINS-Fusion/outputs
...