bundleAdjustmentMotion

Refine camera pose using motion-only bundle adjustment

Description

example

refinedPose = bundleAdjustmentMotion(xyzPoints,imagePoints,absolutePose,intrinsics) returns the refined absolute camera pose that minimizes reprojection errors.

The motion-only refinement procedure is a special case of the Levenberg-Marquardt algorithm for bundle adjustment with 3-D points fixed during optimization. The 3-D points and the camera pose are placed in the same world coordinate system.

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

[___] = bundleAdjustmentMotion(___,Name,Value) uses additional options specified by one or more Name,Value pair arguments. Unspecified properties have default values.

Examples

collapse all

Load data for initialization into the workspace.

data = load('motionOnlyBA.mat');

Refine the absolute camera poses.

refinedPose = bundleAdjustmentMotion(data.xyzPoints,data.imagePoints,data.absPose,data.intrinsics);

Display the 3-D world points.

pcshow(data.xyzPoints,'VerticalAxis','y','VerticalAxisDir','down','MarkerSize',45);
hold on

Plot the absolute camera poses before and after refinement.

plotCamera('AbsolutePose',data.absPose,'Color','r','Size',2);
plotCamera('AbsolutePose',refinedPose,'Color','m','Size',2);

Input Arguments

collapse all

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

Data Types: single | double

Image points, specified as an M-by-2 matrix or an M-element Point Feature Types array.

Absolute camera pose, specified as a scalar rigid3d object.

Camera intrinsics, specified as a cameraIntrinsics object.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'MaxIterations', '50'

Maximum number of iterations before the Levenberg-Marquardt algorithm stops, specified as the comma-separated pair consisting of 'MaxIterations' and a positive integer.

Absolute termination tolerance of the mean squared reprojection error in pixels, specified as the comma-separated pair consisting of 'AbsoluteTolerance' and a positive scalar.

Relative termination tolerance of the reduction in reprojection error between iterations, specified as the comma-separated pair consisting of 'RelativeTolerance' and a positive scalar.

Flag to indicate lens distortion, specified as the comma-separated pair consisting of 'PointsUndistorted' and either false or true. When you set PointsUndistorted to false, the 2-D points in pointTracks must be from images with lens distortion. To use undistorted points, use the undistortImage function first, then set PointsUndistorted to true.

Display progress information, specified as the comma-separated pair consisting of 'Verbose' and either false or true.

Output Arguments

collapse all

Refined absolute pose of the camera, returned as a rigid3d object.

Reprojection errors, returned as an M-elment 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, M.I.A. and A.A. Argyros. "SBA: A Software Package for Generic Sparse Bundle Adjustment". ACM Transactions on Mathematical Software. Volume 36, Issue 1. March 2009.

[2] Hartley, R. and A. Zisserman. "Multiple View Geometry in Computer Vision". Cambridge University Press. 2003

[3] Triggs, B., P. McLauchlan, R. Hartley, and A. Fitzgibbon. "Bundle Adjustment: A Modern Synthesis". Proceedings of the International Workshop on Vision Algorithms: Theory and Practice. Pages 298 — 372. Springer-Verlag. 1999.

Introduced in R2020a