Contenido principal

poses

R2026b

Absolute camera poses estimated from structure-from-motion (SfM) 3-D reconstruction

Since R2026b

Description

camPoses = poses(sfmObj) returns the absolute camera poses estimated from the SfM 3-D reconstruction of the scene views associated with the sfm object, sfmObj. Use this function to retrieve camera poses after calling the triangulateInitialViews or reconstruct object function. The poses returned after calling the reconstruct object function cover more views than the one returned after calling triangulateInitialViews. The latter only contains poses for the initial two views.

example

[camPoses,viewIDs] = poses(sfmObj) additionally returns the view IDs of the images corresponding to each camera pose. Use the view IDs to identify which images in the original collection correspond to the returned poses.

Examples

collapse all

Use the sfm object to recover camera poses and a sparse 3-D point cloud from images of an indoor scene.

Create Image Datastore and Define Camera Intrinsics

Create an ImageDatastore from the image sequence. Specify the camera intrinsic parameters.

unzip("sfm_images.zip")
imageFolder = fullfile(pwd,"images");
imds = imageDatastore(imageFolder);
intrinsics = cameraIntrinsics([535.1307 532.1860],[323.3722 239.7986],[480 640]);

Visualize the indoor scene.

imshow(preview(imds))

Create SfM Object and Run Pipeline

Create an sfm object and execute each stage of the incremental SfM pipeline sequentially.

sfmObj = sfm(imds,intrinsics);

Connect image pairs based on visual similarity.

sfmObj = connectImagePairs(sfmObj);

Visualize the similarity matrix for the connected image pairs using the imagesc function.

imagesc(sfmObj.SimilarityMatrix)
title("Similarity Matrix for Connected Image Pairs")

Verify that the view graph was created successfully before proceeding to geometric verification.

if isConnected(sfmObj)
    sfmObj = verifyImagePairs(sfmObj);
end

Visualize the similarity matrix for the refined image pair connections using the imagesc function.

imagesc(sfmObj.SimilarityMatrix)
title("Similarity Matrix after Refining Connected Image Pairs")

Confirm that geometric verification completed successfully before initializing the reconstruction. Specify a minimum median angle of 5 degrees and a maximum triangulation error of 4 pixels. Display the initialization metrics.

if isVerified(sfmObj)
    [sfmObj,info] = triangulateInitialViews(sfmObj,MinMedianAngle=5,MaxTriangulationError=4);
    disp(info)
end
                     ViewId1: 9
                     ViewId2: 10
                RelativePose: [1×1 rigidtform3d]
                     Matches: [380×2 uint32]
    MedianTriangulationAngle: 8.6016
       MeanReprojectionError: 0.2799

Confirm that initialization succeeded before running incremental reconstruction.

if isInitialized(sfmObj)
    sfmObj = reconstruct(sfmObj);
end

Retrieve Results

Retrieve the estimated camera poses and the sparse 3-D point cloud.

camPoses = poses(sfmObj);
sparsePoints = pointCloud(sfmObj);

Visualize Reconstruction

Display the reconstructed scene showing the camera trajectory and sparse point cloud. Adjust the view orientation and zoom for better visualization.

plot(sfmObj,CameraSize=0.5,MarkerSize=25)
view(82.69,-15.53)
camroll(-90)
camva(4.52)

Input Arguments

collapse all

Structure from motion object, specified as an sfm object. The object must contain estimated camera poses generated by running triangulateInitialViews or reconstruct object functions.

Output Arguments

collapse all

Absolute camera poses estimated from SfM 3-D reconstruction, returned as an M-element array of rigidtform3d objects. Each element contains the absolute camera pose (rotation and translation) of a registered image in world coordinates.

View identifiers for the absolute camera poses, returned as an M-element vector of positive integers. Each element specifies the view ID for the camera pose in the corresponding element of camPoses.

Version History

Introduced in R2026b