Problem
Hardmax::forward wrote the normalized axis back into the axis attribute, so a later input of a different rank used the stale index: the wrong axis for higher rank, an assertion for lower rank.
Fix
Store the result of normalize_axis in a local normAxis and pass it to hardmaxApply. The axis attribute keeps the value from the model.
QRCodeEncoder::create accepted any version and any correction level, and a version outside of [0, 40] or an unknown level made the encoder read or write out of range. Check the version with CV_CheckGE and CV_CheckLE and the level with CV_Check in the constructor, so that the encoder raises an error. This is the same change and the same tests as #31042 on 4.x.
- Implement TensorScatterLayer supporting linear and circular modes along specified axis
- Register TensorScatter in LayerFactory and ONNX importer
- Copy contiguous slice blocks per outer row with std::memcpy, bounded chunking, and nstripes tuning
- Un-denylist 3 official ONNX conformance tests and shield OpenVINO backend
- Add dedicated unit tests for circular wrapping, default indices, int64 bounds, zero-work domains, and chunk scheduling
createCLAHE and setTilesGridSize accepted a tile grid with a zero in it, and CLAHE_Impl::apply then divided by the number of tiles, which crashed. Check that both numbers of tiles are positive in apply, after the type check. This is the same change and the same test as #31109 on 4.x, in test_histograms.cpp because 5.x has no test_clahe.cpp.
A NaN is false for every comparison in dp <= 0, minDist <= 0, param1 <= 0, param2 <= 0 and param2 >= 1, so it passed all of them, and a NaN dp with HOUGH_GRADIENT_ALT ended in a segmentation fault. Write the checks as !(x > 0) and !(param2 < 1), so that NaN is rejected as well. This is the same change and the same test as #31100 on 4.x.
- Implement TensorScatterLayer supporting linear and circular modes along specified axis
- Register TensorScatter in LayerFactory and ONNX importer
- Copy contiguous slice blocks per outer row with std::memcpy, bounded chunking, and nstripes tuning
- Un-denylist 3 official ONNX conformance tests and shield OpenVINO backend
- Add dedicated unit tests for circular wrapping, default indices, int64 bounds, zero-work domains, and chunk scheduling
Key changes
Fused row+column filter: box filters with 3x3 or 5x5 kernels run in one pass with no intermediate row buffer. Large images are split into row bands that run in parallel.
Float accuracy: 32F and 64F kernels up to 5x5 use blockSum, which accumulates in double. Fused float kernels are removed. Results now match pre-Optimized Blur and Box filters by implementing a combined row-and-column separable approach #28224 4.x, and cancellation works ([1e8, 1, -1e8] gives 3).
Bug fixes: in-place boxFilter on ROIs, and a false src/dst overlap check.
Problem
IsInf threw "Unsupported mode" when detect_positive and detect_negative were both 0. ONNX expects an all-false output in that case.
Fix
Fill the output with zeros in that branch instead of calling CV_Error.
* dnn: make ONNX Constant value_int and value_ints int64
The new engine created Constant nodes with a value_int or value_ints
attribute as CV_32S, but ONNX defines both attributes as int64. When such
a constant meets an int64 tensor in an elementwise op (e.g. Equal with a
Split of a shape), NaryEltwise fails with "All inputs should have equal
types". This broke the expanded AffineGrid conformance tests, which are
now enabled.
* dnn: skip the expanded AffineGrid conformance tests on OpenVINO
Problem
Bilinear Resize2 in tf_crop_and_resize mode treated a sample that lands exactly on the last input pixel as out of bounds, so the last output row and column got extrapolation_value whenever the crop box reached the input edge.
Fix
Check the sample position src against [0, inLen - 1] instead of checking floor(src) >= inLen - 1, and cap the second neighbour i1 at inLen - 1 so the last pixel never reads past the row.
Restore the full-frame input. The CPU-vs-OpenCL dissimilarity drops to ~0.004 (about 28× under the 0.1 bound) and all 24 cases pass.
Reproduced on an Apple Silicon (M5) OpenCL GPU.
* core: support 1D Mat in trace and setIdentity for non-float types
In OpenCV 5.x, 1D Mat support was introduced and cv::trace and
cv::setIdentity were updated with CV_Assert(m.dims <= 2). However,
both functions previously relied on m.diag() as the general fallback
path for non-float types (e.g. integer and multi-channel types).
Since Mat::diag strictly asserts dims == 2, calling cv::trace or
cv::setIdentity on a 1D non-float Mat resulted in an assertion failure
in Mat::diag.
Fix this by using m.col(0) when m.dims <= 1 (mirroring the behavior of
1xN 2D matrices), and gracefully handling empty matrices. Also add unit
tests covering 1D Mat across integral, floating point, and multi-channel
types for both cv::trace and cv::setIdentity.
* core: handle 0-D Mat in trace and setIdentity for non-float types
Properly handle 0-D matrices (scalars) in cv::trace using cv::sum(m)
and in cv::setIdentity using m = s without invoking m.col(0).
Also add unit tests for 0-D Mat covering integral, floating-point,
and multi-channel types.
* core: forbid trace and setIdentity for non-2D matrices
* tests: re-enable and fix disabled perf tests, remove dead test code
Signed-off-by: abhishek-gola <abhishek@opencv.org>
* tests: drop OpticalFlowPyrLK_ovx, check RANSAC and multi-encode results, remove stale UPDATE_* hints
Signed-off-by: Abhishek Gola <abhishek.gola@bigvisionllc.com>
---------
Signed-off-by: abhishek-gola <abhishek@opencv.org>
Signed-off-by: Abhishek Gola <abhishek.gola@bigvisionllc.com>
Incorrect prefix offsets can be generated when different partitions are used for counting and emission, leading to some coordinates being overwritten or not written at all. Despite this, the output shape remains correct.
Each logical stripe is counted independently. We have added a parameterized test for dense and sparse inputs. It covers three different counting partitions and tests that all coordinates are correctly generated in row-major order. The test also verifies that the output shape and type are correct, that output memory was reused and that input data was preserved.
fastGemm optimizations and add flashattention without MLAS
fastGemm cuts every product into fixed tiles (60 × 320 on AVX/AVX2, from #23897) and runs one tile per parallel task. Transformer layers have few rows, so they make fewer tasks than there are threads. On a 32-thread CPU, a 50 × 3072 projection gives 10 tasks, and one attention MatMul of DeiT-Tiny (3 heads × 197 × 64 × 197) gives 12.
* imgproc: bit-exact BGR(A)2GRAY on AVX-512 (5.x)
Port of https://github.com/opencv/opencv/pull/29848.
5.x already dispatches color_rgb through AVX512_ICL, but the uchar RGB2Gray kernel was still the universal SIMD path. Use vpmaddwd for BGRA and vpermb+vpmaddwd for BGR, and keep that kernel as the fallback.
* imgproc: fix AVX-512 RGB2Gray tail for overlapping buffers (5.x)
Additional fixes.
- Take the AVX-512 kernels only when the source and destination byte ranges are disjoint. The clamped final block re-reads source pixels, and an overlapping store can overwrite them (src == dst, or a 1-channel dst that starts 1-3 bytes into the source). Those cases use the existing fallback.
- Use 'i <= n - 16' as the loop bound so the check cannot overflow for very large rows.
- Add exact integer-reference tests for CV_8UC4 BGRA2GRAY and RGBA2GRAY at widths 1-263 with random alpha, and aliased-storage tests at widths 15-33.
* imgproc: scalar tail for overlapping BGR(A)2GRAY buffers (5.x)
Rewinding the final vector block re-reads source pixels already overwritten when dst overlaps src. Use the scalar tail for overlapping buffers, and test widths 63-129 on both the dispatched and baseline paths.
* imgproc: tidy BGRA/RGBA2GRAY 4ch tests (5.x)
- Use the shared theRNG() instead of fixed seeds
- Reduce exact-check widths to 1, 16, 17, 263
* imgproc: drop BGRA/RGBA2GRAY 4ch tests (5.x)
- Existing BGRA2GRAY/RGBA2GRAY bit-exact tests already cover color conversion
- Remove the 4ch exact and aliased checks added in this branch
* imgproc: check buffer overlap once in RGB2Gray float/ushort (5.x)
Android default updates to SDK 36 and NDK 30. - #31075
CI: https://github.com/opencv/ci-gha-workflow/pull/365
### 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
This cuts the runtime of slow accuracy and perf tests by giving them less work on the same code paths: fewer iterations, smaller inputs, and fewer perf parameter combinations that measure the same thing. The table lists every change and why the code path the test was written for is still exercised; most changes also carry a short comment in the code.
DISK, ALIKED and the two LightGlueMatcher variants read the ONNX network outputs through raw pointers and Mat::at<> with the layout of the reference exports, but never check the shape or element type that the loaded model actually returned. Any model passed to DISK::create, ALIKED::create or LightGlueMatcher::create (file or buffer) reaches this code:
DISK::detectAndCompute reads kptsData[i * 2 + 1] for every row of keypoints without checking it has 2 columns.
ALIKEDImpl::runNetwork reads at<float>(i, 1) on keypoints and at<float>(i, 0) on scores without checking 2 columns or the float type.
ALIKEDLightGlueMatcherImpl::lightglueMatch reads at<int64_t>(i, 1) on matches0 and at<float>(i) on mscores0 for every match row without checking 2 columns, the int64 type or one score per match.
DISKLightGlueMatcherImpl::lightglueMatch already checks the element counts but reads at<int64_t>(i) on matches0 without checking the int64 type.