fbpx
Sigmoidal
  • Home
  • LinkedIn
  • About me
  • Contact
No Result
View All Result
  • Português
  • Home
  • LinkedIn
  • About me
  • Contact
No Result
View All Result
Sigmoidal
No Result
View All Result

ORB-SLAM 3: A Tool for 3D Mapping and Localization

Carlos Melo by Carlos Melo
April 10, 2023
in Computer Vision
1
389
SHARES
13k
VIEWS
Share on LinkedInShare on FacebookShare on Whatsapp

Welcome to this tutorial on ORB-SLAM 3, a powerful tool for 3D mapping and localization. If you’re interested in computer vision, robotics, or simply want to learn more about the latest advancements in SLAM technology, then you’re in the right place.

ORB-SLAM 3 is a state-of-the-art SLAM system that builds on the success of its predecessors, ORB-SLAM and ORB-SLAM 2. It uses a combination of feature-based and direct methods to achieve real-time performance on a variety of platforms. In this tutorial, we’ll walk you through the step-by-step process of implementing ORB-SLAM 3, from installation to running the system on your own data. So, let’s get started!

Applications of Simultaneous Localization and Mapping (SLAM)

SLAM, or Simultaneous Localization and Mapping, is a fundamental problem in computer vision that involves building a map of an unknown environment while simultaneously tracking the position within that environment. This is a challenging problem that requires a combination of sensor fusion, optimization, and machine learning techniques.

SLAM has a wide range of applications in robotics, computer vision, and augmented reality. One of the most common applications of SLAM is in autonomous vehicles, where it is used to build a map of the environment and localize the vehicle within that map. In practice it allows the vehicle to navigate autonomously without human intervention.

Simultaneous Localization And Mapping (SLAM) example [Source].
Another important application is in the field of robotics, where it is used to build maps of unknown environments and enable robots to navigate through them. This is particularly useful in scenarios where human intervention is not possible or desirable, such as search and rescue missions or hazardous environments.

SLAM is also used in the field of augmented reality, where it is used to track the position of a user’s device in real-time and overlay virtual objects onto the real world. This allows for immersive and interactive experiences that blur the line between the digital and physical worlds.

In addition to these applications, SLAM has a wide range of other uses, including in the fields of agriculture, construction, and archaeology. As this technology continues to advance, we can expect to see even more innovative applications in the future.

What is ORB-SLAM?

ORB-SLAM is a state-of-the-art SLAM (Simultaneous Localization and Mapping) system that uses a combination of feature-based and direct methods to achieve real-time performance on a variety of platforms. It was developed by researchers at the University of Zaragoza, Spain, and is now widely used in both academia and industry.

The name ORB-SLAM comes from the fact that it uses Oriented FAST and Rotated BRIEF (ORB) features to detect and match keypoints in images. These features are combined with other techniques, such as loop closing and pose optimization, to achieve robust and accurate localization and mapping.

One of the key advantages of ORB-SLAM is its ability to work in real-time on a variety of platforms, including laptops, mobile devices, and even drones. This makes it a versatile tool for a wide range of applications, from autonomous vehicles to augmented reality.

Overall, ORB-SLAM is a powerful and flexible SLAM system that has become a popular choice for researchers and practitioners alike. Its combination of feature-based and direct methods, along with its real-time performance and platform flexibility, make it a valuable tool for anyone working in the field of computer vision or robotics.

Setting up a virtual machine with ORB-SLAM 3

Probably every enthusiast who ventured to try installing any of the ORB-SLAM versions from the instructions on the GitHub repository ended up frustrated after hours or days trying to build and install all the dependencies. The truth is that, as it is a research project on the cutting edge of knowledge and recent, it requires specific versions of its dependencies to be installed. This also applies to the operating system that should be used.

In my specific case, I have a MacBook Pro (Intel chip), and I had to create a virtual machine with Ubuntu. Even then, I had to test three different versions to find one where I could successfully compile and run on a test dataset.

If you search around, you will find instructions that claim it is possible to compile on macOS or Ubuntu 20.04. However, just take a look at the open issues or even merge requests to see that it’s not that straightforward. After many attempts (and cups of coffee), thanks to a fork of the official repository, I managed to find a sequence that worked without any errors. And that’s what I will teach you below.

The version I had success with was Ubuntu 18.04. We will use a freshly installed version from this image. If you wish to use another version, I should warn you that it probably won’t work right away, and you will have to adapt the steps.

