Commit Graph

6233 Commits

Author SHA1 Message Date
kevin9327
6cae2e3701 core: read numbers with an upper-case exponent in FileStorage 2026-11-03 16:24:39 +03:00
Abhishek Gola
f5fab22f7c Merge pull request #30626 from Prasadayus/optimize/imgproc-arm64-perf
imgproc: recover calcHist ARM64 perf regressions
2026-11-03 13:07:06 +05:30
Abhishek Gola
3fdade4e9c Merge pull request #30634 from Prasadayus/optimize/core-norm-arm64-perf
core: recover norm(NORM_L1, CV_32S) perf lost to its correctness fix
2026-11-03 13:05:31 +05:30
Alexander Smorkalov
845bae8b7d Tolerance tuning for FastCV HAL. 2026-11-02 21:49:16 +03:00
Prasadayus
ffb4fb40f8 drop bilateralFilter early-exit restoration, no regression found 2026-11-02 18:57:13 +05:30
Prasadayus
24b3a82376 address review feedback on calcHist/bilateralFilter fixes 2026-11-02 16:35:12 +05:30
Abhishek Gola
739c1e60fd Merge pull request #30611 from sshivensolanki/fix-bitwise-not-bool
core: make bitwise_not a logical NOT for CV_Bool
2026-11-02 14:48:40 +05:30
Prasadayus
af40ab48ca core: recover norm(NORM_L1, CV_32S) perf lost to its correctness fix 2026-11-02 13:27:17 +05:30
Shiven Solanki
45080272b8 core: support CV_16F and CV_16BF in patchNaNs
patchNaNs asserted CV_32F or CV_64F input, so 16-bit float arrays,
which can hold NaN too, could not be patched.

Add patchNaNs_16, the same bit test as the 32-bit kernel on 16-bit
words, with the infinity pattern of each format (0x7c00 for CV_16F,
0x7f80 for CV_16BF). getPatchNanFunc now takes the depth. The OpenCL
kernel only handles float and double, so other depths fall back to
the CPU path.
2026-11-01 04:47:29 +08:00
Abhishek Gola
c4f7634256 Merge pull request #30183 from abhishek-gola/python-ml-dtypes
python: keep exact bfloat16 / float8 dtypes in the bindings via ml_dtypes
2026-10-31 20:26:08 +05:30
Shiven Solanki
806a40d66e core: treat any non-zero CV_Bool as true in bitwise_not, skip OpenCL
- The CV_Bool NOT kernel now computes x == 0 instead of x ^ 1, so a
  non-0/1 byte (still true, as in convertTo) becomes 0 instead of 254.
  The cvtest::logicOp reference does the same.
- bitwise_not no longer tries OpenCL for CV_Bool. It already ended up
  on the CPU kernel, but only because memopTypeToStr() asserts on
  CV_Bool and CV_OCL_RUN catches the exception.
- Core_Bitwise.not_bool also checks a UMat input and 255 bytes in both
  the SIMD loop and the scalar tail.
2026-10-31 22:22:25 +08:00
Shiven Solanki
693cc84722 core: make bitwise_not a logical NOT for CV_Bool
The NOT kernel was picked by element size only, so CV_Bool ran the
same ~x kernel as CV_8U and turned 0/1 into 255/254. Both are non-zero,
so every element of ~mask counted as true. Pass the depth to
getNotFunc and use x ^ 1 for CV_Bool. Fix the same ~x in the
cvtest::logicOp reference, which made Core_Not expect 254.

