Files
opencv-MIRROR/modules/calib
Savya Sanchi Sharma 7510afe588 Merge pull request #30175 from SavyaSanchi-Sharma:fix/schur-determinism
calib: make Schur complement solver deterministic - #30175

The Schur-complement LM solver's Jacobian accumulation previously summed per-image contributions into shared `U`/`ea` matrices under a mutex, so results depended on thread-scheduling order. This partitions images into a fixed number of parallel "buckets" (nparts, capped at 16), accumulates each bucket independently without locking, then reduces them serially  removing the mutex and making results bit-identical regardless of thread count.

### Benchmark: CalibrateCamera

Median of 5 runs, native 5.x vs this branch:

| Threads | 5.x median (ms) | This branch median (ms) | Change |
|---|---|---|---|
| 32 | 838.8 (777.7–855.6) | 578.4 (574.5–583.2) | 1.45× faster |
| 1 | 1233.8 (1225.8–1236.8) | 1214.6 (1213.1–1214.8) | 1.6% faster |

Single-thread time is essentially unchanged, as expected removing the mutex has no effect without contention. The gain comes from splitting the Jacobian accumulation (`U`/`ea`) into lock-free per-bucket partials instead of serializing every image's update behind one mutex, which scales much closer to linear with thread count.
### Pull Request Readiness Checklist

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
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2026-10-12 15:59:03 +03:00
..