mirror of
https://github.com/opencv/opencv.git
synced 2026-09-13 05:42:51 -05:00
Merge pull request #28461 from Ron12777:opt-clean
Optimize calibrateCamera with Schur‑complement LM and parallel Jacobian accumulation #28461 ## Summary - Optimized `calibrateCamera` for faster runtime without changing outputs using Schur‑complement LM, Parallel Jacobian accumulation, alongside other optimizations. - Reduced time complexity from O(n^3) to O(n) - Add a perf test that uses a 500-image chessboard dataset for performance testing. ## Performance <img width="1200" height="800" alt="base_vs_fast_results" src="https://github.com/user-attachments/assets/6dafa19f-f9cb-4f7f-ba40-0940373712e8" /> <img width="1200" height="800" alt="fast_vs_ceres_results" src="https://github.com/user-attachments/assets/7157af27-8a2b-4810-8b53-3cc9972a8493" /> <img width="1200" height="800" alt="base_vs_fast_param_deviation" src="https://github.com/user-attachments/assets/fe4f954c-34f9-4b9a-b1b2-46e4c76ce08c" /> [Testing repo ](https://github.com/Ron12777/OpenCV-benchmarking) ## Testing - All local tests pass ## Related - [opencv_extra PR with test images](https://github.com/opencv/opencv_extra/pull/1312) See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -627,7 +627,8 @@ enum { CALIB_NINTRINSIC = 18,
|
||||
// for stereo rectification
|
||||
CALIB_ZERO_DISPARITY = 0x00400,
|
||||
CALIB_USE_LU = (1 << 17), //!< use LU instead of SVD decomposition for solving. much faster but potentially less precise
|
||||
CALIB_USE_EXTRINSIC_GUESS = (1 << 22) //!< for stereoCalibrate
|
||||
CALIB_USE_EXTRINSIC_GUESS = (1 << 22), //!< for stereoCalibrate
|
||||
CALIB_DISABLE_SCHUR_COMPLEMENT = (1 << 23) //!< disable Schur complement (use Bouguet calibration engine)
|
||||
};
|
||||
|
||||
//! the algorithm for finding fundamental matrix
|
||||
@@ -1659,6 +1660,7 @@ fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set
|
||||
center ( imageSize is used), and focal distances are computed in a least-squares fashion.
|
||||
Note, that if intrinsic parameters are known, there is no need to use this function just to
|
||||
estimate extrinsic parameters. Use @ref solvePnP instead.
|
||||
- @ref CALIB_DISABLE_SCHUR_COMPLEMENT Disable Schur complement and use the Bouguet calibration engine (@cite Zhang2000, @cite BouguetMCT).
|
||||
- @ref CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
|
||||
optimization. It stays at the center or at a different location specified when
|
||||
@ref CALIB_USE_INTRINSIC_GUESS is set too.
|
||||
@@ -1693,7 +1695,9 @@ supplied distCoeffs matrix is used. Otherwise, it is set to 0.
|
||||
@return the overall RMS re-projection error.
|
||||
|
||||
The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
|
||||
views. The algorithm is based on @cite Zhang2000 and @cite BouguetMCT . The coordinates of 3D object
|
||||
views. By default, the optimization follows a sparse bundle adjustment formulation with Schur
|
||||
complement; see @cite Triggs2000_bundle_adjustment and @cite Lourakis2009_sba for background. Use
|
||||
@ref CALIB_DISABLE_SCHUR_COMPLEMENT to switch to the Bouguet calibration engine. The coordinates of 3D object
|
||||
points and their corresponding 2D projections in each view must be specified. That may be achieved
|
||||
by using an object with known geometry and easily detectable feature points. Such an object is
|
||||
called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
|
||||
@@ -1716,6 +1720,10 @@ The algorithm performs the following steps:
|
||||
the projected (using the current estimates for camera parameters and the poses) object points
|
||||
objectPoints. See @ref projectPoints for details.
|
||||
|
||||
- In practice, robust acquisition is essential for stable results: use multiple board poses with
|
||||
significant tilt, avoid collecting all views at a single working distance, span the expected
|
||||
working-distance range (a larger board with larger squares can help for longer distances).
|
||||
|
||||
@note
|
||||
If you use a non-square (i.e. non-N-by-N) grid and @ref findChessboardCorners for calibration,
|
||||
and @ref calibrateCamera returns bad values (zero distortion coefficients, \f$c_x\f$ and
|
||||
@@ -1801,8 +1809,8 @@ less precise and less stable in some rare cases.
|
||||
@return the overall RMS re-projection error.
|
||||
|
||||
The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
|
||||
views. The algorithm is based on @cite Zhang2000, @cite BouguetMCT and @cite strobl2011iccv. See
|
||||
#calibrateCamera for other detailed explanations.
|
||||
views. The object-releasing extension follows @cite strobl2011iccv and uses the same optimization
|
||||
core as #calibrateCamera. See #calibrateCamera for other detailed explanations.
|
||||
@sa
|
||||
calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user