Bundle Adjustment using lsqnonlin

This code implements Bundle Adjustment using the Matlab function "lsqnonlin"
701 Downloads
Updated 1 Nov 2017

>>Description:
In the main file a set of points and cameras are randomly generated being the points distributed on a plane and the cameras moving parallel to the plane. 2d image projections are computed per each point and camera observing that point using the true locations. After this step, Gaussian noise is added to the 3D coordinates of the points (x y z) and the 6D coordinates of the cameras (x y z phi theta psi). Then an optimization problem is formulated by defining a cost function using the reprojection error of the 3D points to the camera image planes.
Both Levenberg-Marquardt and Trust-Region-Reflective Least Squares are used. If it is specified to use the second algorithm, a matrix representing the Jacobian sparsity pattern is built to achieve a significant speedup of the optimization.
This code is written just to show the nature of a Bundle Adjustment problem and how it can be implemented. It meant to be used for academic purposes.
>>Usage:

Just run the main script. To change the geometry of the cameras or the geometry of the point cloud just edit the main script under the part Pose and Point Cloud Generation.

>>Compatibility:

Written and tested on Matlab 2016a (it should work also with less recent releases)

>>Notes:

If you find this code useful and you want to check my recent publications, please visit my ResearchGate page at this link: https://www.researchgate.net/profile/Riccardo_Giubilato
If you have any questions, my email address is riccardo.giubilato@gmail.com

Cite As

Riccardo Giubilato (2025). Bundle Adjustment using lsqnonlin (https://github.com/RiccardoGiubilato/Test_BA), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes
1.1.0.0

added preview image

1.0.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.