Commit Graph

27719 Commits

Author SHA1 Message Date
Shiven Solanki
5014b24db5 dnn: keep CV_64S precision in Resize2 nearest mode (#31036)
* dnn: keep CV_64S precision in Resize2 nearest mode

Fixes #31035

* dnn: use ptr<>() in Resize2 int64 test to fix Debug assert on 4D Mat
2026-11-24 13:04:50 +05:30
Alexander Smorkalov
ed4ee4d5b2 Merge pull request #31097 from sshivensolanki:dnn-cumsum-empty-axis
dnn: fix CumSum crash when the scan axis has length 0
2026-11-24 10:02:45 +03:00
Abhishek Gola
1056624e1c dnn: fix CumProd crash when the scan axis has length 0 (#31063)
* dnn: fix CumProd crash when the scan axis has length 0

* dnn: use Mat::empty() for the CumProd empty-input check

Return early from forwardImpl() when the input has no elements. The output already has the right empty shape. The check comes after normalize_axis(), so an out-of-range axis is still reported.
2026-11-24 10:45:03 +05:30
Madan mohan Manokar
19f86d566c Merge pull request #30974 from amd/port_5.x_opencl_boxfilter
imgproc: Port 4.x enable boxFilter OpenCL fast paths on all aligned GPUs (5.x)

This PR only removes the Intel vendor gate as a port of upstream OpenCV PR #29805.

No changes are made to the underlying OpenCL kernels or dispatch logic.
Regression is observed on Apple M5 when filterSmall is used, including cases up to about 3.5× slower at odd, large sizes.
Earlier benchmark data in imgproc: Enable boxFilter OpenCL fast paths on Non-Intel GPUs. #29805 showed gains on AMD and NVIDIA GPUs for the small-kernel cases.
The filterSmall gate is therefore extended from Intel to AMD and NVIDIA. Apple and other vendors stay on the general kernel.
Any potential kernel correctness, ROI, aliasing, boundary handling, or in-place processing issues are pre-existing implementation concerns and should be evaluated separately in follow-up PRs. Such issues are outside the scope of this change.
2026-11-24 10:14:09 +05:30
Abhishek Gola
eb30136494 Merge pull request #30924 from pctablet505/fix-dnn-cuda-gemm-square-transpose-5x
dnn: avoid transposing square Gemm weights in-place in initCUDA (5.x) 🤖🤖🤖
2026-11-24 09:44:47 +05:30
Abhishek Gola
5eb67caa6b Merge pull request #31093 from vinaykumar11-maker/fix-empty-case-msvc
dnn(test): remove empty CASE() entry that breaks MSVC build with OpenVINO
2026-11-24 09:37:45 +05:30
Abhishek Gola
f15f296e1b Merge pull request #31023 from v-hogood/fix-lightglue-swift-name
features(objc): fix conflicting Swift name for LightGlueMatcher.create
2026-11-24 09:24:07 +05:30
Karnajeet Gosavi
c309fe76d4 Merge pull request #31029 from kg290/codex/ffmpeg-frame-size-warning
videoio: Report expected and actual FFmpeg frame sizes
2026-11-24 09:22:10 +05:30
Shiven Solanki
150a25256c dnn: fix CumSum crash when the scan axis has length 0 2026-11-23 22:25:12 +08:00
vinay kumar
958be87d74 dnn(test): remove empty CASE() entry that breaks MSVC build with OpenVINO 2026-11-23 18:14:55 +05:30
Shiven Solanki
9637fe1290 Merge pull request #30999 from sshivensolanki:core-mean-bool
core: support CV_Bool input in mean and meanStdDev - #30999

Fixes #30998

### Problem

`cv::mean` and `cv::meanStdDev` fail with `func != 0` on a `CV_Bool` source, because there is no `CV_Bool` sum kernel. `cv::sum` and `cv::norm` already handle `CV_Bool`.

### Fix

For a `CV_Bool` source, compute the result from `countNonZero` and `total()` instead of the sum kernels: mean = nz/n, and stddev = sqrt(p*(1-p)) with p = nz/n. A mask, or more than one channel, reports `StsNotImplemented`.

### Tests

Added `Core_MeanStdDev.bool_input`: a 1-channel `CV_Bool` source (including a raw `255` byte) must give mean 0.5 and stddev 0.5, and both functions must throw when a mask is given. It fails on the current code with the assert and passes with the fix. The full `opencv_test_core` run passes.

### 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-23 15:01:58 +03:00
Shiven Solanki
7f57e38b02 dnn: use Mat::empty() for the CumProd empty-input check 2026-11-23 18:58:12 +08:00
Virat Pratap
79ae232914 docs(imgproc): fix math rendering in color formula
Clarify the max operator and group ChannelRange as one identifier. Addresses #31077.
2026-11-23 08:55:17 +00:00
Abhishek Gola
fb6166e54b Merge pull request #31044 from harshil-sri/fix-0d-threshold-lut
core, imgproc: support 0D Mat in LUT and threshold

Give a 0D input a 1x1 header before the row-based code runs, the same way #30704 normalizes 1D inputs in gemm:

threshold / thresholdWithMask: src (and mask) are viewed as 1x1, so the output is 1x1, the same as the other imgproc functions return for 0D input.
LUT: src and dst get 1x1 headers for the HAL and parallel paths. dst is created with createSameSize, so the result itself stays 0D.
2026-11-23 09:27:52 +05:30
Abhishek Gola
d2c6f944cf Merge pull request #31034 from sshivensolanki/dnn-cast-uint32-uint64
dnn: support UINT32 and UINT64 targets in Cast

Map ONNX UINT32 (12) and UINT64 (13) to CV_32U and CV_64U in mapToCvDepth.
Add CV_32U and CV_64U cases to truncateFloatToInt, so float inputs truncate toward zero as ONNX requires, instead of being rounded by convertTo.
Allow CV_32U and CV_64U in the outputType parameter.
2026-11-23 09:27:12 +05:30
Abhishek Gola
e4ec28617f Merge pull request #31039 from ish1416/dnn-reduce-support-unsigned
dnn: support CV_32U and CV_64U in Reduce layers

Fix
In modules/dnn/src/layers/reduce2_layer.cpp: Add CV_32U and CV_64U to getTypes validation.
In modules/dnn/src/layers/reduce_layer.cpp: Add CV_32U and CV_64U to getTypes and typeDispatch (opDispatch<uint32_t> and opDispatch<uint64_t>).
In modules/dnn/test/test_int.cpp: Extend Test_Reduce_Int to include CV_32U and CV_64U.
In modules/dnn/test/test_layers.cpp: Add Layer_Test_Reduce_Unsigned parameterized test checking MAX, MIN, and SUM on CV_32U and CV_64U with values greater than 2^31 to verify unsigned comparison logic.
2026-11-23 09:26:18 +05:30
Shiven Solanki
36596cbeca dnn: fix CumProd crash when the scan axis has length 0 2026-11-23 08:50:36 +08:00
Abhishek Gola
2ce6479ab8 Merge pull request #31047 from sshivensolanki/dnn-range-zero-delta
dnn: reject zero delta in Range layer

Check that delta is not zero in getRangeParams() before rangeSize() is called: CV_CheckNE for the float branch and CV_CheckTrue(idelta != 0, ...) for the integer branch, since CV_CheckNE has no int64_t overload. Both forward() and getMemoryShapes() go through getRangeParams(), so both are covered.
2026-11-22 21:31:16 +05:30
Ishita Singh
4bd226ed15 dnn: support CV_32U and CV_64U in Reduce layers 2026-11-22 20:35:00 +05:30
Shiven Solanki
5bb1be7693 imgproc: support 5.x depths in remap/warp with INTER_NEAREST (#30595)
* imgproc: support 5.x depths in remap/warp with INTER_NEAREST

nn_tab in cv::remap only had entries for CV_8U..CV_64F, so remap,
warpAffine and warpPerspective with INTER_NEAREST failed with
"nnfunc != 0" for CV_16F, CV_16BF, CV_Bool, CV_64U, CV_64S, CV_32U and
both fp8 depths. Nearest neighbor only copies pixels, so add the
remapNearest instances for these types, in both the absolute and the
WARP_RELATIVE_MAP rows. Using the real element types keeps the border
value conversion right (e.g. CV_Bool border 2 becomes 1).

Add an Imgproc_Warp_NearestNewDepths test.

* imgproc: use MatDepth in Imgproc_Warp_NearestNewDepths

A plain int parameter prints a failing case as GetParam() = 13. MatDepth prints the depth name instead.

* imgproc: convert remap nearest border once, dispatch copy by element size
2026-11-22 19:28:31 +05:30
Shiven Solanki
7e2201571d Merge pull request #31025 from sshivensolanki/dnn-onehot-uint32-bool
dnn: support CV_32U, CV_64U and CV_Bool values in OneHot

Add the missing case labels, calling the existing runKernel<uint32_t>, runKernel<uint64_t> and runKernel<bool>.
tensorToScalar could not read CV_64U tensors. It now reads them as uint64_t and writes the result without going through int64_t, so values above INT64_MAX are not cut down. The output conversion moved into a small storeScalar template, called with double, int64_t or uint64_t; the results for the other input types are unchanged.
2026-11-22 18:35:51 +05:30
Tushar Burla
f3a7576b57 dnn(onnx): add support for ONNX Col2Im operator
- Implement Col2ImLayer supporting static/dynamic output shape inference and spatial summation
- Enforce CV_32F data input and int32/int64 shape inputs in getTypes() and forward()
- Require 1-D rank and CV_64S value range-checking (rejecting > INT_MAX) for image_shape and block_shape
- Support multi-dimensional spatial blocks, dilations, pads, and strides
- Parse image and block shapes using OpenCV tensorToIntVec()
- Parallelize across batch and channels using a single parallel_for_ with batch*channel <= INT_MAX guard
- Guard wide-coordinate offsets and domain arithmetic against signed overflow
- Add unit and parameterized tests in test_layers for shape inference, type validation, empty inputs, oversized shapes, malformed ranks, coordinate bounds, malformed attributes, and 4-D spatial values
- Add Col2Im performance benchmark baseline in modules/dnn/perf/perf_col2im.cpp
- Skip Col2Im conformance tests in OpenVINO filter
- Un-denylist all 5 official ONNX conformance tests

# Conflicts:
#	modules/dnn/test/test_layers.cpp

# Conflicts:
#	modules/dnn/test/test_layers.cpp
2026-11-22 11:32:10 +05:30
Shiven Solanki
45833cc1aa dnn: reject zero delta in Range layer 2026-11-22 10:58:26 +08:00
Harshil
942aa1aabb core, imgproc: support 0D Mat in LUT and threshold 2026-11-22 02:28:24 +05:30
Shiven Solanki
ad55604af8 dnn: support UINT32 and UINT64 targets in Cast 2026-11-21 19:52:12 +08:00
Shiven Solanki
c8ac3039be dnn: support CV_32U and CV_64U outputs in EyeLike 2026-11-21 18:03:13 +08:00
Abhishek Gola
e49cba7856 Merge pull request #31013 from sshivensolanki/dnn-clip-uint32-uint64
dnn: support CV_32U and CV_64U in Clip default bounds
2026-11-21 14:00:48 +05:30
Abhishek Gola
d12ffef79b Merge pull request #30817 from ternaus/codex/fractional-area-resize
imgproc: reuse filtered rows in fractional area resize 🤖🤖🤖
2026-11-21 09:44:33 +05:30
Shiven Solanki
fe06ceaca5 dnn: support CV_32U and CV_64U in Clip default bounds 2026-11-21 12:07:01 +08:00
Abhishek Gola
c7a8a7afbd Merge pull request #31004 from sshivensolanki/dnn-tensortoscalar-int8-uint16
dnn: read CV_8S and CV_16U correctly in tensorToScalar
2026-11-21 09:20:43 +05:30
Abhishek Gola
63cb0349bb Merge pull request #30985 from RITU940/fix/triangulate-column-roi-stride
geometry: respect row stride in triangulatePoints

The fix uses step1(0) to advance between points in a two-channel column matrix, while keeping the existing two-scalar step for row matrices. I applied this separately to both camera inputs and used size_t for the scalar offsets.
The triangulation algorithm itself is unchanged, and packed-column behavior from #28829 is preserved.
I also added a regression test covering float and double inputs, including contiguous columns, cloned ROIs, row layouts, and non-contiguous column ROIs on the left camera, right camera, or both.
2026-11-21 09:20:13 +05:30
Abhishek Gola
fc79cd24c2 Merge pull request #30990 from pranayr710/fix/compare-cv-bool
core: add the missing CV_Bool kernel to cv::compare

The fix is not simply reusing the uchar kernel. A CV_Bool byte is not guaranteed to be 0 or 1:
Mat wrapping an external buffer performs no conversion, so other values are reachable through
the public API, and comparing the raw bytes would order 2 above 1 when both mean true.
2026-11-21 09:19:22 +05:30
Howard Good
65b92805f2 features(objc): fix conflicting Swift name for LightGlueMatcher.create 2026-11-20 15:37:39 -08:00
Varun Jaiswal
b6d8ca41b1 Merge pull request #30977 from varun-jaiswal17/docs-5x-version-wording
documentation fix 5.0 to 5.x - #30977
 
Replace stale "OpenCV 5.0" current-version wording with "5.x" in the 5.x docs (landing page, sidebar, prebuilt-binaries and transition-guide tutorials)

### 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-20 16:42:37 +03:00
Alexander Smorkalov
21b23e402f Merge pull request #31001 from sshivensolanki:dnn-hardmax-int64-bool
dnn: support CV_64S and CV_Bool in Hardmax forward
2026-11-20 16:12:09 +03:00
Abhishek Gola
22db6f41b9 Merge pull request #30398 from abhishek-gola/non-cpu-hal
core: non-CPU HAL (cv::accel) with a CUDA backend

What this PR adds: cv::accel, a non-CPU HAL in core, kept to a minimal first version.

Explicit placement: UMat::createOn(device, shape, type), Mat::upload(device) and UMat::upload(device). Mat::upload() returns once the Mat has been read; UMat::upload() returns the same UMat when it is already on that device.
Functions with an accelerator hook (cv::flip and cv::transpose in this PR) run on the device stored in the input's UMatData. Their output is created there with createOn(), also when the backend declines the call and the CPU runs it. Other functions run on the CPU as before.
One allocator per backend; each buffer keeps its device in UMatData::allocatorContext.
One stream per device and CPU thread (Device::threadStream()). Work of one thread runs in order; work of different threads is synchronized explicitly with cv::accel::synchronize(device).
Operations are reached with device.ops<accel::CoreOps>("core") and called directly. A stream keeps the buffers of queued work alive until it finishes (Stream::retain()), as the OpenCL backend does with a running kernel's UMats.
In-place calls are handled by each operation: the CUDA backend swaps mirrored elements for an in-place flip and transposes square matrices in place.
A CUDA backend with flip and transpose kernels. Discrete GPUs get memory from a stream-ordered pool that keeps freed memory for reuse while the pool holds less than a quarter of the device's memory, and returns the rest to the driver. On a GPU the build has no kernels for, the calls fall back to the CPU.
2026-11-20 17:54:15 +05:30
Shiven Solanki
884de0655d doc(core): fix output type rules for mulTransposed and calcCovarMatrix (#30987)
* doc(core): fix output type rules for mulTransposed and calcCovarMatrix

* doc(core): describe calcCovarMatrix mean depth rule per overload

* doc(core): drop redundant gemm note from mulTransposed src
2026-11-20 17:34:11 +05:30
Abhishek Gola
319fa030a2 Merge pull request #30822 from iammanoj807/fix/mixed-depth-64bit-add-sub
core: add and subtract a 64-bit integer with a narrower integer in 64-bit integers 🤖🤖🤖
2026-11-20 17:06:51 +05:30
Abhishek Gola
e03d01a414 Merge pull request #30973 from vrabaud/avif
Fix sanitizer bugs in OpenCV image warping

Strip BORDER_ISOLATED and validate borderType (0 <= borderType <= BORDER_TRANSPARENT)
Align cv::borderInterpolate (copy.cpp) and borderInterpolate_fast
Only compute tl_ofs in scalar bicubicCoeffs when all_inliers is true
2026-11-20 16:31:34 +05:30
Shiven Solanki
7410814bf7 dnn: read CV_8S and CV_16U correctly in tensorToScalar 2026-11-20 17:25:31 +08:00
Abhishek Gola
ae3d5ae750 core: cap the accel CUDA pool at a quarter of device memory and document that UMat::clone() stays on its device
Signed-off-by: Abhishek Gola <abhishek.gola@bigvisionllc.com>
2026-11-20 14:47:31 +05:30
Alexander Smorkalov
ef693903f5 Merge pull request #30989 from sshivensolanki:core-keypoint-overlap-nan
core: fix NaN in KeyPoint::overlap for internally tangent keypoints
2026-11-20 11:58:48 +03:00
Abhishek Gola
f672e8b1c8 core: bound the accel CUDA pool and fix its out-of-memory trim, fall back on GPUs without kernels and keep UMat::clone() on its device
Signed-off-by: Abhishek Gola <abhishek.gola@bigvisionllc.com>
2026-11-20 14:00:53 +05:30
Shiven Solanki
e9b03f5d0a dnn: support CV_64S and CV_Bool in Hardmax forward 2026-11-20 15:55:33 +08:00
pranayr710
01bdef3cab core: add the missing CV_Bool kernel to cv::compare
Comparing two CV_Bool matrices threw "no kernel for this op/type combination" for all six
comparison operations, while the matrix/scalar overload of the same function worked.
compareByType had a case for every other depth, CV_32U, CV_64U and CV_64S included, so
CV_Bool was the only one left out.

The uchar kernel is not a correct substitute. A CV_Bool byte is not guaranteed to hold 0 or
1, since a matrix wrapping an external buffer is never converted, and comparing the raw
bytes would order 2 above 1 when both mean true. countNonZero, norm, sum and the scalar
compare overload all already read CV_Bool logically, and notKernel documents the same rule
for bitwise NOT.

scalarCompareKernel takes an isBool template parameter that normalises each operand to 0/1
before comparing. It is a compile time constant, so the existing instantiations are
unchanged.
2026-11-20 13:24:29 +05:30
abhishek-gola
f23446318f core: fix accel transpose between regions of one buffer, CUDA < 11.2 builds and OpenCL images of foreign UMats
Signed-off-by: abhishek-gola <abhishek@opencv.org>
2026-11-20 12:54:06 +05:30
Shiven Solanki
1ae9b2b523 core: support 1D Mat in findNonZero
Fixes #30995
2026-11-20 14:37:51 +08:00
Abhishek Gola
4b0b7c6086 Merge pull request #30378 from kari-pikkarainen/fix/photo-debevec-gauge-row-5.x
photo: weight the CalibrateDebevec gauge equation like the data equations (5.x) 🤖🤖🤖

the CalibrateDebevec gauge equation g(128) = 0 is weighted with the hat weight of the middle value instead of 1, so the offset of the response curve no longer depends on float32 rounding in the solver. calibrate.cpp is identical on 4.x and 5.x.
2026-11-20 10:36:23 +05:30
Abhishek Gola
c8ef5d67e2 imgproc: enable medianBlur OpenCL path on all aligned 8UC1 images (5.x) (#30975)
Remove the Intel-only gate for medianFilter3_u/medianFilter5_u when cn==1 and dimensions meet the alignment requirements.

Port of https://github.com/opencv/opencv/pull/29803.
2026-11-20 10:35:24 +05:30
Abhishek Gola
ecd208bc9f Merge pull request #30976 from ternaus/codex/pow-zero-any-channel
core: fix pow with zero exponent on high-channel images 🤖🤖🤖

The zero-exponent branch of cv::pow fills the destination with a four-component Scalar. CPU outputs with more than four channels reject it. Use a single numeric input that broadcasts to every channel for this case. CUDA output continues through the four-component path required by its OutputArray implementation.

The 5.1 wheel reproduces the assertion for five and nine channels. A patched ARM64 Release core build passed a native 24-case check across Mat and UMat, CV_8U, CV_16F and CV_32F, and channels 1, 4, 5 and 9. Added a parameterized Core regression test.
2026-11-20 09:15:31 +05:30