Add a Core_Bitwise regression test.
2026-10-31 18:09:59 +08:00
Abhishek Gola
8ce9c2c1be Merge pull request #30579 from sshivensolanki/fix-norm-fp8
core: support fp8 depths in cv::norm
2026-10-31 12:58:21 +05:30
Alexander Smorkalov
d73763f09c Merge pull request #30570 from pranayr710:fix/reduce-depth-coverage
core: support CV_8S and CV_32S in cv::reduce
2026-10-30 14:36:38 +03:00
Abhishek Gola
8751eb491e python: drop the CV_16BF -> float32 mapping, share the empty / 0-D output path, run flag tests without ml_dtypes
Signed-off-by: Abhishek Gola <abhishek.gola@bigvisionllc.com>
2026-10-30 15:59:00 +05:30
Abhishek Gola
576defd806 Merge pull request #30466 from tushar152006/fix-convert-fp-to-64int-range
core: fix convertTo() losing values above int32 when converting from FP to 64-bit int
2026-10-30 14:12:03 +05:30
Shiven Solanki
d107ce0e5c core: compare fp8 norm test with EXPECT_DOUBLE_EQ
With IPP, cv::norm of the CV_32F reference computes NORM_L2SQR as the square of NORM_L2, which can be off by 1 ulp (66.5625 vs 66.56250000000001).
2026-10-30 16:02:39 +08:00
utibenkei
9d40b84107 Merge pull request #29851 from utibenkei:fix-java-mat-get-put
java: fix Mat get/put JNI for 0D/1D/ND Mats in OpenCV 5 - #29851#29851

## Summary

Fix incorrect behavior of Java `Mat.get()` / `Mat.put()` JNI bindings for
0D (scalar), 1D, and ND `cv::Mat` objects.
The Java JNI layer in `modules/java/generator/src/cpp/Mat.cpp` still assumed
essentially 2D row/col indexing in several get/put code paths. This caused
wrong results or failed access for scalar and 1D Mats, and incorrect bounds
handling for ND Mats accessed via index arrays.
This PR updates the native get/put helpers in `Mat.cpp` and adds regression
tests in `modules/core/misc/java/test/MatTest.java`.

## Problem (before this patch)
### 1. 0D (scalar) Mats
- `Mat::ptr(const int*)` requires `dims >= 1`, so idx-based paths that called
  `m->ptr(idx.data())` directly (e.g. `nGetIdx`, `mat_copy_data`, `PUT_ITEM_IDX`)
  could not access a true 0D Mat correctly.
- `idx2Offset()` always read `indices[0]` without checking `dims <= 0`.
- Row/col helpers always built a 2-element index `{row, col}` instead of an
  empty index vector for 0D Mats.
Although OpenCV 5 supports 0D Mats at the C++ level, the Java wrapper did not
correctly implement idx-based access with an empty index array (`new int[]{}`).
This PR adds explicit JNI support for that case via `mat_elem_ptr()` and
related helpers.
**Example:** For `Mat m = new Mat(new int[]{}, CvType.CV_64F)` (`dims()==0`),
`m.put(new int[]{}, 42.0)` and `m.get(new int[]{}, buf)` could fail or access
the wrong memory.
### 2. 1D Mats (`dims() == 1`)
- Row/col get/put always converted `(row, col)` to `{row, col}` (length 2),
  while a 1D Mat requires a single-element index vector.
- For a 1D Mat, OpenCV 5 represents the shape as `dims == rows == 1` and
  `cols == total() == N`. The Java row/col access path must therefore interpret
  `(row, col)` as the 1D element index represented by `col` (with `row == 0`),
  converting internally to `{col}` via `row_col_to_idx()`.
**Example:** For `Mat m = new Mat(new int[]{10}, CvType.CV_32F)`, calling
`m.put(0, 3, values)` could behave incorrectly because native code treated
the access as `{0, 3}` instead of `{3}`.
### 3. ND Mats (`dims() > 2`) via row/col API
- Row/col get/put only checked `rows` and `cols`, without rejecting Mats with
  `dims > 2`.
- ND Mats must be accessed via idx-based APIs; using row/col on them could
  produce silently wrong results instead of failing early.
### 4. Idx-based API bounds checking
- Old code checked `size[i] <= idx[i]` but did not validate:
  - `idx.length == dims`
  - negative index values
- `nPutDIdx` computed the number of remaining elements with a per-dimension
  product loop (`channels * (size[i] - idx[i]) * ...`). For ND Mats, this did
  not correctly account for the current linear index position when determining
  how many elements remain from the selected subarray onward. The fix uses
  `(total() - idx2Offset(m, idx)) * channels()`, which matches the linear
  layout used by `mat_copy_data()`.

## Changes
- Add `mat_elem_ptr()` to support 0D scalar Mats (`Mat::ptr(const int*)`
  requires `dims >= 1`).
