Convert Figma logo to code with AI

gaoxiang12 logoslambook2

edition 2 of the slambook

5,401
2,002
5,401
184

Top Related Projects

Real-Time SLAM for Monocular, Stereo and RGB-D Cameras, with Loop Detection and Relocalization Capabilities

LSD-SLAM

3,039

g2o: A General Framework for Graph Optimization

A large scale non-linear optimization library

4,351

The Kalibr visual-inertial calibration toolbox

Quick Overview

The gaoxiang12/slambook2 repository is a collection of code examples and exercises related to Simultaneous Localization and Mapping (SLAM), a fundamental problem in robotics and computer vision. It serves as a comprehensive resource for learning and implementing various SLAM algorithms and techniques.

Pros

  • Comprehensive Coverage: The repository covers a wide range of SLAM-related topics, including visual SLAM, lidar SLAM, and optimization-based SLAM, providing a solid foundation for understanding and implementing these techniques.
  • Hands-on Exercises: The repository includes numerous code examples and exercises, allowing users to actively engage with the material and gain practical experience.
  • Active Maintenance: The project is actively maintained, with regular updates and improvements to the code and documentation.
  • Detailed Documentation: The repository provides detailed documentation, including explanations of the algorithms, implementation details, and instructions for running the examples.

Cons

  • Steep Learning Curve: The SLAM field can be quite complex, and the repository may not be suitable for complete beginners without a strong background in robotics, computer vision, and optimization.
  • Dependency on External Libraries: The code examples in the repository rely on several external libraries, such as Eigen, Ceres Solver, and OpenCV, which may require additional setup and configuration.
  • Limited Real-world Applicability: While the repository provides a solid foundation for SLAM, the examples may not directly translate to real-world robotic applications, which often involve additional challenges and constraints.
  • Lack of Unified Codebase: The repository contains a collection of individual examples and exercises, rather than a single, cohesive codebase, which may make it more challenging to integrate the different components.

Code Examples

Here are a few short code examples from the gaoxiang12/slambook2 repository:

  1. Visual SLAM using ORB Features:
// Load the image pair
cv::Mat img1 = cv::imread("path/to/image1.png");
cv::Mat img2 = cv::imread("path/to/image2.png");

// Extract ORB features
std::vector<cv::KeyPoint> keypoints1, keypoints2;
cv::Mat descriptors1, descriptors2;
cv::Ptr<cv::ORB> orb = cv::ORB::create();
orb->detectAndCompute(img1, cv::Mat(), keypoints1, descriptors1);
orb->detectAndCompute(img2, cv::Mat(), keypoints2, descriptors2);

// Match the features
std::vector<cv::DMatch> matches;
cv::BFMatcher matcher(cv::NORM_HAMMING);
matcher.match(descriptors1, descriptors2, matches);

// Estimate the essential matrix
cv::Mat essential = cv::findEssentialMat(keypoints1, keypoints2, matches);
  1. Lidar SLAM using Ceres Solver:
// Load the lidar scans
std::vector<Eigen::Vector3d> points1, points2;
// ... (load the point clouds)

// Estimate the transformation between the scans
ceres::Problem problem;
ceres::LossFunction* loss_function = new ceres::HuberLoss(1.0);
ceres::LocalParameterization* quaternion_parameterization =
    new ceres::QuaternionParameterization;

Eigen::Isometry3d T_12;
problem.AddParameterBlock(T_12.data(), 7, quaternion_parameterization);

for (size_t i = 0; i < points1.size(); i++) {
  ceres::CostFunction* cost_function =
      PointToPointErrorFunctor::Create(points1[i], points2[i]);
  problem.AddResidualBlock(cost_function, loss_function, T_12.data());
}

ceres::Solver::Options options;
ceres::Solver::Summary summary;
ceres::Solve(options, &problem, &summary);
  1. Optimization-based SLAM using g2o:
