(Dual system GPU version) DynaSLAM super detailed installation configuration running ubantu20.0.4+opencv2.4.11+tensorflow-gpu1.14.0

(Dual system GPU version) DynaSLAM super detailed installation configuration running ubantu20.0.4+opencv2.4.11+tensorflow-gpu1.14.0

The following link is the cpu version tutorial installed on the virtual machine before:
DynaSLAM ultra-detailed installation configuration running ubantu20.0.4+opencv2.4.11+tensorflow1.4.0

1. Install Anaconda

Reference: Install Anaconda

2. Install the boost library

sudo apt-get install libboost-all-dev

3. Download DynaSLAM source code and mask_rcnn_coco.h5

3.1 Download DynaSLAM source code

git clone https://github.com/BertaBescos/DynaSLAM.git

3.2 Download mask_rcnn_coco.h5

注:找不到的拉到页面的最下面。

insert image description here

Fourth, use Anaconda to configure Python-related environments

4.1 Configure the Anaconda environment

Here first Anacondacreate a new virtual environment and activate it, and then install tensorflowand in turn in the virtual environment keras.
PS: 我已经安装了cuda11.4: ubuntu20.04, GeForce RTX 3060, CUDA Version: 11.4 install cuda

conda create -n DynaSLAM python=2.7  
conda activate DynaSLAM
pip install tensorflow-gpu==1.14.0
pip install keras==2.0.9
pip install h5py==2.10.0
pip install numpy==1.16.6
pip install pillow==6.2.2 
pip install pycocotools==2.0.3
pip install scikit-image==0.14.5
sudo apt-get install libcanberra-gtk-module 

I later configured a conda environment ( MASKRCNN) usingconda create -n MASKRCNN python=2.7.18

PS:If it is installed scikit-imagebut cannot be found conda listafter scikit-image, you can try to close the condaenvironment and reactivate the environment.

conda deactivate
conda activate DynaSLAM

If the download is slow, you can try to add Tsinghua Mirror

  • Step 1: Add Anaconda’s Tsinghua mirror.
    Anaconda’s default download sources for various packages are all abroad. The download speed is slow and often interrupted. Therefore, it is necessary to configure the mirror installed in China, so that the download speed is very fast.
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  • Step 2: Display the channel address when setting the search
conda config --set show_channel_urls yes 

conda configNote: A configuration file will be generated for the first run anacnoda. This configuration file is the same as the jupyter configuration file and does not exist by default. WindowsThe default location for is C://Users/username/.condarc, Linux/Macfor ~/.condarc.

  • Step 3: Update the source of pip
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
  • View current download source
(yolact) cgm:~$ conda config --show channels                                                                                                                                                                                
channels:                                                                                                                                                                                                                       
 - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/                                                                                                                                                                 
 - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/                                                                                                                                                             
 - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/                                                                                                                                                                   
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2                                                                                                                                                                    
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro                                                                                                                                                                      
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r                                                                                                                                                                        
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                                                                                                                                                                     
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main                                                                                                                                                                     
 - defaults  

After adding the above image, the original source still exists, and the file -defaultsis the original source.

  • Clear all added download sources
    When we want to switch back to Anaconda’s default download source, just remove the previously set ones:
conda config --remove-key channels

4.2 The following is a screenshot of the installation

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

4. Test the Mask R-CNN environment

4.1 Test Mask R-CNN environment

前提:Activate the conda environment, cd to DynaSLAM, and run the following command

python src/python/Check.py

If the output is Mask R-CNN is correctly working, you can go to the next step.
insert image description here
insert image description here
PS:If it is installed scikit-image, an error is reported during the test ImportError: No module named skimage.io, and it cannot be found conda listafter scikit-image, you can try to close the conda environment and reactivate the environment.

conda deactivate DynaSLAM
conda activate DynaSLAM

4.2, the corresponding dependent version