Building ORB-SLAM3 library and examples

In this section, we’ll provide a step-by-step guide to implementing ORB-SLAM 3, from installation to running the system on your own data. We’ll cover everything you need to know to get started with ORB-SLAM 3, including how to install the necessary dependencies, how to build the system from source, and how to run the system on your own data.

Attention! Many times we will execute the git checkout command to select specific commits from the dependencies, as well as modify files before building and installing ORB-SLAM3.

$ sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
$ sudo apt update
$ sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
$ sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev libjasper-dev $ libglew-dev libboost-all-dev libssl-dev libeigen3-dev

This particular code block illustrates the installation of the necessary dependencies for building and running ORB-SLAM 3. The first line adds the Ubuntu Xenial Security repository to the list of repositories, which contains the necessary packages for building and running ORB-SLAM 3. The second line updates the package list to include the newly added repository. The third line installs the required dependencies, including build tools, libraries for image and video processing, and the Boost C++ libraries.

$ cd ~
$ mkdir Dev && cd Dev
$ git clone https://github.com/opencv/opencv.git
$ cd opencv
$ git checkout 3.2.0

Here, we have a code segment that illustrates how to download and install OpenCV 3.2.0. The first and second commands change the current directory to the user’s home directory and create a new directory called Dev in the user’s home directory and changes the current directory to that directory. The third command clones the OpenCV repository from GitHub into the current directory. The fourth command checks out a specific version of the library, which is required for building and running ORB-SLAM 3. This version was the only one that really worked for me.

$ gedit ./modules/videoio/src/cap_ffmpeg_impl.hpp

As demonstrated in the code block above, this command opens the “cap_ffmpeg_impl.hpp” file in the videoio module of the OpenCV codebase using the Gedit text editor. This file contains the implementation of the FFmpeg-based video capture functionality used by ORB-SLAM 3. We will modify it in order to enable support for H.264 video encoding, which is required for processing video data from many modern cameras. The modifications involve adding these few lines of code to the header of the file:

#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
#define AVFMT_RAWPICTURE 0x0020

These lines of code define three constants that are used to modify the FFmpeg-based video capture functionality. The first constant, AV_CODEC_FLAG_GLOBAL_HEADER, is a flag that indicates that the codec should output a global header. The second constant, CODEC_FLAG_GLOBAL_HEADER, is an alias for the first constant. The third constant, AVFMT_RAWPICTURE, is a flag that indicates that the format uses raw picture data.

$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=Release -D WITH_CUDA=OFF -D CMAKE_INSTALL_PREFIX=/usr/local ..
$ make -j 3
$ sudo make install

After selecting the right version and change the file, the code snippet above demonstrates how to build and install OpenCV 3.2.0 on your system. The first command creates a new directory called “build” and changes the current directory to that directory. The third command configures the build using CMake with specific options, including setting the build type to “Release,” disabling the use of CUDA, and specifying the installation prefix. The fourth command compiles the code using three threads. The fifth command installs the compiled OpenCV on your system.

$ cd ~/Dev
$ git clone https://github.com/stevenlovegrove/Pangolin.git
$ cd Pangolin
$ git checkout 86eb4975fc4fc8b5d92148c2e370045ae9bf9f5d
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ make -j 3
$ sudo make install

The above code snippet demonstrates how to build and install the Pangolin library, which is a lightweight C++ library for displaying 3D graphics and images. Going back from the current directory to the “Dev” directory in the user’s home directory, we clone the Pangolin repository from GitHub into the current directory and check out a specific commit of the code. The following commands create a new directory called “build”, changes the current directory to that directory, run the CMake, compile the code using three threads and install the compiled code on your system.

$ cd ~/Dev
$ git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git
$ cd ORB_SLAM3
$ git checkout ef9784101fbd28506b52f233315541ef8ba7af57

The moment we have all been waiting for! These commands above clone the ORB-SLAM 3 repository from GitHub and check out a specific commit of the code that worked for me. The first command changes the current directory to the “Dev” directory in the user’s home directory. The second command clones the ORB-SLAM 3 repository from GitHub into the current directory. The third command changes the current directory to the newly cloned ORB-SLAM 3 repository.

$ gedit ./include/LoopClosing.h

In this code block, we can see that the gedit command is used to open the “LoopClosing.h” file. This file contains the implementation of the loop closing functionality, which is responsible for detecting and correcting loop closures in the SLAM system and needs to be modified. In file ./include/LoopClosing.h (at line 51) change the line from:

Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;

