Guide to 3D reconstruction from unposed RGB images using the MapAnything model.
Guide to 3D reconstruction from unposed RGB images using the MapAnything model.
Overview
The MultiViewReconstructionMapAnythingAlgorithm provides 3D reconstruction from N >= 1 unposed RGB images. Given images and their pinhole intrinsics, the underlying MapAnything TorchScript model jointly predicts:
- Per-pixel metric Z-depth maps
- Camera-to-world 4x4 poses
- Recovered intrinsics at the output resolution
- Per-pixel confidence scores
- Binary validity masks
The algorithm outputs depth maps and coloured world-space point clouds. Both are uniformly scaled by 100 relative to the model's metric output so the reconstruction fits the display coordinate system better.
Usage
The following example demonstrates basic usage of the MultiViewReconstructionMapAnythingAlgorithm. The input is a SharedImageSet containing N >= 1 same-resolution RGB images with an attached CameraCalibrationDataComponent.
#include <ImFusion/Base/DataList.h>
#include <ImFusion/Base/PointCloud.h>
#include <ImFusion/Base/SharedImageSet.h>
#include <ImFusion/Vision/CameraCalibrationDataComponent.h>
#include <ImFusion/Vision/MultiViewReconstructionMapAnythingAlgorithm.h>
calib->p_K = K;
inputImages->components().add(std::move(calib));
algorithm.p_exportPointClouds = true;
algorithm.compute();
@ POINTSET
Set of points.
Definition Data.h:40
Algorithm for 3D reconstruction using the MapAnything model.
Definition MultiViewReconstructionMapAnythingAlgorithm.h:26
Wrapper class to store a list of owned Data instances.
Definition OwningDataList.h:24
std::unique_ptr< SharedImageSet > extractFirstImage(Data::Kind kind=Data::UNKNOWN, Data::Modality modality=Data::NA)
Extract the first SharedImageSet instance of given kind and modality.
std::vector< std::unique_ptr< Data > > extractAll(Data::Kind kind=Data::UNKNOWN)
Extract all Data instances of given kind.
Data structure for point clouds.
Definition PointCloud.h:24
Namespace of the ImFusion SDK.
Definition Changelog.dox:1
Model Details
The MapAnything model is a TorchScript module loaded via the ImFusion ML framework. It expects two inputs:
- images: float32 tensor of shape (N, 3, H, W) with RGB pixel values in [0, 255]
- intrinsics: float32 tensor of shape (N, 3, 3) with standard pinhole matrices
The model internally resizes to 518x518 and maps outputs back to the input resolution. Any input resolution is accepted, and all views must share the same resolution.
Output coordinate conventions:
- Depth: Z-depth along the optical axis, in display units (model's metric depth multiplied by 100)
- Poses: 4x4 camera-to-world transformation matrices, with translations multiplied by 100 to match the scaled depth maps
- Camera frame: OpenCV convention (Z forward, X right, Y down)
Low-Level Access
For direct access to all model outputs (including confidence and mask tensors), use the MultiViewReconstructionMapAnything utility class:
#include <ImFusion/Vision/MultiViewReconstructionMapAnything.h>
auto result = reconstruction.
compute(images);
if (result)
{
}
3D reconstruction using the MapAnything TorchScript model.
Definition MultiViewReconstructionMapAnything.h:52
std::optional< MapAnythingResult > compute(const SharedImageSet &images)
Run reconstruction.
- See also
- MultiViewReconstructionMapAnythingAlgorithm, MultiViewReconstructionMapAnything, MapAnythingResult