(DynaSLAM) cgm@cgm:~$ conda list
# packages in environment at /home/cgm/anaconda3/envs/DynaSLAM:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
_openmp_mutex             4.5                       2_gnu    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
absl-py                   0.15.0                   pypi_0    pypi
astor                     0.8.1                    pypi_0    pypi
backports-functools-lru-cache 1.6.4                    pypi_0    pypi
backports-weakref         1.0.post1                pypi_0    pypi
ca-certificates           2022.12.7            ha878542_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
certifi                   2016.9.26                py27_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
cloudpickle               1.3.0                    pypi_0    pypi
cycler                    0.10.0                   pypi_0    pypi
cython                    0.29.33                  pypi_0    pypi
decorator                 4.4.2                    pypi_0    pypi
enum34                    1.1.10                   pypi_0    pypi
funcsigs                  1.0.2                    pypi_0    pypi
futures                   3.4.0                    pypi_0    pypi
gast                      0.5.3                    pypi_0    pypi
google-pasta              0.2.0                    pypi_0    pypi
grpcio                    1.41.1                   pypi_0    pypi
h5py                      2.10.0                   pypi_0    pypi
keras                     2.0.9                    pypi_0    pypi
keras-applications        1.0.8                    pypi_0    pypi
keras-preprocessing       1.1.2                    pypi_0    pypi
kiwisolver                1.1.0                    pypi_0    pypi
ld_impl_linux-64          2.40                 h41732ed_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libffi                    3.2.1             he1b5a44_1007    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libgcc-ng                 12.2.0              h65d4601_19    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libgomp                   12.2.0              h65d4601_19    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libsqlite                 3.40.0               h753d276_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libstdcxx-ng              12.2.0              h46fd767_19    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libzlib                   1.2.13               h166bdaf_4    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
markdown                  3.1.1                    pypi_0    pypi
matplotlib                2.2.5                    pypi_0    pypi
mock                      3.0.5                    pypi_0    pypi
ncurses                   6.3                  h27087fc_1    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
networkx                  2.2                      pypi_0    pypi
numpy                     1.16.6                   pypi_0    pypi
openssl                   1.1.1t               h0b41bf4_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pillow                    6.2.2                    pypi_0    pypi
pip                       20.0.2                   py27_1    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
protobuf                  3.17.3                   pypi_0    pypi
pycocotools               2.0.3                    pypi_0    pypi
pyparsing                 2.4.7                    pypi_0    pypi
python                    2.7.15          h5a48372_1011_cpython    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
python-dateutil           2.8.2                    pypi_0    pypi
python_abi                2.7                    1_cp27mu    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pytz                      2022.7.1                 pypi_0    pypi
pywavelets                1.0.3                    pypi_0    pypi
pyyaml                    5.4.1                    pypi_0    pypi
readline                  8.2                  h8228510_1    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
scikit-image              0.14.5                   pypi_0    pypi
scipy                     1.2.3                    pypi_0    pypi
setuptools                44.1.1                   pypi_0    pypi
six                       1.16.0                   pypi_0    pypi
sqlite                    3.40.0               h4ff8645_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
subprocess32              3.5.4                    pypi_0    pypi
tensorboard               1.14.0                   pypi_0    pypi
tensorflow-estimator      1.14.0                   pypi_0    pypi
tensorflow-gpu            1.14.0                   pypi_0    pypi
termcolor                 1.1.0                    pypi_0    pypi
tk                        8.6.12               h27826a3_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
werkzeug                  1.0.1                    pypi_0    pypi
wheel                     0.34.2                   py27_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
wrapt                     1.15.0                   pypi_0    pypi
zlib                      1.2.13               h166bdaf_4    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge

insert image description here

Five, install OpenCV2.4.11 and OpenCV4.2.0 dual version coexistence

5.1 OpenCV version requirements

ps:有人说:(不是我说的,我没测试OpenCV 3.X)