to:

Eigen::aligned_allocator<std::pair<KeyFrame *const, g2o::Sim3> > > KeyFrameAndPose;

This adjustment ensures successful compilation. After this change, we can compile ORB-SLAM3 and its dependencies, such as DBoW2 and g2o.

$ ./build.sh

Let’s explore this piece of code and understand what’s going on. This command runs the “build.sh” script, which is a shell script that builds and installs ORB-SLAM 3 on your system. The script runs several commands, including building and installing some thirds dependencies.

In fact, I read that it might not work on the first try, and it may be necessary to run $ ./build.sh one or two more times (I didn’t need to).

Obtaining the EuRoc Dataset for Testing

To test the ORB-SLAM 3 system, we need a dataset of real-world images and camera poses. In this section, we’ll download and prepare the EuRoc dataset, which is a popular dataset for testing visual SLAM systems.

EuRoc Dataset for Testing.
cd ~
mkdir -p Datasets/EuRoc
cd Datasets/EuRoc/
wget -c http://robotics.ethz.ch/~asl-datasets/ijrr_euroc_mav_dataset/machine_hall/MH_01_easy/MH_01_easy.zip
mkdir MH01
unzip MH_01_easy.zip -d MH01/

Here, we have a code segment that illustrates how to download and prepare the EuRoc dataset for testing ORB-SLAM 3. The first command changes the current directory to the user’s home directory. The second command creates a new directory called “Datasets/EuRoc” in the user’s home directory. The third command changes the current directory to the newly created “Datasets/EuRoc” directory. The fourth command downloads the “MH01easy.zip” file from the EuRoc dataset website. The fifth command creates a new directory called “MH01” in the current directory. The sixth command unzips the downloaded file into the newly created “MH01” directory. This code segment is necessary for obtaining and preparing the EuRoc dataset for testing ORB-SLAM 3.

$ cd ~/Dev/ORB_SLAM3
$ ./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml ~/Datasets/EuRoc/MH01 ./

As we can see from the code above, this command runs the ORB-SLAM 3 system on the EuRoc dataset. The first command changes the current directory to the ORB-SLAM 3 codebase directory. The second command runs the “mono_euroc” example, which is a monocular visual SLAM system designed to work with the EuRoc dataset. The third command specifies the path to the ORB vocabulary file. The fourth command specifies the path to the EuRoc dataset configuration file. The fifth command specifies the path to the EuRoc dataset directory. The sixth command specifies the path to the output directory. This command is necessary for testing the ORB-SLAM 3 system on the EuRoc dataset.

Results and Conclusion

The ORB-SLAM 3 delivers remarkable technical results, providing a comprehensive solution to the SLAM problem. In our case, during the execution process the library displays a window that shows the sequence of images from the EuRoc dataset and tracks the features in real-time. These features, also known as points of interest, are represented by small green trackers that move with the scene as the camera moves.

In addition, ORB-SLAM 3 creates a 3D point cloud that represents the environment map. This point cloud is generated from the features extracted from the images and allows for visualization and analysis of the mapped space. Although ORB-SLAM 3 does not directly generate a 3D mesh from this point cloud, the obtained information can be easily exported and processed by other tools to create a three-dimensional mesh of the environment.

Another important feature is the ability to visualize the estimated camera trajectory in real-time. ORB-SLAM3 provides a separate window that displays the camera trajectory and the covisibility map of keyframes, allowing the user to follow the progress of the algorithm and evaluate the accuracy of the location in relation to the environment.

In summary, ORB-SLAM3 delivers a robust and accurate visual and visual-inertial SLAM solution, providing valuable information about the environment and sensor movement. The library displays tracked features, generates a 3D point cloud, and allows for the visualization of the camera trajectory, making it easy to analyze and apply these data in various contexts and projects.

Share27Share156Send
Previous Post

Building a Deep Learning Neural Network using TensorFlow

Next Post

What is Computer Vision and How does it work?

Carlos Melo

Carlos Melo

Computer Vision Engineer with a degree in Aeronautical Sciences from the Air Force Academy (AFA), Master in Aerospace Engineering from the Technological Institute of Aeronautics (ITA), and founder of Sigmoidal.

Related Posts

Como equalizar histograma de imagens com OpenCV e Python
Computer Vision

Histogram Equalization with OpenCV and Python

