Shiven Solanki 4fe077ab3e Merge pull request #31142 from sshivensolanki:dnn-dft-opset20-axis
dnn: use the opset 20 default axis -2 for ONNX DFT - #31142

Fixes #31141

### Problem
Opset 20 made the `DFT` axis an optional input with default `-2`, but the importer leaves the layer on its opset 17 default `axis = 1`. So opset 20 `DFT` without an axis input transforms the wrong dim for 4-D and larger inputs.

### Fix
In `parseDFT`, set `axis = -2` when the model's opset is 20 or newer and no `axis` attribute is present (same pattern as `parseRoiAlign`).

### Tests
Added `Test_ONNX_layers.DFT_opset20_default_axis` to `test_onnx_importer.cpp`, using a `[1, 3, 4, 2]` model from opencv_extra. It fails without the fix and passes with it. The full `opencv_test_dnn` passes (9540 tests) on macOS arm64.

### 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-25 12:34:14 +03:00
2018-10-11 17:57:51 +00:00
2026-11-18 19:15:21 +03:00
2026-11-18 19:15:21 +03:00
2025-08-07 10:35:20 +03:00

OpenCV: Open Source Computer Vision Library

Resources

Contributing

Please read the contribution guidelines before starting work on a pull request.

Summary of the guidelines:

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.

Additional Resources

Description
Languages
C++ 87.7%
C 3.1%
Python 2.9%
CMake 2%
Java 1.5%
Other 2.6%