README.md中写的DynaSLAM 现在支持 OpenCV 2.X 和 OpenCV 3.X。在实测中发现3.4.3版本运行异常,具体原因不知道;根据网上的建议,我重新安装了老版本的OpenCV 2.4.11

Check DynaSLAM's CMakeLists.txt, my computer is OpenCV4.2.0, and now the dual version of OpenCV2.4.11 is installed to coexist.
insert image description here

  • Check your own opencv version
pkg-config opencv --modversion
  • View the command of the opencv4 version:
pkg-config opencv4 --modversion

insert image description here

5.2 Download the installation package

Official website opencv 2.4.11 installation package , click to download , after downloading

注:第三行和 cmake .. 一样,最后有两个点点

  • Prevent errors from being reported as follows:CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:85 (list)
  • Solution: OpenCVDetectCXXCompiler.cmakeReplace the content of the following with the following:
# ----------------------------------------------------------------------------
# Detect Microsoft compiler:
# ----------------------------------------------------------------------------
if(CMAKE_CL_64)
    set(MSVC64 1)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  set(CMAKE_COMPILER_IS_GNUCXX 1)
  set(CMAKE_COMPILER_IS_CLANGCXX 1)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
  set(CMAKE_COMPILER_IS_GNUCC 1)
  set(CMAKE_COMPILER_IS_CLANGCC 1)
endif()
if("${CMAKE_CXX_COMPILER};${CMAKE_C_COMPILER}" MATCHES "ccache")
  set(CMAKE_COMPILER_IS_CCACHE 1)
endif()

# ----------------------------------------------------------------------------
# Detect Intel ICC compiler -- for -fPIC in 3rdparty ( UNIX ONLY ):
#  see  include/opencv/cxtypes.h file for related   ICC & CV_ICC defines.
# NOTE: The system needs to determine if the '-fPIC' option needs to be added
#  for the 3rdparty static libs being compiled.  The CMakeLists.txt files
#  in 3rdparty use the CV_ICC definition being set here to determine if
#  the -fPIC flag should be used.
# ----------------------------------------------------------------------------
if(UNIX)
  if  (__ICL)
    set(CV_ICC   __ICL)
  elseif(__ICC)
    set(CV_ICC   __ICC)
  elseif(__ECL)
    set(CV_ICC   __ECL)
  elseif(__ECC)
    set(CV_ICC   __ECC)
  elseif(__INTEL_COMPILER)
    set(CV_ICC   __INTEL_COMPILER)
  elseif(CMAKE_C_COMPILER MATCHES "icc")
    set(CV_ICC   icc_matches_c_compiler)
  endif()
endif()

if(MSVC AND CMAKE_C_COMPILER MATCHES "icc|icl")
  set(CV_ICC   __INTEL_COMPILER_FOR_WINDOWS)
endif()

# ----------------------------------------------------------------------------
# Detect GNU version:
# ----------------------------------------------------------------------------
if(CMAKE_COMPILER_IS_CLANGCXX)
  set(CMAKE_GCC_REGEX_VERSION "4.2.1")
  set(CMAKE_OPENCV_GCC_VERSION_MAJOR 4)
  set(CMAKE_OPENCV_GCC_VERSION_MINOR 2)
  set(CMAKE_OPENCV_GCC_VERSION 42)
  set(CMAKE_OPENCV_GCC_VERSION_NUM 402)

  execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -v
                  ERROR_VARIABLE CMAKE_OPENCV_CLANG_VERSION_FULL
                  ERROR_STRIP_TRAILING_WHITESPACE)

  string(REGEX MATCH "version.*$" CMAKE_OPENCV_CLANG_VERSION_FULL "${CMAKE_OPENCV_CLANG_VERSION_FULL}")
  string(REGEX MATCH "[0-9]+\\.[0-9]+" CMAKE_CLANG_REGEX_VERSION "${CMAKE_OPENCV_CLANG_VERSION_FULL}")