by Carlos Melo
July 16, 2024
How to Train YOLOv9 on Custom Dataset
Computer Vision

How to Train YOLOv9 on Custom Dataset – A Complete Tutorial

by Carlos Melo
February 29, 2024
YOLOv9 para detecção de Objetos
Blog

YOLOv9: A Step-by-Step Tutorial for Object Detection

by Carlos Melo
February 26, 2024
Depth Anything - Estimativa de Profundidade Monocular
Computer Vision

Depth Estimation on Single Camera with Depth Anything

by Carlos Melo
February 23, 2024
Point Cloud Processing with Open3D and Python
Computer Vision

Point Cloud Processing with Open3D and Python

by Carlos Melo
February 12, 2024
Next Post
O que é Visão Computacional

What is Computer Vision and How does it work?

Comments 1

  1. Vunana Pedro says:
    2 years ago

    Meu Deus há tanta coisa que sempre imaginei em fazer e que afinal é possivel com computer vision… os filmes mostram muito estes cenários em que lançam um drone para efetuar o mapeamento da zona em atuação por uma equipa de soldados ou tecnicos em zonas remotas, eu não imaginava que isso já fosse uma realidade.. uau… o filme prometheus mostra isso.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Trending
  • Comments
  • Latest
Estimativa de Pose Humana com MediaPipe

Real-time Human Pose Estimation using MediaPipe

September 11, 2023
ORB-SLAM 3: A Tool for 3D Mapping and Localization

ORB-SLAM 3: A Tool for 3D Mapping and Localization

April 10, 2023

Build a Surveillance System with Computer Vision and Deep Learning

1
ORB-SLAM 3: A Tool for 3D Mapping and Localization

ORB-SLAM 3: A Tool for 3D Mapping and Localization

1
Point Cloud Processing with Open3D and Python

Point Cloud Processing with Open3D and Python

1

Fundamentals of Image Formation

0
Como equalizar histograma de imagens com OpenCV e Python

Histogram Equalization with OpenCV and Python

July 16, 2024
How to Train YOLOv9 on Custom Dataset

How to Train YOLOv9 on Custom Dataset – A Complete Tutorial

February 29, 2024
YOLOv9 para detecção de Objetos

YOLOv9: A Step-by-Step Tutorial for Object Detection

February 26, 2024
Depth Anything - Estimativa de Profundidade Monocular

Depth Estimation on Single Camera with Depth Anything

February 23, 2024

Seguir

  • Cada passo te aproxima do que realmente importa. Quer continuar avançando?

🔘 [ ] Agora não
🔘 [ ] Seguir em frente 🚀
  • 🇺🇸 Green Card por Habilidade Extraordinária em Data Science e Machine Learning

Após nossa mudança para os EUA, muitas pessoas me perguntaram como consegui o Green Card tão rapidamente. Por isso, decidi compartilhar um pouco dessa jornada.

O EB-1A é um dos vistos mais seletivos para imigração, sendo conhecido como “The Einstein Visa”, já que o próprio Albert Einstein obteve sua residência permanente através desse processo em 1933.

Apesar do apelido ser um exagero moderno, é fato que esse é um dos vistos mais difíceis de conquistar. Seus critérios rigorosos permitem a obtenção do Green Card sem a necessidade de uma oferta de emprego.

Para isso, o aplicante precisa comprovar, por meio de evidências, que está entre os poucos profissionais de sua área que alcançaram e se mantêm no topo, demonstrando um histórico sólido de conquistas e reconhecimento.

O EB-1A valoriza não apenas um único feito, mas uma trajetória consistente de excelência e liderança, destacando o conjunto de realizações ao longo da carreira.

No meu caso específico, após escrever uma petição com mais de 1.300 páginas contendo todas as evidências necessárias, tive minha solicitação aprovada pelo USCIS, órgão responsável pela imigração nos Estados Unidos.

Fui reconhecido como um indivíduo com habilidade extraordinária em Data Science e Machine Learning, capaz de contribuir em áreas de importância nacional, trazendo benefícios substanciais para os EUA.

Para quem sempre me perguntou sobre o processo de imigração e como funciona o EB-1A, espero que esse resumo ajude a esclarecer um pouco mais. Se tiver dúvidas, estou à disposição para compartilhar mais sobre essa experiência! #machinelearning #datascience
  • 🚀Domine a tecnologia que está revolucionando o mundo.

