appliedAI-Initiative / orb_slam_2_ros

A ROS implementation of ORB_SLAM2
Other
594 stars 283 forks source link

how to build from source on aarch64, opencv 4.* - FAQ #148

Open zoldaten opened 10 months ago

zoldaten commented 10 months ago

Screenshot_1

i do not pretend to full wiki but i built it successfully after several attempts. here what i fixed.

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2 && cd ORB_SLAM2

  1. changes
    sed -i 's/++11/++14/g' CMakeLists.txt
    nano CMakeLists.txt
    find_package(OpenCV 4.0 QUIET)
     ...
    find_package(Eigen3 NO_MODULE)
    find_package(Pangolin REQUIRED)

    1.1.DBow nano Thirdparty/DBoW2/CMakeLists.txt find_package(OpenCV 4.0 QUIET)

2.Pangolin

cd ~
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
git checkout eab3d3449a33a042b1ee7225e1b8b593b1b21e3e
mkdir build && cd build
cmake     -DCMAKE_BUILD_TYPE=Release     -DCMAKE_INSTALL_PREFIX=/usr/local     -DBUILD_EXAMPLES=OFF     -DBUILD_PANGOLIN_DEPTHSENSE=OFF     -DBUILD_PANGOLIN_FFMPEG=OFF     -DBUILD_PANGOLIN_LIBDC1394=OFF     -DBUILD_PANGOLIN_LIBJPEG=OFF     -DBUILD_PANGOLIN_LIBOPENEXR=OFF     -DBUILD_PANGOLIN_LIBPNG=OFF     -DBUILD_PANGOLIN_LIBTIFF=OFF     -DBUILD_PANGOLIN_LIBUVC=OFF     -DBUILD_PANGOLIN_LZ4=OFF     -DBUILD_PANGOLIN_OPENNI=OFF     -DBUILD_PANGOLIN_OPENNI2=OFF     -DBUILD_PANGOLIN_PLEORA=OFF     -DBUILD_PANGOLIN_PYTHON=OFF     -DBUILD_PANGOLIN_TELICAM=OFF     -DBUILD_PANGOLIN_UVC_MEDIAFOUNDATION=OFF     -DBUILD_PANGOLIN_V4L=OFF     -DBUILD_PANGOLIN_ZSTD=OFF     ..
make -j4 && sudo make install

3.changes

nano /home/rock/ORB_SLAM2/include/ORBextractor.h
    //#include <opencv/cv.h>
      #include <opencv2/opencv.hpp>
  1. add #include <unistd.h> to files: /ORB_SLAM2/src/LoopClosing.cc /ORB_SLAM2/src/System.cc /ORB_SLAM2/src/Tracking.cc /ORB_SLAM2/src/LocalMapping.cc /ORB_SLAM2/src/Viewer.cc

  2. add #include <opencv2/opencv.hpp> to /ORB_SLAM2/src/FrameDrawer.cc

  3. add

    #include <opencv2/imgproc/types_c.h>
    #include <opencv2/opencv.hpp>
    using namespace cv;

    to: /ORB_SLAM2/include/System.h /ORB_SLAM2/include/PnPsolver.h

  4. fix ORB_SLAM2/include/LoopClosing.h : before: Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose; after: Eigen::aligned_allocator<std::pair<KeyFrame* const, g2o::Sim3> > > KeyFrameAndPose;

  5. add

    #include <unistd.h>
    #include <opencv2/imgproc/types_c.h>
    #include <opencv2/opencv.hpp>
    using namespace cv;

    and change CV_LOAD_IMAGE_UNCHANGED to IMREAD_UNCHANGED (should looks like - imRGB = cv::imread(string(argv[3])+"/"+vstrImageFilenamesRGB[ni],IMREAD_UNCHANGED);

in files: nano /home/rock/ORB_SLAM2/Examples/RGB-D/rgbd_tum.cc /ORB_SLAM2/Examples/Stereo/stereo_kitti.cc /ORB_SLAM2/Examples/Stereo/stereo_kitti.cc /ORB_SLAM2/Examples/Stereo/stereo_euroc.cc /ORB_SLAM2/Examples/Monocular/mono_tum.cc /ORB_SLAM2/Examples/Monocular/mono_kitti.cc /ORB_SLAM2/Examples/Monocular/mono_euroc.cc