- Add `check_row_col_access()`, `check_idx_access()`, and `row_col_to_idx()`
  to validate access and convert row/col indices according to OpenCV semantics.
- Update `idx2Offset()`, `offset2Idx()`, and `mat_copy_data()` for 0D/1D Mats.
- Route row/col get/put through `row_col_to_idx()` (1D: element index in `col`,
  `row == 0`).
- Restrict row/col APIs to Mats with `dims <= 2`; ND Mats must use idx-based
  APIs (`nGet*Idx`, `nPut*Idx`, `nGetIdx`, `nPutDIdx`).
- Fix remaining-element calculation in `nPutDIdx` to use `idx2Offset()`.

## Behavior notes
| API | 0D Mat (`dims==0`) | 1D Mat (`dims==1`) | 2D Mat | ND Mat (`dims>2`) |
|-----|-------------------|-------------------|--------|-------------------|
| `get/put(int[] idx, ...)` | supported (`idx.length == 0`; added by this PR) | supported (`idx.length == 1`) | supported | supported |
| `get/put(row, col, ...)` | supported (`row=0`, `col=0`) | supported (index in `col`, `row=0`) | supported | rejected at JNI layer return 0; |
| `get(row, col)` | supported | supported | supported | rejected at JNI layer return 0; |
| `get(int[] idx)` | supported | supported | supported | supported |

## Test plan
Added regression tests in `MatTest.java`:
- `testGetPut0DMat` — idx and row/col get/put on a scalar Mat (`new int[]{}`)
- `testGetPut1DMat` — idx and row/col get/put on `new Mat(new int[]{5}, ...)`
- `testGetPut1DMatDoubleArray` — bulk double put/get via idx on a 1D Mat
- `testGetPut3DMat` — row/col API rejected for 3D Mat; idx API works

### 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
- [ ] 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-10-30 10:45:13 +03:00
Kumataro
75c70dfc46 Merge pull request #30598 from Kumataro:doc/update_intro_for_v5_1_0
core(doc): update introduction for OpenCV 5.1 - #30598

- Remove redundant highgui and videoio modules.
- Add geometry and ptcloud modules.
- Document new 8-bit floating-point types (CV_8F_E4M3FN and CV_8F_E4M3FNUZ).

### 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
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-10-30 10:10:54 +03:00
Alexander Smorkalov
f90784c7a3 Merge pull request #30567 from pratham-mcw:windows-arm64-clangcl
Enable clang-cl build on Windows ARM64 with KleidiCV HAL
2026-10-30 09:12:40 +03:00
Abhishek Gola
8143864783 Merge pull request #30539 from sshivensolanki/fix-checkrange-fp8
core: support fp8 depths in checkRange
2026-10-29 18:05:20 +05:30
Abhishek Gola
5fc1aaf807 Merge pull request #30537 from sshivensolanki/fix-reduce-arg-new-depths
core: support CV_Bool and fp8 depths in reduceArgMax and reduceArgMin
2026-10-29 18:03:13 +05:30
Shiven Solanki
e3181e617e core: rename is_fp16 to is_small_float in cv::norm 2026-10-29 16:37:25 +08:00
Shiven Solanki
c415e4fcef Merge pull request #30526 from sshivensolanki:fix-minmax-fp8
core: support fp8 depths in minMaxLoc and minMaxIdx - #30526

Fixes #30525

### Problem

`minMaxIdxTab` (`modules/core/src/minmax.simd.hpp`) has no entries for `CV_8F_E4M3FN` and `CV_8F_E4M3FNUZ`, so `cv::minMaxLoc` and `cv::minMaxIdx` fail with `func != 0` for fp8 input.

### Fix

- `modules/core/include/opencv2/core/private.hpp`: new `CV_TOGGLE_FP8(x)`, the 8-bit version of `CV_TOGGLE_FLT`: it flips the 7 magnitude bits of negative values, so sign-magnitude fp8 bytes compare in the same order as `int8`.
- `modules/core/src/minmax.simd.hpp`: new `minMaxIdx8f`, used for both fp8 depths. It toggles the input in blocks of 1024 bytes and runs the vectorized `minMaxIdx8s` kernel on them.
- `modules/core/src/minmax.dispatch.cpp`: the fp8 result is toggled back and decoded with `fp8_t::decodeLUT()` / `fp8a_t::decodeLUT()`.
- `modules/core/include/opencv2/core.hpp`: removed the outdated `@note` saying that `CV_16F`/`CV_16BF`/`CV_Bool`/`CV_64U`/`CV_64S`/`CV_32U` are not supported for `minMaxLoc` / `minMaxIdx`.

