An image equipped with ORB-SLAM2 and ready for dev. No more GPU, dependencies and build problems !
480
Just an image that makes you skip the ORB-SLAM2 installation process. No additional applications, no fancy dependencies... just the source code !
Moreover, all the images and their build are tested on a freshly installed Ubuntu 20.04 to ensure they work properly !
The image is based on a realsense-ready image. See lmwafer/realsense-ready
Solved common issues (the real bois will know) :
Actual supported version :
lmwafer/orb-slam2-ready:1.0-ubuntu18.04 tagHost version : Ubuntu 20.04 LTS
Just the one mandatory package when you do some image/video stuff in containers
The device id parameter in orb-slam/docker-compose.yml may take another number on different machines. Use
lshw -c display
to get the id of your GPU.
Pull the image
docker pull lmwafer/orb-slam2-ready:<tag>
(We'll use <image> to refer to it)
Expose the X server
sudo xhost +local:root
If you don't enter this command, you will get the Could not open OpenGL window error
Run the container
sudo docker-compose up -d
Here is the docker-compose.yml file (make sure to have docker-compose 1.29.2+ installed)
version: '3.7'
services:
realsense-ready:
container_name: <container>
image: orb-ready
restart: always
privileged: true
ports:
- "8086:8086" # Inherited from realsense-ready
environment:
- DISPLAY=$DISPLAY # Inherited from realsense-ready
- QT_X11_NO_MITSHM=1 # Inherited from realsense-ready
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix # For orb-ready only, give access to X11
stdin_open: true # For orb-ready only, equivalent to "docker run -i"
tty: true # For orb-ready only, equivalent to "docker run -t"
deploy: # For orb-ready only, in response to what(): Pangolin X11: Failed to create an OpenGL context
resources:
reservations:
devices:
- driver: nvidia
device_ids: ['0'] # This ID may change on different machines : `lshw -c display` for more info
capabilities: [gpu]
Access the container's console
clear && docker exec -it <conainter> bash
Although -it has already been given in the .yml file you still need to re-give it in order to avoid a frozen terminal when stopping it.
Stop the container
docker-compose down <container>
Here is the Dockerfile for the 1.0-ubuntu18.04 tag
FROM lmwafer/realsense-ready:ubuntu18.04
RUN apt install -y git nano cmake wget libglew-dev && \
mkdir /app && mkdir /dpds && cd /dpds && \
wget https://github.com/stevenlovegrove/Pangolin/archive/refs/tags/v0.5.tar.gz && \
tar -xzf v0.5.tar.gz && \
rm v0.5.tar.gz && \
cd Pangolin-0.5/ && \
mkdir build && cd build && \
cmake .. && \
cmake --build . && \
cd /dpds && \
wget https://github.com/opencv/opencv/archive/refs/tags/3.2.0.tar.gz && \
tar -xzf 3.2.0.tar.gz && \
rm 3.2.0.tar.gz && \
cd opencv-3.2.0/ && \
mkdir build && cd build && \
cmake .. && \
make && \
sudo make install && \
sudo ldconfig && \
cd /dpds && \
wget https://gitlab.com/libeigen/eigen/-/archive/3.1.0/eigen-3.1.0.tar.gz && \
tar -xzf eigen-3.1.0.tar.gz && \
rm eigen-3.1.0.tar.gz && \
cd eigen-3.1.0 && \
mkdir build && cd build && \
cmake .. && \
make install && \
cd /dpds && \
git clone https://github.com/raulmur/ORB_SLAM2.git && \
cd ORB_SLAM2/ && \
rm include/System.h
COPY System.h /dpds/ORB_SLAM2/include/
RUN cd /dpds/ORB_SLAM2/ && \
chmod +x build.sh && \
./build.sh
# CMD ["./executable"]
# CMD ["/bin/sh", "-ec", "while :; do echo '.'; sleep 5 ; done"]
In fact you can get over the COPY line by simply adding #include<unistd.h> to System.h
For the lazy ones, where is the new System.h file. Juste place it next to Dockerfile and it will be fine.
/**
* This file is part of ORB-SLAM2.
*
* Copyright (C) 2014-2016 Raúl Mur-Artal <raulmur at unizar dot es> (University of Zaragoza)
* For more information see <https://github.com/raulmur/ORB_SLAM2>
*
* ORB-SLAM2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ORB-SLAM2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ORB-SLAM2. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SYSTEM_H
#define SYSTEM_H
#include<string>
#include<thread>
#include<opencv2/core/core.hpp>
#include<unistd.h>
#include "Tracking.h"
#include "FrameDrawer.h"
#include "MapDrawer.h"
#include "Map.h"
#include "LocalMapping.h"
#include "LoopClosing.h"
#include "KeyFrameDatabase.h"
#include "ORBVocabulary.h"
#include "Viewer.h"
namespace ORB_SLAM2
{
class Viewer;
class FrameDrawer;
class Map;
class Tracking;
class LocalMapping;
class LoopClosing;
class System
{
public:
// Input sensor
enum eSensor{
MONOCULAR=0,
STEREO=1,
RGBD=2
};
public:
// Initialize the SLAM system. It launches the Local Mapping, Loop Closing and Viewer threads.
System(const string &strVocFile, const string &strSettingsFile, const eSensor sensor, const bool bUseViewer = true);
// Proccess the given stereo frame. Images must be synchronized and rectified.
// Input images: RGB (CV_8UC3) or grayscale (CV_8U). RGB is converted to grayscale.
// Returns the camera pose (empty if tracking fails).
cv::Mat TrackStereo(const cv::Mat &imLeft, const cv::Mat &imRight, const double ×tamp);
// Process the given rgbd frame. Depthmap must be registered to the RGB frame.
// Input image: RGB (CV_8UC3) or grayscale (CV_8U). RGB is converted to grayscale.
// Input depthmap: Float (CV_32F).
// Returns the camera pose (empty if tracking fails).
cv::Mat TrackRGBD(const cv::Mat &im, const cv::Mat &depthmap, const double ×tamp);
// Proccess the given monocular frame
// Input images: RGB (CV_8UC3) or grayscale (CV_8U). RGB is converted to grayscale.
// Returns the camera pose (empty if tracking fails).
cv::Mat TrackMonocular(const cv::Mat &im, const double ×tamp);
// This stops local mapping thread (map building) and performs only camera tracking.
void ActivateLocalizationMode();
// This resumes local mapping thread and performs SLAM again.
void DeactivateLocalizationMode();
// Returns true if there have been a big map change (loop closure, global BA)
// since last call to this function
bool MapChanged();
// Reset the system (clear map)
void Reset();
// All threads will be requested to finish.
// It waits until all threads have finished.
// This function must be called before saving the trajectory.
void Shutdown();
// Save camera trajectory in the TUM RGB-D dataset format.
// Only for stereo and RGB-D. This method does not work for monocular.
// Call first Shutdown()
// See format details at: http://vision.in.tum.de/data/datasets/rgbd-dataset
void SaveTrajectoryTUM(const string &filename);
// Save keyframe poses in the TUM RGB-D dataset format.
// This method works for all sensor input.
// Call first Shutdown()
// See format details at: http://vision.in.tum.de/data/datasets/rgbd-dataset
void SaveKeyFrameTrajectoryTUM(const string &filename);
// Save camera trajectory in the KITTI dataset format.
// Only for stereo and RGB-D. This method does not work for monocular.
// Call first Shutdown()
// See format details at: http://www.cvlibs.net/datasets/kitti/eval_odometry.php
void SaveTrajectoryKITTI(const string &filename);
// TODO: Save/Load functions
// SaveMap(const string &filename);
// LoadMap(const string &filename);
// Information from most recent processed frame
// You can call this right after TrackMonocular (or stereo or RGBD)
int GetTrackingState();
std::vector<MapPoint*> GetTrackedMapPoints();
std::vector<cv::KeyPoint> GetTrackedKeyPointsUn();
private:
// Input sensor
eSensor mSensor;
// ORB vocabulary used for place recognition and feature matching.
ORBVocabulary* mpVocabulary;
// KeyFrame database for place recognition (relocalization and loop detection).
KeyFrameDatabase* mpKeyFrameDatabase;
// Map structure that stores the pointers to all KeyFrames and MapPoints.
Map* mpMap;
// Tracker. It receives a frame and computes the associated camera pose.
// It also decides when to insert a new keyframe, create some new MapPoints and
// performs relocalization if tracking fails.
Tracking* mpTracker;
// Local Mapper. It manages the local map and performs local bundle adjustment.
LocalMapping* mpLocalMapper;
// Loop Closer. It searches loops with every new keyframe. If there is a loop it performs
// a pose graph optimization and full bundle adjustment (in a new thread) afterwards.
LoopClosing* mpLoopCloser;
// The viewer draws the map and the current camera pose. It uses Pangolin.
Viewer* mpViewer;
FrameDrawer* mpFrameDrawer;
MapDrawer* mpMapDrawer;
// System threads: Local Mapping, Loop Closing, Viewer.
// The Tracking thread "lives" in the main execution thread that creates the System object.
std::thread* mptLocalMapping;
std::thread* mptLoopClosing;
std::thread* mptViewer;
// Reset flag
std::mutex mMutexReset;
bool mbReset;
// Change mode flags
std::mutex mMutexMode;
bool mbActivateLocalizationMode;
bool mbDeactivateLocalizationMode;
// Tracking state
int mTrackingState;
std::vector<MapPoint*> mTrackedMapPoints;
std::vector<cv::KeyPoint> mTrackedKeyPointsUn;
std::mutex mMutexState;
};
}// namespace ORB_SLAM
#endif // SYSTEM_H
Build instructions (consider plugging your laptop adapter, the build might be a bit long)
sudo docker build -f <Dockerfile> -t <Image name> .
Content type
Image
Digest
Size
1.6 GB
Last updated
over 4 years ago
docker pull lmwafer/orb-slam2-ready:1.2-ubuntu18.04