Main Content

bundleAdjustmentStructure

Refine 3-D points using structure-only bundle adjustment

Since R2020a

Description

xyzRefinedPoints = bundleAdjustmentStructure(xyzPoints,pointTracks,cameraPoses,intrinsics) returns the refined 3-D points that minimize reprojection errors.

The structure-only refinement procedure is a special case of bundle adjustment with camera poses fixed during optimization. The 3-D points and the camera poses are placed in the same world coordinate system.

example

[wpSetRefined,vSetRefined,pointIndex] = bundleAdjustmentStructure(wpSet,vSet,viewID,intrinsics) refines 3-D points from the world point set, wpSet, and refines camera poses from the image view set, vSet. viewID specifies the IDs if the views in vSet.

[xyzRefinedPoints,reprojectionErrors] = bundleAdjustmentStructure(___) additionally returns an N-element vector containing the mean reprojection error for each 3-D world point using the arguments from the previous syntax.

[___] = bundleAdjustmentStructure(___,Name,Value) uses additional options specified by one or more name-value arguments. Unspecified arguments have default values.

Examples

collapse all

Load data for initialization.

data = load('globeBA.mat');

Refine the 3-D world points.

xyzRefinedPoints = bundleAdjustmentStructure(data.xyzPoints,data.pointTracks,data.cameraPoses,data.intrinsics);

Display the refined 3-D world points.

pcshow(xyzRefinedPoints,AxesVisibility="on",VerticalAxis="y",VerticalAxisDir="down",MarkerSize=45);

Display the cameras.

hold on
plotCamera(data.cameraPoses,Size=0.2);
hold off
grid on

Figure contains an axes object. The axes object contains 51 objects of type line, text, patch, scatter.

Input Arguments

collapse all

Unrefined 3-D points, specified as an M-by-3 matrix of [x,y,z] locations.

Data Types: single | double

Matched points across multiple images, specified as an N-element array of pointTracks objects.

Camera poses, specified as a table containing the two columns ViewId and AbsolutePose. You can get the cameraPoses table using the poses object function of the imageviewset object.

3-D world points, specified as a worldpointset object.

Camera poses, specified as an imageviewset object.

View identifiers of the views in vSet, specified as an N-element array. The viewIDs represent which camera poses to refine specifying their related views in imageviewset.

Camera intrinsics, specified as a cameraIntrinsics object or an N-element array of cameraIntrinsics objects. N is the number of camera poses or the number of IDs in viewIDs. Use a single cameraIntrinsics object when images are captured using the same camera. Use a vector cameraIntrinsics objects when images are captured by different cameras.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: MaxIterations=50 sets the number of iterations to 50.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Maximum number of iterations before the Levenberg-Marquardt algorithm stops, specified as a positive integer.

Absolute termination tolerance of the mean squared reprojection error in pixels, specified as a positive scalar.

Relative termination tolerance of the reduction in reprojection error between iterations, specified as a positive scalar.

Flag to indicate lens distortion, specified as false or true. When you set PointsUndistorted to false, the 2-D points in pointTracks or in vSet must be from images with lens distortion. To use undistorted points, first use the undistortImage function to remove distortions from the images, then set PointsUndistorted.

Display progress information, specified as false or true.

Output Arguments

collapse all

3-D locations of refined world points, returned as an M-by-3 matrix of [x,y, z] locations.

Data Types: single | double

Refined 3-D world points, returned as a worldpointset object.

Refined camera poses, returned as a imageviewset object.

Indices to wpSetRefined of refined 3-D world points, returned as an M-element array.

Reprojection errors, returned as an M-element vector. The function projects each world point back into each camera. Then in each image, the function calculates the reprojection error as the distance between the detected and the reprojected point. The reprojectionErrors vector contains the average reprojection error for each world point.

References

[1] Lourakis, Manolis I. A., and Antonis A. Argyros. "SBA: A Software Package for Generic Sparse Bundle Adjustment." ACM Transactions on Mathematical Software 36, no. 1 (March 2009): 2:1–2:30.

[2] Hartley, Richard, and Andrew Zisserman. Multiple View Geometry in Computer Vision. 2nd ed. Cambridge, UK ; New York: Cambridge University Press, 2003.

[3] Triggs, Bill, Philip F. McLauchlan, Richard I. Hartley, and Andrew W. Fitzgibbon. "Bundle Adjustment — A Modern Synthesis." In Proceedings of the International Workshop on Vision Algorithms, 298–372. Springer-Verlag, 1999.

Extended Capabilities

Version History

Introduced in R2020a

expand all