// Create the optimization problem
g2o::SparseOptimizer optimizer;
g2o

Competitor Comparisons

Real-Time SLAM for Monocular, Stereo and RGB-D Cameras, with Loop Detection and Relocalization Capabilities

Pros of ORB_SLAM2

  • More focused on a specific SLAM implementation (ORB-SLAM2)
  • Better performance and robustness in real-world scenarios
  • More extensive documentation and community support

Cons of ORB_SLAM2

  • Less educational content compared to slambook2
  • More complex codebase, potentially harder for beginners to understand
  • Limited to visual SLAM, while slambook2 covers a broader range of SLAM topics

Code Comparison

ORB_SLAM2 (feature extraction):

void Frame::ExtractORB(int flag, const cv::Mat &im)
{
    if(flag==0)
        (*mpORBextractorLeft)(im,cv::Mat(),mvKeys,mDescriptors);
    else
        (*mpORBextractorRight)(im,cv::Mat(),mvKeysRight,mDescriptorsRight);
}

slambook2 (feature extraction):

void Frame::ExtractORB() {
    cv::Ptr<cv::Feature2D> orb = cv::ORB::create(500);
    orb->detect(image_, keypoints_);
    orb->compute(image_, keypoints_, descriptors_);
}

The code snippets show different approaches to feature extraction. ORB_SLAM2 uses a more customized implementation, while slambook2 relies on OpenCV's built-in ORB feature extractor.

LSD-SLAM

Pros of LSD-SLAM

  • LSD-SLAM is a real-time monocular SLAM system that can operate on a wide range of hardware, including mobile devices.
  • The algorithm is robust to illumination changes and can handle dynamic scenes.
  • LSD-SLAM provides a dense 3D reconstruction of the environment, which can be useful for various applications.

Cons of LSD-SLAM

  • LSD-SLAM is a more complex system compared to slambook2, with a steeper learning curve.
  • The documentation and community support for LSD-SLAM may not be as extensive as slambook2.
  • LSD-SLAM may have higher computational requirements, making it less suitable for resource-constrained devices.

Code Comparison

slambook2:

// Compute the Jacobian
Eigen::Matrix<double, 2, 6> jacobian = Eigen::Matrix<double, 2, 6>::Zero();
jacobian(0, 0) = 1;
jacobian(0, 2) = -u;
jacobian(0, 3) = -u*v;
jacobian(0, 4) = (1+u*u);
jacobian(0, 5) = -v;
jacobian(1, 1) = 1;
jacobian(1, 2) = -v;
jacobian(1, 3) = -(1+v*v);
jacobian(1, 4) = u*v;
jacobian(1, 5) = u;

LSD-SLAM:

// Compute the Jacobian
Eigen::Matrix<float, 2, 6> jacobian;
jacobian(0, 0) = 1.0f;
jacobian(0, 2) = -u;
jacobian(0, 3) = -u*v;
jacobian(0, 4) = (1+u*u);
jacobian(0, 5) = -v;
jacobian(1, 1) = 1.0f;
jacobian(1, 2) = -v;
jacobian(1, 3) = -(1+v*v);
jacobian(1, 4) = u*v;
jacobian(1, 5) = u;

The code for computing the Jacobian matrix is similar in both projects, with the main difference being the use of double precision in slambook2 and float precision in LSD-SLAM.

3,039

g2o: A General Framework for Graph Optimization

Pros of g2o

  • More mature and widely used in the SLAM community
  • Offers a broader range of optimization algorithms and solvers
  • Better documentation and community support

Cons of g2o

  • Steeper learning curve for beginners
  • Less focus on educational aspects compared to slambook2
  • May be overkill for simpler SLAM projects

Code Comparison

g2o example (vertex addition):

g2o::VertexSE3* v = new g2o::VertexSE3();
v->setId(vertex_id);
v->setEstimate(Sophus::SE3d());
optimizer.addVertex(v);