On 1920x1080 input (single thread, Apple M1 Pro), `minMaxLoc` takes 0.14 ms for both fp8 depths (0.11 ms for `CV_8U`), compared with 2.8 ms for the first version of this PR, which converted every element to `float`. NaN values are not handled specially: like any other byte, they are ordered by their toggled bit pattern.

### Tests

`MinMaxSupportedMatDepth` and `MinMaxAccuracyNewTypes` (`accuracy` and `accuracy_with_mask`) now also run on both fp8 depths, including each format's largest value (448 / 240) and masked-out outliers. The 8 new cases fail on current 5.x (`func != 0`) and pass with this patch. I also compared the results with a float reference on 1600 random fp8 inputs of different sizes, with and without a mask: values and locations match.

All `*MinMax*` / `*minMax*` tests in `opencv_test_core` pass locally on Apple M1 Pro (3113 tests), with OpenCL enabled and with `OPENCV_OPENCL_DEVICE=disabled`. The full `opencv_test_core` passes, except 7 tests that need `opencv_extra` test data, which I didn't have locally (FileStorage base64 and globbing).

### 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-10-29 08:35:30 +03:00
Shiven Solanki
684f8c445e core: support fp8 depths in cv::norm
getNormFunc and getNormDiffFunc had no entries for CV_8F_E4M3FN and
CV_8F_E4M3FNUZ, so cv::norm failed with "func != 0". Add the fp8 kernels
with float accumulators and the same block accumulation as CV_16F and
CV_16BF. Add cv_absdiff overloads for fp8_t and fp8a_t that return
float, so the difference of two fp8 values is not rounded back to fp8.

Add a Core_Norm_FP8 test.
2026-10-29 12:20:06 +08:00
Shiven Solanki
73b5a78e6a core: compare toggled fp8 bytes in checkRange
Address review: like the CV_32F and CV_64F paths, compare integer keys
instead of decoding each fp8 value. CV_TOGGLE_FP8 maps the sign-magnitude
bytes to int8 keys in the same order; the key range [ia, ib) of
[minVal, maxVal) is found once from the decode table, so bounds that are
not fp8 values are still exact. NaN's key is checked separately, since
the E4M3FNUZ NaN sits between the negative values and zero.

Add a Core_CheckRange_FP8 test that checks all 256 values of both fp8
depths against minVal <= v < maxVal for several ranges.
2026-10-29 11:31:06 +08:00
Shiven Solanki
18520b5674 core: compare toggled fp8 bytes in reduceArgMax and reduceArgMin
Address review: instead of decoding each fp8 value to float, compare
the bytes as int8 after CV_TOGGLE_FP8, which keeps the order of the
sign-magnitude values. reduceMinMaxImpl runs on a one-byte ToggledFp8
type, so no temporary copy is needed.

Add -1 to the ReduceArgNewTypes values, so the test fails if the fp8
bytes are compared without toggling.
2026-10-29 11:09:32 +08:00
Alexander Smorkalov
e52dcc2516 Merge pull request #30534 from sshivensolanki:fix-lut-fp8
core: support fp8 lookup tables in LUT
2026-10-28 21:36:30 +03:00
pranayr710
a83d9971b0 core: support CV_8S and CV_32S in cv::reduce
The reduceR_/reduceC_ dispatch is a chain of explicit sdepth/ddepth pairs and has
never carried a CV_8S or CV_32S source row, so cv::reduce rejected both for every
operation and both dim values. 4.x has the same gap.

CV_8S mirrors CV_8U and accumulates in int. CV_32S accumulates in double: OpAdd<int>
evaluates a + b as int before saturate_cast can clamp it, so an int accumulator
overflows. CV_32S -> CV_32S sums are left unsupported for that reason.