elseif(CMAKE_COMPILER_IS_GNUCXX)
  execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
                OUTPUT_VARIABLE CMAKE_OPENCV_GCC_VERSION_FULL
                OUTPUT_STRIP_TRAILING_WHITESPACE)

  execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -v
                ERROR_VARIABLE CMAKE_OPENCV_GCC_INFO_FULL
                OUTPUT_STRIP_TRAILING_WHITESPACE)

  # Typical output in CMAKE_OPENCV_GCC_VERSION_FULL: "c+//0 (whatever) 4.2.3 (...)"
  # Look for the version number, major.minor.build
  string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
  if(NOT CMAKE_GCC_REGEX_VERSION)#major.minor
    string(REGEX MATCH "[0-9]+\\.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
  endif()

  if(CMAKE_GCC_REGEX_VERSION)
    # Split the parts:
    string(REGEX MATCHALL "[0-9]+" CMAKE_OPENCV_GCC_VERSIONS "${CMAKE_GCC_REGEX_VERSION}")

    list(GET CMAKE_OPENCV_GCC_VERSIONS 0 CMAKE_OPENCV_GCC_VERSION_MAJOR)
    list(GET CMAKE_OPENCV_GCC_VERSIONS 1 CMAKE_OPENCV_GCC_VERSION_MINOR)
  else()#compiler returned just the major version number
    string(REGEX MATCH "[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
    if(NOT CMAKE_GCC_REGEX_VERSION)#compiler did not return anything reasonable
      set(CMAKE_GCC_REGEX_VERSION "0")
      message(WARNING "GCC version not detected!")
    endif()
    set(CMAKE_OPENCV_GCC_VERSION_MAJOR ${CMAKE_GCC_REGEX_VERSION})
    set(CMAKE_OPENCV_GCC_VERSION_MINOR 0)
  endif()

  set(CMAKE_OPENCV_GCC_VERSION ${CMAKE_OPENCV_GCC_VERSION_MAJOR}${CMAKE_OPENCV_GCC_VERSION_MINOR})
  math(EXPR CMAKE_OPENCV_GCC_VERSION_NUM "${CMAKE_OPENCV_GCC_VERSION_MAJOR}*100 + ${CMAKE_OPENCV_GCC_VERSION_MINOR}")
  message(STATUS "Detected version of GNU GCC: ${CMAKE_OPENCV_GCC_VERSION} (${CMAKE_OPENCV_GCC_VERSION_NUM})")

  if(WIN32)
    execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
              OUTPUT_VARIABLE OPENCV_GCC_TARGET_MACHINE
              OUTPUT_STRIP_TRAILING_WHITESPACE)
    if(OPENCV_GCC_TARGET_MACHINE MATCHES "amd64|x86_64|AMD64")
      set(MINGW64 1)
    endif()
  endif()
endif()

if(MSVC64 OR MINGW64)
  set(X86_64 1)
elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING))
  set(X86 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
  set(X86_64 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*")
  set(X86 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
  set(ARM 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
  set(AARCH64 1)
endif()

# Workaround for 32-bit operating systems on 64-bit x86_64 processor
if(X86_64 AND CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT FORCE_X86_64)
  message(STATUS "sizeof(void) = 4 on x86 / x86_64 processor. Assume 32-bit compilation mode (X86=1)")
  unset(X86_64)
  set(X86 1)
endif()

# Similar code exists in OpenCVConfig.cmake
if(NOT DEFINED OpenCV_STATIC)
  # look for global setting
  if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
    set(OpenCV_STATIC OFF)
  else()
    set(OpenCV_STATIC ON)
  endif()
endif()

if(MSVC)
  if(CMAKE_CL_64)
    set(OpenCV_ARCH x64)
  elseif((CMAKE_GENERATOR MATCHES "ARM") OR ("${arch_hint}" STREQUAL "ARM") OR (CMAKE_VS_EFFECTIVE_PLATFORMS MATCHES "ARM|arm"))
    # see Modules/CmakeGenericSystem.cmake
    set(OpenCV_ARCH ARM)
  else()
    set(OpenCV_ARCH x86)
  endif()
  if(MSVC_VERSION EQUAL 1400)
    set(OpenCV_RUNTIME vc8)
  elseif(MSVC_VERSION EQUAL 1500)
    set(OpenCV_RUNTIME vc9)
  elseif(MSVC_VERSION EQUAL 1600)
    set(OpenCV_RUNTIME vc10)
  elseif(MSVC_VERSION EQUAL 1700)
    set(OpenCV_RUNTIME vc11)
  elseif(MSVC_VERSION EQUAL 1800)
    set(OpenCV_RUNTIME vc12)
  elseif(MSVC_VERSION EQUAL 1900)
    set(OpenCV_RUNTIME vc14)
  elseif(MSVC_VERSION EQUAL 1910)
    set(OpenCV_RUNTIME vc15)
  endif()
elseif(MINGW)
  set(OpenCV_RUNTIME mingw)

  if(MINGW64)
    set(OpenCV_ARCH x64)
  else()
    set(OpenCV_ARCH x86)
  endif()
endif()
  • Prevent errors from being reported as follows:rgbdodometry.cpp:65:12: fatal error: unsupported/Eigen/MatrixFunctions: 没有那个文件或目录
  • Solution: add to the opencv-2.4.11/modules/contrib/src/rgbdodometry.cppline65eigen3
#include <eigen3/unsupported/Eigen/MatrixFunctions>
//或者
#include </usr/include/eigen3/unsupported/Eigen/MatrixFunctions>

5.2 Start compiling and installing

mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv2.4.11 -DENABLE_PRECOMPILED_HEADERS=OFF -D WITH_FFMPEG=OFF -D WITH_CUDA=OFF -D CUDA_nppicom_LIBRARY=stdc++ ..
make -j4
sudo make install

It’s useless to me here cuda: -D WITH_CUDA=OFF
I tried: -D WITH_CUDA=ONor don’t want this command, but there is an error when compiling: CUDA_nppi_LIBRARY (ADVANCED), just forget it if you don’t get it right after a bit of tossing.

insert image description here

insert image description here

cgm@cgm:~/opencv-2.4.11/build$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv2.4.11 -DENABLE_PRECOMPILED_HEADERS=OFF -D WITH_FFMPEG=OFF -D WITH_CUDA=OFF  ..
CMake Deprecation Warning at CMakeLists.txt:47 (cmake_policy):
  The OLD behavior for policy CMP0022 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:52 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Detected version of GNU GCC: 90 (900)
-- Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR) 
-- Found OpenEXR: /usr/lib/x86_64-linux-gnu/libIlmImf.so
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- 
-- General configuration for OpenCV 2.4.11 =====================================
--   Version control:               unknown
-- 
--   Platform:
--     Host:                        Linux 5.15.0-67-generic x86_64
--     CMake:                       3.16.3
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/c++  (ver 9.4.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):
--     Linker flags (Debug):
--     Precompiled headers:         NO
-- 
--   OpenCV modules:
--     To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib python stitching superres ts videostab
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera dynamicuda java viz
-- 
--   GUI: 
--     QT:                          NO
--     GTK+ 2.x:                    YES (ver 2.24.32)
--     GThread :                    YES (ver 2.64.6)
--     GtkGlExt:                    NO
--     OpenGL support:              NO
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.1.0)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2.3.0)
-- 
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  YES (ver 2.2.5)
--     FFMPEG:                      NO
--       codec:                     NO
--       format:                    NO
--       util:                      NO
--       swscale:                   NO
--       gentoo-style:              NO
--     GStreamer:                   
--       base:                      YES (ver 1.16.3)
--       video:                     YES (ver 1.16.3)
--       app:                       YES (ver 1.16.3)
--       riff:                      YES (ver 1.16.3)
--       pbutils:                   YES (ver 1.16.3)
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    Using libv4l1 (ver 1.18.0) / libv4l2 (ver 1.18.0)
--     XIMEA:                       NO
--     Xine:                        NO
-- 
--   Other third-party libraries:
--     Use IPP:                     NO
--     Use Eigen:                   YES (ver 3.3.7)
--     Use TBB:                     NO
--     Use OpenMP:                  NO
--     Use GCD                      NO
--     Use Concurrency              NO
--     Use C=:                      NO
--     Use Cuda:                    NO
--     Use OpenCL:                  YES
-- 
--   OpenCL:
--     Version:                     dynamic
--     Include path:                /home/cgm/opencv-2.4.11/3rdparty/include/opencl/1.2
--     Use AMD FFT:                 NO
--     Use AMD BLAS:                NO
-- 
--   Python:
--     Interpreter:                 /usr/bin/python2 (ver 2.7.18)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.18)
--     numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.5)
--     packages path:               lib/python2.7/dist-packages
-- 
--   Java:
--     ant:                         NO
--     JNI:                         /usr/lib/jvm/java-8-openjdk-amd64/include /usr/lib/jvm/java-8-openjdk-amd64/include/linux /usr/lib/jvm/java-8-openjdk-amd64/include
--     Java tests:                  NO
-- 
--   Documentation:
--     Build Documentation:         NO
--     Sphinx:                      NO
--     PdfLaTeX compiler:           NO
--     Doxygen:                     YES (/usr/bin/doxygen)
-- 
--   Tests and samples:
--     Tests:                       YES
--     Performance tests:           YES
--     C/C++ Examples:              NO
-- 
--   Install path:                  /usr/local/opencv2.4.11
-- 
--   cvconfig.h is in:              /home/cgm/opencv-2.4.11/build
-- -----------------------------------------------------------------
-- 
-- Configuring done
CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library):
  Policy CMP0038 is not set: Targets may not link directly to themselves.
  Run "cmake --help-policy CMP0038" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Target "opencv_haartraining_engine" links to itself.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library):
  Policy CMP0038 is not set: Targets may not link directly to themselves.
  Run "cmake --help-policy CMP0038" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Target "opencv_haartraining_engine" links to itself.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /home/cgm/opencv-2.4.11/build
  • When compiling to 96%, an error is reported:error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
  • Find opencv-2.4.11/build/modules/contrib/CMakeFiles/opencv_contrib.dir/flags.makethe file and 删掉-Werror=address
    insert image description here
    then install it successfully
