mirror of
https://github.com/opencv/opencv.git
synced 2026-12-02 21:22:43 -06:00
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