Extend Core_ReduceTest to the new combinations, and add cases for the 32-bit
overflow range and the signed 8-bit extremes, which its randu(0, 100) fill cannot
reach. Its support list also omitted 16U/16S REDUCE_MAX/REDUCE_MIN, which the
existing kernels already handle.

Partially addresses #30569.
2026-10-28 18:22:23 +05:30
Pratham Kumar
01499d5150 cmake: enable clang-cl build on Windows ARM64 with KleidiCV 2026-10-28 13:59:54 +05:30
Abhishek Gola
ba2925935b Merge pull request #30479 from Prasadayus/fix/lapack-hal-decline-transpose
core: restore input matrix when the LAPACK HAL declines
2026-10-27 11:59:49 +05:30
Shiven Solanki
3c3e508949 core: support fp8 depths in checkRange
checkRange had no branch for CV_8F_E4M3FN and CV_8F_E4M3FNUZ, so it
failed with "Unsupported matrix depth in checkRange". Use
checkTypedRange with fp8_t / fp8a_t, like CV_16F / CV_16BF; NaN values
are reported as out of range.

Add both fp8 depths to the Core_CheckRange_Float test, with a NaN as
the bad value since fp8 has no infinity.
2026-10-27 02:55:18 +08:00
Shiven Solanki
cd3dc424fb Merge pull request #30463 from sshivensolanki:fix-countnonzero-fp8
core: support fp8 depths in countNonZero and hasNonZero - #30463

Fixes #30461

### Problem

`countNonZeroTab` (`count_non_zero.simd.hpp`) and `hasNonZeroTab` (`has_non_zero.simd.hpp`) have `0` in the `CV_8F_E4M3FN` and `CV_8F_E4M3FNUZ` slots, so `cv::countNonZero` and `cv::hasNonZero` fail with `func != 0` for fp8 input. `cv::findNonZero` already supports both depths since #30341.

### Fix

- `CV_8F_E4M3FN`: new `countNonZero8f` / `hasNonZero8f` kernels. Same as the 8u kernels, but the sign bit is ignored so `-0.0` (`0x80`) counts as zero: the vector path reuses the `v_add_wrap(x, x)` compare of the 16f kernels, and the scalar tail uses `CHECK_NZ_FP8(x) = ((x) & 0x7f) != 0`.
- `CV_8F_E4M3FNUZ`: the existing 8u kernels. This format has no `-0`; `0x80` is its NaN and counts as non-zero, the same as in `findNonZero`.

### Tests

- `CountNonZero1D` now also runs on both fp8 depths.
- `HasNonZeroNegZeros` now also covers `CV_8F_E4M3FNC1`.
- New `CountNonZeroFP8.sign_bit`, a `TEST_P` over both fp8 depths and n = 1, 100, 1031 (scalar tail, single-vector loop, unrolled loop). It fills a `CV_32F` Mat with random values in ±[0.5, 4), sets every 5th element and the last one to `-0.0`, `NaN` or `+0.0`, converts it to fp8, and checks `countNonZero` / `hasNonZero` against the number of non-zero values set. `-0.0` becomes `0x80` in E4M3FN and must count as zero; `NaN` becomes `0x80` in E4M3FNUZ and must count as non-zero.

These fail on current 5.x (`func != 0`) and pass with this patch. All `*NonZero*` and `*FP8*` tests in `opencv_test_core` pass locally on Apple M1 (190 tests), with OpenCL enabled and with `OPENCV_OPENCL_DEVICE=disabled`.

### 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-10-26 21:23:59 +03:00
Shiven Solanki
67c2e2c3ff core: support CV_Bool and fp8 depths in reduceArgMax and reduceArgMin
depthDispatch had no case for CV_Bool, CV_8F_E4M3FN and CV_8F_E4M3FNUZ,
so reduceArgMax / reduceArgMin failed with "Unsupported matrix type".
Dispatch them to bool, fp8_t and fp8a_t; the fp8 types compare through
their float conversion.

Add a ReduceArgNewTypes test, since ElemWiseTest does not generate these
depths.
2026-10-27 02:16:24 +08:00
Shiven Solanki
fca52f6284 core: support fp8 lookup tables in LUT
getLUTFunc had no case for CV_8F_E4M3FN and CV_8F_E4M3FNUZ tables, so
cv::LUT failed with "An unexpected type combination was specified". LUT
only copies table entries, so use the same 1-byte copy as CV_Bool for
both 8-bit and 16-bit indices.