make -j4
sudo make install

installed here/usr/local/opencv2.4.11

insert image description here

5.3 Add environment variables

sudo gedit ~/.bashrc
//在文件末尾加上下面两行:
export PKG_CONFIG_PATH="/usr/local/opencv2.4.11/lib/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="/usr/local/opencv2.4.11/lib:$LD_LIBRARY_PATH"
//保存之后
//更新环境
source ~/.bashrc
//查看opencv的版本
pkg-config --modversion opencv

When using another version (mine is 4.2.0), the same terminal gedit ~/.bashrcinput just remove the # in the first two lines (uncomment).

remember tosource ~/.bashrc
insert image description here

Six install and compile DynaSLAM

6.1 Download bbescos/feature/carlathe DynaSLAM source code of the branch

//通过以下命令可以克隆带有carla文件的源码
git clone -b bbescos/feature/carla https://github.com/BertaBescos/DynaSLAM

PS:如果克隆的master分支,master分支里没有mono_carla.cc这个文件,需要注释掉

git clone https://github.com/BertaBescos/DynaSLAM
//注释master分支的CMakeLists.txt的末尾部分

# add_executable(mono_carla
# Examples/Monocular/mono_carla.cc)
# target_link_libraries(mono_carla ${
      
      PROJECT_NAME})