slambook2 example (vertex addition):

VertexPose *vertex_pose = new VertexPose();
vertex_pose->setId(vertex_id);
vertex_pose->setEstimate(Sophus::SE3d());
optimizer.addVertex(vertex_pose);

Both repositories provide similar functionality for adding vertices to the optimization graph, but g2o offers more specialized vertex types and a wider range of options for different SLAM scenarios.

A large scale non-linear optimization library

Pros of Ceres Solver

  • More mature and widely used in industry and research
  • Highly optimized for large-scale problems
  • Extensive documentation and community support

Cons of Ceres Solver

  • Steeper learning curve for beginners
  • Less focused on SLAM-specific applications
  • Requires more setup and configuration

Code Comparison

Ceres Solver example:

ceres::Problem problem;
problem.AddResidualBlock(
    new ceres::AutoDiffCostFunction<CostFunctor, 1, 1>(new CostFunctor),
    nullptr,
    &x);
ceres::Solve(options, &problem, &summary);

Slambook2 example:

g2o::SparseOptimizer optimizer;
optimizer.setAlgorithm(new g2o::OptimizationAlgorithmLevenberg);
g2o::VertexSE3Expmap *pose = new g2o::VertexSE3Expmap();
optimizer.addVertex(pose);
optimizer.initializeOptimization();
optimizer.optimize(10);

Summary

Ceres Solver is a more general-purpose optimization library with broader applications, while Slambook2 is specifically tailored for SLAM (Simultaneous Localization and Mapping) problems. Ceres Solver offers more flexibility and performance for large-scale problems, but may be more challenging for beginners. Slambook2 provides a more accessible entry point for those focusing on SLAM applications, with examples and tutorials specific to this domain.

4,351

The Kalibr visual-inertial calibration toolbox

Pros of kalibr

  • Specialized tool for sensor calibration, particularly for multi-sensor systems
  • Supports a wide range of sensor types, including cameras, IMUs, and LiDARs
  • Provides detailed documentation and examples for various calibration scenarios

Cons of kalibr

  • Narrower focus compared to slambook2, which covers a broader range of SLAM topics
  • Steeper learning curve for users not specifically focused on calibration tasks
  • Less comprehensive coverage of general SLAM concepts and algorithms

Code Comparison

kalibr (Python):

import kalibr_common as kc
import kalibr_camera_calibration as kcc

cam = kc.ConfigReader.camera_from_file(cam_yaml)
imu = kc.ConfigReader.imu_from_file(imu_yaml)

slambook2 (C++):

#include <myslam/visual_odometry.h>

auto vo = std::make_shared<myslam::VisualOdometry>();
vo->SetCameraIntrinsics(fx, fy, cx, cy);
vo->AddFrame(frame);

While kalibr focuses on sensor calibration with specialized tools and configurations, slambook2 provides a broader introduction to SLAM concepts and implementations. The code snippets reflect their different focuses, with kalibr emphasizing configuration and calibration, and slambook2 demonstrating core SLAM functionality.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Slambook2

titlepage

Welcome to Slambook 2nd Edition! This is the codebase of our book. Here are some relavant links if you need them:

Email me if you have any questions: gao.xiang.thu at gmail dot com. Or send a issue at github if your question is about the code.

Errata will be updated at this code base.

Hope you like this book.

BaiduYun backup link in case your github is very slow (common in China): here


视觉SLAM十四讲:从理论到实践 第二版

欢迎来到视觉SLAM十四讲:从理论到实践。这里存放本书对应的代码文件。以下是一些可能对你有用的链接:

如果您对书籍内容有疑问,请给我发送邮件。如果对代码有疑问,请点击上方的issue链接新建issues。我会不定期查看和回复(抱歉我可能无法回复所有问题和邮件)。

勘误表会更新到代码库中。

希望您喜欢本书。

本代码的百度云备份(如果您的github速度非常慢)下载链接.