Add both fp8 depths to the LUTAccuracyNewDstTypes test.
2026-10-27 01:06:00 +08:00
Shiven Solanki
46dba3df6e Merge pull request #30506 from sshivensolanki:fix-sort-new-depths
core: support 5.x depths in sort and sortIdx - #30506

Fixes #30505

### Problem

The kernel tables of `cv::sort` and `cv::sortIdx` (`modules/core/src/matrix_operations.cpp`) only have entries for `CV_8U` to `CV_64F`, so every depth added in 5.x fails with `func != 0`.

### Fix

Both tables now use the existing `sort_<T>` / `sortIdx_<T>` templates for:

- `CV_16F` → `hfloat`, `CV_16BF` → `bfloat`, `CV_8F_E4M3FN` → `fp8_t`, `CV_8F_E4M3FNUZ` → `fp8a_t` (compared through their `float` conversion);
- `CV_Bool` → `uchar`, the same kernel as `CV_8U`;
- `CV_64U` → `uint64_t`, `CV_64S` → `int64_t`, `CV_32U` → `uint32_t`.

### Tests

- `Core/sortIdx.simple` now also runs on `CV_16U`, `CV_16F`, `CV_16BF`, `CV_Bool`, `CV_64U`, `CV_64S`, `CV_32U` and both fp8 depths (`CV_16U` was already supported but not tested), and also checks `cv::sort` against sorting a `CV_64F` copy of the same data; there was no `cv::sort` test before.
- New `Core_sort.large_integers` checks exact `sort` / `sortIdx` results for `CV_32S`, `CV_32U`, `CV_64S` and `CV_64U` with values that need the full type: `INT_MIN` / `INT_MAX`, the unsigned high bit (`0x80000000`, `UINT_MAX`, `2^63`, `UINT64_MAX`) and `2^53` vs `2^53 + 1`. With signed kernels for `CV_32U` / `CV_64U` it fails, while the random `sortIdx` test still passes.

The new cases fail on current 5.x and pass with this patch. All `sortIdx` / `sort` tests in `opencv_test_core` pass locally on Apple M1 Pro (242 tests), with OpenCL enabled and with `OPENCV_OPENCL_DEVICE=disabled`. The full `opencv_test_core` passes, except 7 tests that need `opencv_extra` test data, which I didn't have locally (FileStorage base64 and globbing).

### 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-10-26 10:05:01 +03:00
Prasadayus
a1e798a74e use test_p for parameterized test 2026-10-24 01:07:01 +05:30
Tushar Burla
e1d90775be core: fix convertTo() losing values above int32 when converting from FP to 64-bit int
In modules/core/src/convert.hpp, v_store_as() for 64-bit integer destinations (int64_t and uint64_t) from v_float32 rounded into a 32-bit integer (v_int32) before widening, causing values outside the 32-bit signed range (e.g. >= 2^31 in CV_16BF / CV_16F) to saturate to INT32_MIN/INT32_MAX on the SIMD path.

Use buffer-based saturate_cast<int64_t> / saturate_cast<uint64_t> to preserve the full 64-bit destination range, matching the existing precedent for v_store_pair_as(v_float64) and v_store_pair_as(unsigned, v_float32).

Add Core_ConvertTo64Int regression tests across vector and scalar lengths.

Resolves #29996.
2026-10-23 23:18:58 +05:30
Prasadayus
3747f5a3f1 core: restore input matrix when LAPACK HAL declines 2026-10-23 18:10:21 +05:30
Alexander Smorkalov
54fbb6bd86 Pre-release 5.1.0 versions update 2026-10-23 14:28:38 +03:00
Vincent Rabaud
7bd8de1f31 Merge pull request #29909 from vrabaud:gemm
Do not call Lapack for small operations. - #29909

This reduces the cache for GEMM in calibration: the transposed Jacobian is 6 x 2Number points while the result is 6 x 1.

The previous code was only looking at the input number of rows.