注:masterthere is no mono_carla.ccsuch file in

insert image description here

6.2 Running DynaSLAM to solve the error

cgm@ubuntu:~$ conda activate DynaSLAM
(DynaSLAM) cgm@ubuntu:~$ cd DynaSLAM/
(DynaSLAM) cgm@ubuntu:~/DynaSLAM$ chmod +x build.sh
(DynaSLAM) cgm@ubuntu:~/DynaSLAM$ ./build.sh

(1) Remove in Dynaslamthe root directory CMakeLists.txtand in the files Thirdpartyin DBoW2and g2oin (otherwise a core dump error will be reported)CMakeLists.txt-march=native

//快速去掉的操作是:vscode里 ctrl+shift+F 打开搜索框,输入`-march=native`  进行全部替换

Note: My last test found that it can be run without deleting it.

insert image description here

(2) Modify the wrong file:

  • In the middle Dynaslamof entering , press search , we can see one , and there is no judgment before calling, which will cause the program to terminate in some cases. We can replace the two sentences in turn (in fact, it is to judge first)srcviewer.ccCtrl+Fimshow2imshowif(!image.empty())
        pangolin::FinishFrame();		
        cv::Mat im = mpFrameDrawer->DrawFrame();
		//cv::imshow("DynaSLAM: Current Frame",im); //替换为如下if语句
        if(!im.empty())
        {
    
    
           cv::imshow("DynaSLAM: Current Frame",im);
        }
         cv::Mat im_dyn = mpFrameDrawer->GetDynamicFrame();
         //cv::imshow("DynaSLAM: Dynamic Frame", im_dyn); //替换为如下if语句
         if(!im_dyn.empty())
        {
    
    
           cv::imshow("DynaSLAM: Dynamic Frame", im_dyn);
        }

