UZ-SLAMLab / ORB_SLAM3

ORB-SLAM3: An Accurate Open-Source Library for Visual, Visual-Inertial and Multi-Map SLAM
GNU General Public License v3.0
6.67k stars 2.57k forks source link

A docker image with everything installed? Or better documented install instructions? #339

Open catproof opened 3 years ago

catproof commented 3 years ago

I spent a few hours trying to get orb-slam 3 to run on Ubuntu 20.04 yesterday. I had no success. Is there a better way to package your program? Such as in a docker image that contains all the required dependencies?... That way you just have to download the docker image and you are ready to go. Your program has a huge amount of dependencies, making it quite brittle.

Or at the very least, the installation instructions could be more straightforward and better documented. For example, someone could write out in order all the required Linux commands to install all the dependencies with the required versions.

partus commented 3 years ago

A dockerfile would be very appreciated. I tried to build one with replacing FROM borda/docker_python-opencv-ffmpeg:py3.6 in yuyou/ORB_SLAM2 dockerfile , which seems to be broken due to unavailable image with this and it worked fine with ORB_SLAM2.

The built of ORB_SLAM3 fails.

Seem like the main errors are like: /ORB_SLAM3/src/LocalMapping.cc:628:49: error: no match for ‘operator/’ (operand types are ‘cv::Matx<float, 3, 1>’ and ‘float’) x3D = x3D_h.get_minor<3,1>(0,0) / x3D_h(3);

No matter if it's opencv4 which I used first, or 3 .

I think it would help a lot anyone who wants to experiment with the project or run it on some new machine if you could provide a clear dockerfile with right dependencies and right versions so that everything builds seamlessly with it.

Update the last error is fixed by @pkok with this unmerged pull request

The next error is missing openssl/md5.h which I tried to resolve by installing openssl https://cloudwafer.com/blog/installing-openssl-on-ubuntu-16-04-18-04/ , seemed to be with no error.

THe next error is /usr/bin/ld: cannot find -lcrypto

So, it's really complicated to make the project running.

Could someone complete the dockerfile so that the project runs seamlessly?

My current dockerfile is :

