Commit Graph

27785 Commits

Author SHA1 Message Date
vrooomy
c3979b137a fastGemm kernel optimizations without MLAS 2026-11-27 17:29:35 +05:30
Abhishek Gola
2ca6076273 Merge pull request #31026 from ternaus/codex/forward-port-area-resize-channels
imgproc: forward-port C>4 fractional INTER_AREA resize 🤖🤖🤖
2026-11-27 15:32:54 +05:30
Abhishek Gola
2b33bdac61 dnn: return all false in IsInf when both detect flags are 0 (#31171)
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.
2026-11-27 13:22:49 +05:30
SWETANK KUMAR
9d8621c824 dnn: make ONNX Constant value_int and value_ints int64 (#31181)
* 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
2026-11-27 13:21:31 +05:30
omrope79
75ab176045 Merge pull request #30440 from omrope79/arm-fastgemm
dnn: fastGemm NEON kernel for AArch64
2026-11-27 13:06:04 +05:30
Abhishek Gola
4075f24217 Merge pull request #31179 from sshivensolanki/dnn-resize-tfcrop-edge
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.
2026-11-27 12:53:47 +05:30
Abhishek Gola
9adaa7c853 video(test): revert OpenCL Farneback half-size crop (#31167)
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.
2026-11-27 10:05:10 +05:30
Shiven Solanki
84f7fe9044 dnn: fix last row and column in bilinear tf_crop_and_resize 2026-11-27 12:21:35 +08:00
omrope79
fe96914443 dnn: early stop in NonMaxSuppression and bigger stripes for per-element layers (#31134)
* dnn: split per-element loops into ~64k-element stripes

* dnn: stop NonMaxSuppression once max_output_boxes_per_class boxes are kept
2026-11-27 00:10:29 +05:30
pranjal9091
2868492769 core: forbid trace and setIdentity for non-2D matrices (#30785)
* 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
2026-11-26 18:00:46 +05:30
Shiven Solanki
ffcc3c5179 dnn: return all false in IsInf when both detect flags are 0 2026-11-26 20:19:11 +08:00
Abhishek Gola
371782f3c4 tests: enable disabled perf tests, remove orphaned ml perf files and unused test data generators (#30935)
* 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>
2026-11-26 16:34:33 +05:30
Alexander Smorkalov
1a4423909c Merge pull request #31164 from sshivensolanki:dnn-maxunpool-pads
dnn: accept 4-value pads in ONNX MaxUnpool and read them as [H, W]
2026-11-26 13:22:00 +03:00
Varun Jaiswal
1864ba6aa3 video(test): revert OpenCL Farneback half-size crop 2026-11-26 14:17:06 +05:30
Abhishek Gola
17683cab81 fix phaseCorrelate origin for odd FFT sizes (#31160) 2026-11-26 13:50:45 +05:30
pbkx
a06a29dc41 dnn: fix NonZero output for grouped parallel ranges (#31009)
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.
2026-11-26 13:27:19 +05:30
Varun Jaiswal
a1b14ca7fe Merge pull request #30423 from varun-jaiswal17/dnn-fastgemm-threads
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.
2026-11-26 13:00:18 +05:30
Shiven Solanki
dbaf062c67 dnn: accept 4-value pads in ONNX MaxUnpool and read them as [H, W] 2026-11-26 14:37:36 +08:00
Madan mohan Manokar
be44bb6112 Port 4.x faster bit-exact BGR(A)2GRAY on x86 AVX-512 to 5.x (#30962)
* 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)
2026-11-26 10:21:24 +05:30
Abhishek Gola
ca47dcf876 Merge pull request #31149 from Prasadayus/fix/filter-tile-nstripes-5x
imgproc: keep each thread's filter tiles contiguous
2026-11-26 10:18:21 +05:30
Abhishek Gola
307bb379c5 features: fix XFeat initialization with ORT engine (#31151) 2026-11-26 10:14:45 +05:30
pbkx
f0ca3b1a20 fix phaseCorrelate origin for odd FFT sizes 2026-11-25 10:47:29 -08:00
Hardik K
2d579693d8 Merge pull request #31148 from hardikkaurani/fix/flann-neon-hamming-tail-5x
flann: handle non-multiple of 16 vector sizes in NEON Hamming distance
2026-11-25 20:03:59 +05:30
Abhishek Gola
ba8003d9fe Merge pull request #31145 from Prasadayus/fix/ecc-stripe-accumulators-5x
video: fix false sharing in ECC multi-scale stripe accumulators
2026-11-25 18:45:15 +05:30
Alexander Smorkalov
d19330ddcc Android default updates to SDK 36 and NDK 30. (#31075)
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
2026-11-25 15:29:14 +03:00
saiAnderson
507e872bfb features: fix XFeat initialization with ORT engine 2026-11-25 19:47:30 +08:00
Abhishek Gola
e45cf0217a tests: reduce iterations, input sizes and perf grids of slow tests (#30844)
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.
2026-11-25 17:05:19 +05:30
Abhishek Gola
72d9ae750b Merge pull request #30807 from lazerg/fix/issue-30790-solvecubic-double-root-5.x
core: fix solveCubic missing double roots after coefficient normalization (5.x)
2026-11-25 16:18:41 +05:30
Abhishek Gola
6767539300 features: check DNN output shapes in DISK, ALIKED and LightGlue (#31114)
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.
2026-11-25 16:10:43 +05:30
RITU BASKEY
9f79aeba07 calib: handle three-channel column object points in calibrateMultiview (#30937)
* calib: handle three-channel column object points

* calib: simplify layout test and document object points

* calib: fix fisheye reprojection errors for object point layouts
2026-11-25 16:09:28 +05:30
Abhishek Gola
5051f0ecb6 core: fix NORM_L2 overflow for CV_16S and CV_32S at the type minimum (#31144)
The SIMD kernels of cv::norm(src, NORM_L2/NORM_L2SQR) for CV_16S and CV_32S
sum adjacent squares in a type that is too narrow for the most negative value:

- CV_16S: the int16 dot product accumulates pairs in int32, and
  (-32768)^2 + (-32768)^2 = 2^31 wraps to INT_MIN.
- CV_32S: the int32 dot product accumulates pairs in int64, and
  INT_MIN^2 + INT_MIN^2 = 2^63 wraps to INT64_MIN.

As a result NORM_L2SQR could return a negative value and NORM_L2 NaN, but
only for inputs long enough to reach the vector loop. Masked norm and
norm(src1, src2) were not affected.

Widen the int16 pairwise sums as unsigned (they always fit into uint32) and
square int32 values in double. Performance is unchanged.
2026-11-25 15:58:47 +05:30
Shiven Solanki
34e51a4bf4 Merge pull request #30558 from sshivensolanki/fix-dot-new-depths
Fix
New kernels in matmul.simd.hpp, called through CV_CPU_DISPATCH like dotProd_64f:

CV_32U, CV_64U, CV_64S: thin wrappers around dotProd_ (each element converted to double, accumulated in double).
CV_16F, CV_16BF: vx_load_expand widens each value to float32, and v_muladd adds the products in float32 with two independent accumulators, in blocks of 8192 like dotProd_32f. Each block's sum is added to a double.
CV_8F_E4M3FN, CV_8F_E4M3FNUZ: decoded through decodeLUT() with v_lut, as in cvtFp8ToF32, then multiplied and added in float32 in the same 8192-element blocks.
CV_Bool gets its own kernel: any non-zero byte is true, so it counts the positions where both bytes are non-zero, using v_ne / v_and on v_uint8 with two byte counters in blocks of 255 * vlanes.
ocl_dot() returns false for the 5.x depths, so UMat::dot uses the CPU kernels instead of trying to compile an OpenCL kernel with an unsupported accumulator type.
The Mat::dot documentation now describes the CV_Bool result and the float32 accumulation of CV_16F, CV_16BF and fp8.
The 16F, 16BF and fp8 kernels only need CV_SIMD, not CV_SIMD_64F, so they also use the vector path on platforms without double-precision SIMD.

On a 1024×1024 matrix (Apple M1 Pro, NEON), Mat::dot takes 0.159 ms for CV_16F / CV_16BF and 0.363 ms for the fp8 depths, compared with 0.25 ms and 1.43 ms for the scalar dotProd_ loop.
2026-11-25 15:56:47 +05:30
Abhishek Gola
0654e71376 ptcloud: validate input size, setters, and ROI continuity in RgbdNormals (#30934)
- Check points3d_ori.rows == rows and points3d_ori.cols == cols (plus
  non-empty valid row step) in RgbdNormalsImpl::apply() before cache()
  and output creation so mismatched inputs throw without touching
  preallocated output buffers.
- Validate positive dimensions in setRows() and setCols() (and >= 2 for
  SRI in create(), setRows(), setCols(), and cache() to prevent the
  cols/2 - 1 underflow and zero-denominator division on 1xN / Nx1 grids).
- Stage non-packed (ROI / padded-step) outputs and overlapping
  CrossProduct buffers through a continuous temporary in apply() and
  copy back into the caller's OutputArray, normalizing 1-D or transposed
  OutputArray wrappers via reshape(0, rows) while preserving buffer
  aliasing.
- Clone non-packed or overlapping 1-channel depth inputs for LINEMOD
  (whose computeImpl() steps rows by cols), skip the inner loop early
  when cols <= 2 * r + 1, and widen pixel-count multiplications to
  size_t in FALS and SRI.
- Add parameterized NormalsInputSize tests covering mismatched sizes,
  setter validation, 1-D wrappers, overlapping/in-place buffers, cross-
  depth 4-channel ROIs, non-continuous Mat/UMat/padded-step outputs, and
  LINEMOD 1-channel depth ROIs across CV_16U, CV_32F, and CV_64F.
2026-11-25 15:54:32 +05:30
Prasadayus
3082686acc imgproc: keep each thread's filter tiles contiguous 2026-11-25 15:42:31 +05:30
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
Savya Sanchi Sharma
c97ebe2b55 core: add ROCm 10 support and HIP backend plugin for the non-CPU HAL (#30925)
Adds the AMD/ROCm half:

ROCm detection, separate from HIP. ROCm 10.0 ships HIP 7.15, and HIP's major
version is 7 on both ROCm 7 and ROCm 10, so hip_VERSION cannot identify the
platform. Detection probes rocm-core, then the legacy version file, then
ROCm 10's core-<major>.<minor> directory.
GPU architecture selection via amdgpu-arch / rocm_agent_enumerator,
falling back to family-wide generic targets.
A standalone HIP backend plugin (hal/accel/hip/), loaded on first use.
No OpenCV module compiles HIP, and the main build does not depend on ROCm.
Implemented kernels: flip, transpose, setTo, and convertTo.
2026-11-25 14:23:05 +05:30
Prasadayus
60b6be4841 video: keep ECC stripe counters private to the stripe 2026-11-25 14:05:28 +05:30
Alexander Smorkalov
e8d7aa4a2f Merge pull request #31131 from sshivensolanki:dnn-einsum-uppercase-letters
dnn: fix Einsum index for uppercase subscript letters
2026-11-25 11:12:59 +03:00
Abhishek Gola
5a7c72eba5 geometry: restore HuMoments accuracy coverage (#30465) 2026-11-25 13:00:47 +05:30
shivensolanki
683d4a5bb1 core: fix NORM_L2 overflow for CV_16S and CV_32S at the type minimum
The SIMD kernels of cv::norm(src, NORM_L2/NORM_L2SQR) for CV_16S and CV_32S
sum adjacent squares in a type that is too narrow for the most negative value:

- CV_16S: the int16 dot product accumulates pairs in int32, and
  (-32768)^2 + (-32768)^2 = 2^31 wraps to INT_MIN.
- CV_32S: the int32 dot product accumulates pairs in int64, and
  INT_MIN^2 + INT_MIN^2 = 2^63 wraps to INT64_MIN.

As a result NORM_L2SQR could return a negative value and NORM_L2 NaN, but
only for inputs long enough to reach the vector loop. Masked norm and
norm(src1, src2) were not affected.

Widen the int16 pairwise sums as unsigned (they always fit into uint32) and
square int32 values in double. Performance is unchanged.
2026-11-25 14:58:32 +08:00
Alexander Smorkalov
b8d77c769a Merge pull request #31120 from sshivensolanki/dnn-det-empty-matrix
dnn: fix Det output for 0x0 matrices
2026-11-25 09:17:41 +03:00
Abhishek Gola
6fd640eca1 Merge pull request #31132 from Prasadayus/fix/reduce-false-sharing-5x
core: give cv::reduce rows a per-call accumulator to stop false sharing
2026-11-25 09:16:38 +05:30
Uwez Khan
354b4b38c9 features: check DNN output shapes in DISK, ALIKED and LightGlue 2026-11-24 23:51:30 +05:30
pctablet505
bf830d892d ptcloud: validate input size, setters, and ROI continuity in RgbdNormals
- Check points3d_ori.rows == rows and points3d_ori.cols == cols (plus
  non-empty valid row step) in RgbdNormalsImpl::apply() before cache()
  and output creation so mismatched inputs throw without touching
  preallocated output buffers.
- Validate positive dimensions in setRows() and setCols() (and >= 2 for
  SRI in create(), setRows(), setCols(), and cache() to prevent the
  cols/2 - 1 underflow and zero-denominator division on 1xN / Nx1 grids).
- Stage non-packed (ROI / padded-step) outputs and overlapping
  CrossProduct buffers through a continuous temporary in apply() and
  copy back into the caller's OutputArray, normalizing 1-D or transposed
  OutputArray wrappers via reshape(0, rows) while preserving buffer
  aliasing.
- Clone non-packed or overlapping 1-channel depth inputs for LINEMOD
  (whose computeImpl() steps rows by cols), skip the inner loop early
  when cols <= 2 * r + 1, and widen pixel-count multiplications to
  size_t in FALS and SRI.
- Add parameterized NormalsInputSize tests covering mismatched sizes,
  setter validation, 1-D wrappers, overlapping/in-place buffers, cross-
  depth 4-channel ROIs, non-continuous Mat/UMat/padded-step outputs, and
  LINEMOD 1-channel depth ROIs across CV_16U, CV_32F, and CV_64F.
2026-11-24 21:01:25 +05:30
Alexander Smorkalov
d1abca9a89 Merge pull request #31123 from sshivensolanki:dnn-maxunpool-kernel-hw
dnn: fix MaxUnpool kernel and stride order in the ONNX importer
2026-11-24 18:08:21 +03:00
Prasadayus
663d7c1a8d core: give cv::reduce rows a per-call accumulator to stop false sharing 2026-11-24 19:49:56 +05:30
uwezkhan
7b07609d66 dnn: reject negative position ids in RotaryEmbedding gather 🤖🤖🤖 (#30511)
* dnn: reject negative position ids in RotaryEmbedding gather

* dnn: check RotaryEmbedding cache width, rotary dim and position_ids shape/type

* dnn: check RotaryEmbedding input types in getTypes, exact cache width and 4d num_heads
2026-11-24 19:22:42 +05:30
uwezkhan
06f7ecb5ce ptcloud: bound triangle vertex indices in triangleRasterize 🤖🤖🤖 (#30640)
* ptcloud: bound triangle vertex indices in triangleRasterize

* ptcloud: use checkRange for the triangle index check
2026-11-24 19:11:50 +05:30
Shiven Solanki
3e3f338dde Merge pull request #31061 from sshivensolanki/dnn-trilu-tall-matrix
dnn: fix Trilu for inputs with more rows than columns

Problem
Trilu only loops over the first min(h, w) rows, so when the input has more rows than columns, the remaining rows keep their input values instead of being masked.

Fix
Loop over all h rows in forward() and remove the unused m. The existing cmin < w && num_zeros > 0 check already keeps the memset inside each row, so no other change is needed.
2026-11-24 18:50:41 +05:30
Shiven Solanki
45fed1fec6 dnn: fix Einsum index for uppercase subscript letters 2026-11-24 20:54:28 +08:00