Files
opencv-MIRROR/modules/core/src
Shiven Solanki bb8cbcdb0b Merge pull request #30715 from sshivensolanki:core-carttopolar-inplace-5x
core: fix in-place cartToPolar when only the magnitude overwrites an input (5.x) - #30715

5.x port of #30646, as requested in its review. Fixes #30645 on 5.x.

### Problem

`cv::cartToPolar` gives wrong results on `CV_32F` when only the magnitude output is the same `Mat` as `x` or `y`. The SIMD tail handling repeats the last full block, and `cartToPolar32f_` only skipped that for in-place calls when the angle was aliased.

### Fix

Same as #30646: added `mag == X || mag == Y` to the check, so these calls handle the leftover elements with the scalar code.

### Tests

Same `Core_CartToPolar_inplace_mag.accuracy` test as #30646 (`CV_32F`, lengths 1 to 39, magnitude overwriting `x`, then `y`). On Apple M1 Pro it fails without the fix on 5.x and passes with it. The full `opencv_test_core` passes.

### 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
- [x] The PR is proposed to the proper branch
- [x] 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.
- [ ] The feature is well documented and sample code can be built with the project CMake
2026-11-08 11:47:11 +03:00
..
2026-05-20 17:57:51 +03:00
2026-07-09 12:17:24 +03:00
2023-01-09 11:08:02 +00:00
2024-11-14 08:33:22 +03:00
2018-09-07 20:33:52 +09:00
2026-05-20 17:29:34 +05:30
2026-05-20 17:29:34 +05:30
2019-03-05 14:47:04 +03:00
2026-07-28 20:28:24 +05:30
2022-03-03 07:21:53 +09:00
2026-10-27 01:06:00 +08:00
2026-07-09 12:17:24 +03:00
2024-02-12 14:20:35 +03:00
2024-11-14 08:33:22 +03:00
2026-09-23 14:28:55 +02:00
2018-02-12 14:14:08 +03:00
2018-08-27 14:42:18 +03:00
2022-02-22 19:55:26 +00:00