What I tested is that if you don’t modify this, it will crash

insert image description here

insert image description here

Note: master分支viewer.ccthis is

insert image description here

(3)报错:/usr/include/c++/9/bits/stl_map.h:122:71: error: static assertion failed: std::map must have the same value_type as its allocator

  • Solution: (this does not modify 100% error)
//打开LoopClosing.h,将
typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
        Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
//改为
typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
		Eigen::aligned_allocator<std::pair<KeyFrame *const, g2o::Sim3> > > KeyFrameAndPose;

(4) 如果Error reporting:

In file included from /home/cgm/DynaSLAM/src/Conversion.cc:9:/home/cgm/DynaSLAN/include/Conversion.h:17:10: fatal error: ndarrayobject.h:没有那个文件或目录
17|#include "ndarrayobject.h"
compilation terminated .

Solution: search anaconda3/envsbelow ndarrayobject.h, copy its path, add to ndarrayobject.habove

//Conversion.h
//将
#include "ndarrayobject.h"
//改为正确的python2.7下的路径
#include "/home/cgm/anaconda3/envs/DynaSLAM/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h"

insert image description here

6.3 Successfully compiled DynaSLAM

insert image description here

7. Run DynaSLAM

7.1 RGB-D example on TUM dataset

For TUM dynamic sequences, these associated files ./Examples/RGB-D/associations/are given in the folder.

insert image description here

7.2 The origin of the above associated files

rgbd_dataset_freiburg2_desk_with_personFor example, we use the ( ) under DYNAMIC OBJECTS of the dataset TUM

insert image description here

Use associate.pythe RGB image in the dataset to associate it with the depth map

reason:

Kinect provides color and depth images asynchronously. This means that the set of timestamps from the color image will not intersect with the set of timestamps from the depth image. Therefore, we need some way to associate the color image with the depth image.

For this, you can use the "associate.py" script. rgb.txtfile and read timestamps from files depth.txtand concatenate them by finding the best match.

Click here to download associate.py .