FROM tensorflow/tensorflow
RUN apt-get update && apt-get install -y \
        build-essential \
        cmake \
        git \
        wget \
        unzip \
        yasm \
        pkg-config \
        libswscale-dev \
        libtbb2 \
        libtbb-dev \
        libjpeg-dev \
        libpng-dev \
        libtiff-dev \
        libavformat-dev \
        libpq-dev \
        libgtk2.0-dev \
        # Optional
        libtbb2 libtbb-dev \
        libjpeg-dev \
        libpng-dev \
        libtiff-dev \
        libv4l-dev \
        libdc1394-22-dev \
        qt4-default \
        # Missing libraries for GTK and wxPython dependencies
        libatk-adaptor \
        libcanberra-gtk-module \
        x11-apps \
        libgtk-3-dev \
        # Tools
        imagemagick \
    && rm -rf /var/lib/apt/lists/*

ENV OPENCV_VERSION="4.2.0"
# ENV OPENCV_VERSION="3.2.0"
# ENV OPENCV_VERSION="4.0.0"

WORKDIR /
RUN wget --output-document cv.zip https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip \
    && unzip cv.zip \
    && wget --output-document contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip \
    && unzip contrib.zip \
    && mkdir /opencv-${OPENCV_VERSION}/cmake_binary

# Install numpy, since1. it's required for OpenCV
RUN pip install --upgrade pip && pip install --no-cache-dir numpy==1.18.1

RUN cd /opencv-${OPENCV_VERSION}/cmake_binary \
    && cmake -DBUILD_TIFF=ON \
        -DBUILD_opencv_java=OFF \
        -DWITH_CUDA=OFF \
        -DWITH_OPENGL=ON \
        -DWITH_OPENCL=ON \
        -DWITH_IPP=ON \
        -DWITH_TBB=ON \
        -DWITH_EIGEN=ON \
        -DWITH_V4L=ON \
        -DBUILD_TESTS=OFF \
        -DBUILD_PERF_TESTS=OFF \
        -DCMAKE_BUILD_TYPE=RELEASE \
        -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib-${OPENCV_VERSION}/modules \
        -D OPENCV_ENABLE_NONFREE=ON \
        -DCMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") \
        -DPYTHON_EXECUTABLE=$(which python) \
        -DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
        -DPYTHON_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
        .. \
    && make install \
    && rm /cv.zip /contrib.zip \
    && rm -r /opencv-${OPENCV_VERSION} /opencv_contrib-${OPENCV_VERSION}

# RUN ln -s \
#   /usr/local/python/cv2/python-3.8/cv2.cpython-38m-x86_64-linux-gnu.so \
#   /usr/local/lib/python3.8/site-packages/cv2.so

RUN pip install --upgrade pip && pip install --no-cache-dir scipy==1.4.1 matplotlib==3.1.2 requests==2.22.0 ipython numba==0.48.0 jupyterlab==1.2.6 rawpy==0.14.0  # Rawpy is required for HDR & Panorama (processing .CR2 files)

# Get dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
        cmake build-essential pkg-config python3-dev \
        libglew-dev libeigen3-dev libomp-dev \
        libboost-dev libboost-thread-dev libboost-filesystem-dev \
        libboost-python1.65-dev libboost-serialization-dev \
        libpython3.8-dev qt5-default \
        opencl-dev ca-certificates \
        curl htop nano wget git unzip \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Build boost with Python 3.6
# RUN cd /tmp && wget https://github.com/boostorg/boost/archive/refs/tags/boost-1.73.0.tar.gz \
#   && tar -xzf boost-1.73.0.tar.gz
#
#
#
# RUN  cd /tmp && ls -l && cd boost-boost-1.73.0 \
#   && bash bootstrap.sh --with-python=python3 \
#   && ./b2 && ./b2 install \
#   && cd / && rm -rf /tmp/boost-boost-1.73.0*

# Pangolin
RUN cd /tmp && git clone https://github.com/stevenlovegrove/Pangolin.git \
    && cd Pangolin && mkdir build && cd build && cmake .. \
    && make -j$(nproc) && make install \
    && cd / && rm -rf /tmp/Pangolin

CMD bash
marcusabate commented 3 years ago

Also voicing my support for a dockerfile. I recently have been trying to get the system working natively on a 20.04 system, which has failed mostly at the Pangolin level. I think either some recent updates to Pangolin broke the system, or other system-wide packages aren't playing well with it. I tried installing natively on 18.04 and saw the same issues. Related to #374.

I've been working on a docker file to run the ROS nodes, which is able to build Pangolin and get to the ORB build script, but it fails there. Fails whether running build.sh or build_ros.sh. Here is what I have so far:

FROM ros:melodic-ros-base

# RUN apt-get update
# RUN apt-get install curl 
# RUN curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -

RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
RUN apt-get install -y \
        # Base tools
        cmake \
        build-essential \
        git \
        unzip \
        pkg-config \
        python-dev \
        # OpenCV dependencies
        python-numpy \
        # Pangolin dependencies
        libgl1-mesa-dev \
        libglew-dev \
        libpython2.7-dev \
        libeigen3-dev \
        # ROS packages
        ros-melodic-cv-bridge \
        ros-melodic-image-geometry \
        ros-melodic-geometry \
        ros-melodic-image-pipeline \
    && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Build OpenCV (3.0 or higher should be fine)
RUN cd /tmp && git clone https://github.com/opencv/opencv.git && \
    cd opencv && \
    git checkout 4.4.0 && \
    mkdir build && cd build && \
    cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .. && \
    make -j3 && make install && \
    cd / && rm -rf /tmp/opencv

# Build Pangolin
RUN cd /tmp && git clone https://github.com/stevenlovegrove/Pangolin && \
    cd Pangolin && git checkout v0.6 && mkdir build && cd build && \
    cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-std=c++11 .. && \
    make -j$nproc && make install && \
    cd / && rm -rf /tmp/Pangolin

# Build ORB-SLAM3 for ROS
RUN git clone https://github.com/UZ-SLAMLab/ORB_SLAM3 /ORB_SLAM3
RUN . /opt/ros/melodic/setup.sh && \
    export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/ORB_SLAM3/Examples/ROS && \
    cd /ORB_SLAM3/ && \
    chmod +x build.sh && ./build.sh \
    chmod +x build_ros.sh && ./build_ros.sh
marcusabate commented 3 years ago

@NickPerezCarletonUniversity @partus over on the Pangolin side the maintainer recommended that for ORB we use tag v0.6. This worked well for me. I've edited the dockerfile above, it builds on my machine.

jahaniam commented 3 years ago

Hi guys, I have written a docker for ros melodic if you are interested.

https://github.com/jahaniam/orbslam3_docker

catproof commented 3 years ago

@jahaniam i noticed you are doing some nvidia commands in your docker container. is that to allow GPU access? also, did you make this container for Windows 10?... (sorry for noob questions, I am a bit of a docker noob at the moment)

jahaniam commented 3 years ago

@NickPerezCarletonUniversity Good point. I used Nvidia docker container for the GUI to work properly and my laptop has gpu. If you don't have GPU you can remove those commands. It was built in Ubuntu 20. I'm not sure about windows 10 but I assume it should work.

stellarpower commented 3 years ago

I'm also working on a container image (without the ROS extras on top) and would happily contribute back. Or, this image worked for me, as far as it seemed to run, but is based on bionic and that's getting on a bit too much for me now.

catproof commented 3 years ago

@stellarpower that's awesome, keep us posted! :) will your docker being running on a windows system? I haven't played around with GPU access in Docker running on a Windows system, but it is on my backlog of things to do.

UcefMountacer commented 3 years ago

@NickPerezCarletonUniversity @partus over on the Pangolin side the maintainer recommended that for ORB we use tag v0.6. This worked well for me. I've edited the dockerfile above, it builds on my machine.

Hi,

I did the same, install pangolin v0.6 and other packages with respect to the versions required. I did that on colab and ubuntu 20 but it does not work. The build fails for some reason:

CMakeFiles/ORB_SLAM3.dir/build.make:88: recipe for target 'CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o' failed
make[2]: *** [CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o] Error 1
CMakeFiles/Makefile2:109: recipe for target 'CMakeFiles/ORB_SLAM3.dir/all' failed
make[1]: *** [CMakeFiles/ORB_SLAM3.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I get a lot of errors like this related to LocalMapping.cc file :

/content/ORB_SLAM3/src/LocalMapping.cc: In member function ‘void ORB_SLAM3::LocalMapping::ScaleRefinement()’:
/content/ORB_SLAM3/src/LocalMapping.cc:1455:15: warning: unused variable ‘N’ [-Wunused-variable]
     const int N = vpKF.size();
               ^
jahaniam commented 3 years ago

@NickPerezCarletonUniversity @stellarpower @UcefMountacer I changed and fixed some problems with the nvidia drivers. Feel free to retest. It enables the UI properly https://github.com/jahaniam/orbslam3_docker.

@stellarpower You can check the docker file in https://github.com/jahaniam/orbslam3_docker and remove the ros installation section and don't run build_ros.sh . It should work properly.

Also, the fix for local mapping for operator / not found error. I have done it in https://github.com/jahaniam/ORB_SLAM3/tree/docker_opencv3.2_fix and requested a PR. The docker uses my branch but as soon as the pr gets accepted I will switch back to original orbslam git repo.

https://github.com/UZ-SLAMLab/ORB_SLAM3/pull/382 It would be nice to comment there and help them push this change faster.

I notice this fix is not required if you use opencv v4 but that's untested.

UcefMountacer commented 3 years ago

@jahaniam thanks man ! it works.

LMWafer commented 2 years ago

I created a docker image to run slam with Realsense cameras (D435i etc.). Here is the Docker hub link, it's empty for the moment but I'm working on a robust documentation.

richtong commented 2 years ago

@LMWafer that is great, I updated the @jahaniam to work properly on an M1 mac and have shipped a PR, but I am not sure how to get the Dockerfile updated