A Pós-Graduação em Visão Computacional & Deep Learning prepara você para atuar nos campos mais avançados da Inteligência Artificial - de carros autônomos a robôs industriais e drones.

🧠 CARGA HORÁRIA: 400h
💻 MODALIDADE: EAD
📅 INÍCIO DAS AULAS: 29 de maio

Garanta sua vaga agora e impulsione sua carreira com uma formação prática, focada no mercado de trabalho.

Matricule-se já!

#deeplearning #machinelearning #visãocomputacional
  • Green Card aprovado! 🥳 Despedida do Brasil e rumo à nova vida nos 🇺🇸 com a família!
  • Haverá sinais… aprovado na petição do visto EB1A, visto reservado para pessoas com habilidades extraordinárias!

Texas, we are coming! 🤠
  • O que EU TENHO EM COMUM COM O TOM CRUISE??

Clama, não tem nenhuma “semana” aberta. Mas como@é quinta-feira (dia de TBT), olha o que eu resgatei!

Diretamente do TÚNEL DO TEMPO: Carlos Melo &Tom Cruise!
  • Bate e Volta DA ITÁLIA PARA A SUÍÇA 🇨🇭🇮🇹

Aproveitei o dia de folga após o Congresso Internacional de Astronáutica (IAC 2024) e fiz uma viagem “bate e volta” para a belíssima cidade de Lugano, Suíça.

Assista ao vlog e escreve nos comentários se essa não é a cidade mais linda que você já viu!

🔗 LINK NOS STORIES
  • Um paraíso de águas transparentes, e que fica no sul da Suíça!🇨🇭 

Conheça o Lago de Lugano, cercado pelos Alpes Suíços. 

#suiça #lugano #switzerland #datascience
  • Sim, você PRECISA de uma PÓS-GRADUAÇÃO em DATA SCIENCE.
  • 🇨🇭Deixei minha bagagem em um locker no aeroporto de Milão, e vim aproveitar esta última semana nos Alpes suíços!
  • Assista à cobertura completa no YT! Link nos stories 🚀
  • Traje espacial feito pela @axiom.space em parceria com a @prada 

Esse traje será usados pelos astronautas na lua.
para acompanhar as novidades do maior evento sobre espaço do mundo, veja os Stories!

#space #nasa #astronaut #rocket
  • INTERNATIONAL ASTRONAUTICAL CONGRESS - 🇮🇹IAC 2024🇮🇹

Veja a cobertura completa do evento nos DESTAQUES do meu perfil.

Esse é o maior evento de ESPAÇO do mundo! Eu e a @bnp.space estamos representando o Brasil nele 🇧🇷

#iac #space #nasa #spacex
  • 🚀 @bnp.space is building the Next Generation of Sustainable Rocket Fuel.

Join us in transforming the Aerospace Sector with technological and sustainable innovations.
  • 🚀👨‍🚀 Machine Learning para Aplicações Espaciais

Participei do maior congresso de Astronáutica do mundo, e trouxe as novidades e oportunidade da área de dados e Machine Learning para você!

#iac #nasa #spacex
  • 🚀👨‍🚀ACOMPANHE NOS STORIES

Congresso Internacional de Astronáutica (IAC 2024), Milão 🇮🇹
Instagram Youtube LinkedIn Twitter
Sigmoidal

O melhor conteúdo técnico de Data Science, com projetos práticos e exemplos do mundo real.

Seguir no Instagram

Categories

  • Aerospace Engineering
  • Blog
  • Carreira
  • Computer Vision
  • Data Science
  • Deep Learning
  • Featured
  • Iniciantes
  • Machine Learning
  • Posts

Navegar por Tags

3d 3d machine learning 3d vision apollo 13 bayer filter camera calibration career cientista de dados clahe computer vision custom dataset Data Clustering data science deep learning depth anything depth estimation detecção de objetos digital image processing histogram histogram equalization image formation job keras lens lente machine learning machine learning engineering nasa object detection open3d opencv pinhole profissão projeto python redes neurais roboflow rocket scikit-learn space tensorflow tutorial visão computacional yolov8 yolov9

© 2024 Sigmoidal - Aprenda Data Science, Visão Computacional e Python na prática.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist

No Result
View All Result
  • Home
  • Cursos
  • Pós-Graduação
  • Blog
  • Sobre Mim
  • Contato
  • Português

© 2024 Sigmoidal - Aprenda Data Science, Visão Computacional e Python na prática.