python associate.py rgb.txt depth.txt > rgbd_dataset_freiburg2_desk_with_person.txt

insert image description here

7.3 RGB-D example program run on TUM dataset

illustrate:

  • ​ Run ./Examples/RGB-D/rgbd_tum, the incoming parameters are: ORB字典、配置信息、数据集路径、Mask目录、OUTPUT目录. Among them, the mask directory and output directory are newly created by us.
  • If provided PATH_TO_MASKS, Mask R-CNNthe underlying dynamic content used to split each frame. These maskare saved PATH_TO_MASKSin . If this parameter is no_save, it is used maskbut not saved. If it finds dynamic masks computed by PATH_TO_MASKSin Mask R-CNN, it uses them but doesn't compute them again.
  • ​ If provided PATH_TO_OUTPUT, computes the inpainted frame and saves it PATH_TO_OUTPUTin . (background fix)

(1) If 未提供PATH_TO_MASKS and PATH_TO_OUTPUT, then 仅使用几何方法检测动态对象.

./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM3.yaml ../DataSet/TUM_Dataset/rgbd_dataset_freiburg3_walking_xyz/ Examples/RGB-D/associations/fr3_walking_xyz.txt

Error:

Light Tracking not working because Tracking is not initialized...
Geometry not working.
New map created with 717 points
Geometry not working.
Geometry not working.
Geometry not working.
  • Solution: If it is found that Light Track has been unsuccessful and cannot be initialized after running, then increase the number of feature points in the ORB parameter setting, and generally change it to 3000 on github.
//TUM3.yaml文件
//ORB Extractor: Number of features per image
ORBextractor.nFeatures: 3000

I reported an error here: Failed to load module "canberra-gtk-module"
Solve:sudo apt-get install libcanberra-gtk-module
insert image description here

evo_ape tum groundtruth.txt KeyFrameTrajectory.txt --plot -va --plot_mode xy

insert image description here

(2) Yes PATH_TO_MASKS,Mask R-CNN用于分割每一帧的潜在动态内容

./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM3.yaml ../DataSet/TUM_Dataset/rgbd_dataset_freiburg3_walking_xyz/ Examples/RGB-D/associations/fr3_walking_xyz.txt /data/mask 
  • Error:
Geometry not working.
Light Tracking not working because Tracking is not initialized...
  • Solution: If it is found that Light Track has been unsuccessful and cannot be initialized after running, then increase the number of feature points in the ORB parameter setting, and generally change it to 3000 on github.
//TUM3.yaml文件
//ORB Extractor: Number of features per image
ORBextractor.nFeatures: 3000

insert image description here

Running and running (stuck and stuck) probably on kps:25, then it crashed...

Depth Threshold (Close/Far Points): 2.98842

-------
Start processing sequence ...
Images in the sequence: 827

Light Tracking not working because Tracking is not initialized...
Geometry not working.
New map created with 769 points
OpenCV Error: Assertion failed (a_size.width == len) in gemm, file /home/cgm/opencv-2.4.11/modules/core/src/matmul.cpp, line 728
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/cgm/opencv-2.4.11/modules/core/src/matmul.cpp:728: error: (-215) a_size.width == len in function gemm
  
已放弃 (核心已转储)

Where is the problem? ?OpenCV Error: Assertion failed (a_size.width == len) in gemm

insert image description here
(3) have PATH_TO_MASKSand PATH_TO_OUTPUTpath,Mask R-CNN用于分割每一帧的潜在动态内容

./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM3.yaml ../DataSet/TUM_Dataset/rgbd_dataset_freiburg3_walking_xyz/ Examples/RGB-D/associations/fr3_walking_xyz.txt /data/mask /data/f3_wxyz_imOut

这个不会报错,不知道为什么提供一个路径就要报错...
If the card is stuck, run it several times, and run the program later to directly read the mask you saved.

insert image description here
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/u013454780/article/details/130007251