主要内容

本页采用了机器翻译。点击此处可查看英文原文。

多视图运动重建

自 R2026a 起

“运动重建” (SfM) 是一种计算机视觉技术,用于根据一组二维图像估计场景的三维结构 [1]。它在机器人导航、自动驾驶、增强现实和三维场景重建等应用中发挥着至关重要的作用。

本示例系列全面介绍了增量式运动重建 (SfM) 流程,演示了如何根据一组经过标定的图像估计相机位姿并重建三维场景。

基于运动重建的增量结构构建工作流步骤

本系列分为四个模块化示例,每个示例都侧重于增量式运动重建流程中的一个关键步骤。每个示例都包含详细的代码和说明,以帮助您理解其背后的算法和实现。如需了解各个步骤的更多信息,请访问以下示例链接:

  1. Create View Graph Using Bag of Features - 从图像中提取特征,并基于视觉相似性构建视图图

  2. Refine View Graph Using Geometric Verification - 通过验证图像对之间的几何一致性来改进视图图。

  3. Reconstruct 3-D Scene from Geometrically Refined Pair of Initial Views - 选择一组稳健的图像对,并初始化三维重建。

  4. Reconstruct Complete 3-D Scene Using Incremental Structure from Motion - 逐步整合剩余视图,以完成三维重建。

开箱即用的 SfM:运行完整的运动重建流程

虽然本系列中的各个示例对增量式运动重建流程的每个阶段都进行了深入探讨,但本节提供了一种利用封装的辅助函数来端到端运行整个运动重建工作流的简化方法。这些辅助函数封装了四个示例中的代码,使您能够处理自己的图像数据,或使用示例数据集,只需极少的配置即可重建三维场景:

  • helperCreateViewGraph

  • helperRefineViewGraph

  • helperReconstructFromInitialPairView

  • helperIncrementalSfM

借助这些辅助函数,您可以处理自己的图像数据,或使用示例数据集,只需极少的准备工作即可进行三维重建。要使用这些辅助函数,请点击文档中示例旁边的复制命令按钮。然后,将复制的命令粘贴到 MATLAB 命令行窗口中。

在 TUM RGB-D 基准数据集上运行 SfM

本节演示了如何使用 TUM RGB-D 基准数据集 [2] 的一个子集,运行完整的运动重建流程。

下载数据集

url = "https://ssd.mathworks.com/supportfiles/3DReconstruction/tum_rgbd_data.zip";
downloadFolder = tempdir;

filename = fullfile(downloadFolder, "tum_rgbd_data.zip");
imageFolder = fullfile(downloadFolder, "sfmTrainingDataTUMRGBD", "images");

if ~exist(imageFolder, "dir")
    disp('Downloading TUM RGB-D Dataset (43 MB)...');
    websave(filename, url);
    unzip(filename, downloadFolder);   
end

加载图像和相机内参

imds = imageDatastore(imageFolder);
intrinsicsFile = fullfile(downloadFolder, "sfmTrainingDataTUMRGBD", "cameraInfo.mat");
data = load(intrinsicsFile);
intrinsics = data.intrinsics;

运行 SfM 流程

viewGraph = helperCreateViewGraph(imds);
viewGraph = helperRefineViewGraph(viewGraph, intrinsics);
[viewGraph, wpSet] = helperReconstructFromInitialPairView(viewGraph, intrinsics);
[viewGraph, wpSet, point3dColors] = helperIncrementalSfM(viewGraph, wpSet, intrinsics, imds);

% Display the final reconstruction with color
pcshow(wpSet.WorldPoints, point3dColors, MarkerSize=30, VerticalAxis="y", VerticalAxisDir="down");

Figure contains an axes object. The axes object contains an object of type scatter.

利用估计得到的相机位姿和稀疏的三维点云,您可以对场景进行稠密重建。有关稠密重建工作流的更多详细信息,请参阅以下示例。

参考资料

[1] Schonberger, Johannes L., and Jan-Michael Frahm."Structure-from-motion revisited."In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4104-4113. 2016.

[2] Sturm, Jürgen, Nikolas Engelhard, Felix Endres, Wolfram Burgard, and Daniel Cremers."A benchmark for the evaluation of RGB-D SLAM systems".In Proceedings of IEEE/RSJ International Conference on Intelligent Robots and Systems, pp. 573-580, 2012.

另请参阅

主题