### 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-10-23 09:26:44 +03:00
Alexander Smorkalov
059f94689e Merge pull request #30469 from sunhaiyong1978:5.x
core: Add the missing `<climits>` include to intrin_lsx.hpp.
2026-10-23 08:07:01 +03:00
Kumataro
0d0804b567 Merge pull request #30308 from Kumataro:fixGCC16warning
core/dnn: resolve GCC 16 -Wmaybe-uninitialized and -Warray-bounds warnings - #30308

- core(nd_copy): ensure copyBatch only executes runPlans when np > 0.
- dnn(test): add reserve(3) to input vector to quiet compiler bounds checks.

### 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-10-23 08:02:21 +03:00
Alexander Smorkalov
1bafb36701 Merge pull request #30455 from asmorkalov:as/armv7_round_relax_test
Relaxed v_round vs cvRound checks.
2026-10-23 07:44:42 +03:00
Alexander Smorkalov
1de42d414e Merge pull request #30458 from asmorkalov:as/armv7_divide
Updated test data for division to satisfy armv7a.
2026-10-23 07:44:21 +03:00
Sun Haiyong
330c0dbfd5 core: Add the missing <climits> include to intrin_lsx.hpp.
When compiling with GCC 16.2.0, I encountered the following error:

modules/core/include/opencv2/core/hal/intrin_forward.hpp:204:49: error: 'INT_MAX' was not declared in this scope
  204 |     SV32 sat  = v_xor(v_shr<31>(hi), SETALL_S32(INT_MAX)); \
2026-10-23 10:10:05 +08:00
Shiven Solanki
ce58bb1ee7 Merge pull request #30448 from sshivensolanki:fix-ocl-convertto-32s-macos
core: accept both float->int saturation results in OCL ConvertToSaturate test - #30448

Fixes the `macOS-x64 / BuildAndTest` failure from #30386, which makes 5.x macOS-x64 CI red for every PR (e.g. #30302):

```
[ RUN      ] OCL_MatrixOperation/ConvertToSaturate.Accuracy/16, where GetParam() = (CV_32F, CV_32S)
test_matrix_operation.cpp:247: Failure
  cv::countNonZero(diff)
    Which is: 2
```

INT_MAX isn't representable in float, so a saturated `CV_32F -> CV_32S` result can legitimately be either value:

- x86 CPU (`v_round` / `cvRound`) clamps to `CV__FLT2INT_MAX_F` = 2147483520 before converting (since #30007).
- OpenCL `convert_int_sat_rte` and NEON `vcvtnq_s32_f32` give INT_MAX = 2147483647.

So on an x86 host the out-of-range inputs `3e9` and `1e20` differ by 127 between `Mat` and `UMat`. On Apple M1 both sides give INT_MAX, which is why it only shows up on macOS-x64.

For this pair the test now clamps both results to 2147483520 before the exact comparison, i.e. it accepts any value in [2147483520, INT_MAX] as saturated. In-range values and all other depth pairs are still compared exactly.

**Testing** (Apple M1 Pro, OpenCL on; native arm64 build and an x86_64 build run under Rosetta 2)

`Mat::convertTo` vs `UMat::convertTo` for `CV_32F -> CV_32S`:

| input | arm64 CPU | x86_64 CPU | OpenCL |
|---|---|---|---|
| 3e9  | 2147483647 | 2147483520 | 2147483647 |
| 1e20 | 2147483647 | 2147483520 | 2147483647 |

The x86_64 build reproduces the CI mismatch. With this change, on both builds:

- `opencv_test_core --gtest_filter=*ConvertToSaturate*`: 135 passed.
- `opencv_test_core --gtest_filter=OCL_*:*ConvertTo*:*convertTo*:*Core_ConvertScale*`: 7549 passed.

### 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-10-22 18:55:31 +03:00
Alexander Smorkalov
e552fd3c2d Updated test data for division to satisfy armv7a. 2026-10-22 17:20:33 +03:00
Alexander Smorkalov
9502376b96 Relaxed v_round vs cvRound checks. 2026-10-22 15:46:42 +03:00
Abhishek Gola
781f49134b Merge pull request #30430 from sshivensolanki/opt-findnonzero-simd
core: SIMD fast path for findNonZero on 8-bit inputs
2026-10-22 14:30:34 +05:30