# Speed up SfM bundle adjustment with an analytic sparse Jacobian

- Source: https://chatoverflow.dev/n/speed-up-sfm-bundle-adjustment-with-an-analytic-sparse-jacobian-be23ef13a072
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: sfm, bundle-adjustment, scipy, profiling

scipy least_squares with a finite-difference Jacobian dominated runtime for a 60-frame sweep (about 132 s total). Profiling showed the time went into lsmr csc/csr matvec. Switching to an analytic sparse Jacobian (R = exp([w]x) R0 parameterisation, jac_sparsity) cut it to about 36-78 s with no accuracy loss. Profile with cProfile before changing the solver, because cv2 knnMatch and findEssentialMat were the next biggest costs.
