Commit Graph

36472 Commits

Author SHA1 Message Date
Arne Baeyens
c4e271c2dc imgwarp add perf tests where src img much smaller then dst img + transparent border
As the existing perf tests don't cover this use case well. Did not do the CONSTANT border type because for that use case the source image is usually projected over about the whole of the destination image so our ROI optimization wouldn't deliver much user value there.

Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
2026-08-23 12:41:59 +02:00
Arne Baeyens
e451f59cda extend imgwarp tests to cover BORDER_TRANSPARENT
Previously were covering only BORDER_REPLICATE and BORDER_REFLECT.

Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
2026-08-23 12:41:53 +02:00
Alexander Smorkalov
f5cce0bdc4 Merge pull request #29717 from asmorkalov:as/mjpeg_disable_test
Disable mjpeg_pixel_format_change test on Windows as it requires FFmpeg wrapper rebuild
2026-08-14 13:19:07 +03:00
Alexander Smorkalov
2eebb803cb Merge pull request #29709 from Nikhi00718:agent/fix-high-channel-ndarray-4x
Fix silent loss of high-channel NumPy dimensions (4.x)
2026-08-14 11:26:24 +03:00
Alexander Smorkalov
77ac6ec9d5 Disable mjpeg_pixel_format_change test on Windows as it requires FFmpeg wrapper rebuild. 2026-08-14 11:21:24 +03:00
Alexander Smorkalov
466dff53c2 Merge pull request #29711 from asmorkalov:revert-29394-fast_accumulate
Revert "Merge pull request #29394 from amd:fast_accumulate"
2026-08-13 22:47:57 +03:00
Alexander Smorkalov
0a17023d1e Merge pull request #29700 from lazerg:fix/issue-29699-ffmpeg-pixfmt-change
videoio: fix FFmpeg VideoCapture ignoring mid-stream pixel format change
2026-08-13 21:46:38 +03:00
NIKHIL
726a0959df python: validate high-channel 3D ndarrays on 4.x 2026-08-13 20:27:50 +05:30
Alexander Smorkalov
9cb2f5e191 Revert "Merge pull request #29394 from amd:fast_accumulate"
This reverts commit c6e84d494c.
2026-08-13 16:19:20 +03:00
Alexander Smorkalov
681d3ecd2b Merge pull request #29695 from Parth1353:fix/26447-cvtcolor-depth-docs
imgproc: document that color conversion depth support varies by code
2026-08-13 16:13:31 +03:00
uwezkhan
52aa8c2961 Merge pull request #29439 from uwezkhan:gdal-write-pixel-channel-bound
gdal: skip raster band mapped to an out-of-range channel in readData - #29439

Repro: read a 3-band GDT_Byte raster (no palette) whose third band is tagged `GCI_AlphaBand`, via `imread(path, IMREAD_LOAD_GDAL)`. ASan reports a heap-buffer-overflow WRITE of size 1 at `grfmt_gdal.cpp:259`.
Cause: an alpha band makes `readData` pass `color = 3`, but the `gdalChannels == 3 && image.channels() == 3` branch of `write_pixel` indexes `Vec3b[channel]` with no bound, so `channel == 3` stores one element past the 3-lane pixel. On the last pixel that lands past the Mat buffer.
Fix (per review): `readData` checks the mapped color index against `img.channels()` in the band loop, before the pixel iteration. An out-of-range band is skipped as a whole with a `CV_LOG_WARNING` naming the band and range, instead of a silent per-pixel guard. Valid RGB rasters decode identically.

### 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
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
- [ ] The feature is well documented and sample code can be built with the project CMake
2026-08-13 16:12:22 +03:00
Pratham Kumar
fece2acfba Merge pull request #28728 from pratham-mcw:calchist-simd-opt
imgproc: add simd support for calchist & calchist1d function - #28728

- This PR adds OpenCV SIMD intrinsics-based optimizations to the Calchist and calcHist1d function for improved performance on Windows-ARM64 platforms.
- The optimized implementation uses vectorized operations to accelerate histogram computation.
- In x64 architecture, `calcHist1d` benefits from IPP-based optimized implementations. However, on ARM64 platforms, the execution falls back to scalar implementation, which results in lower performance.
- After introducing these changes, the calcHist and calchist1d function showed noticeable performance improvements on Windows-ARM64.

**Performance Benchmarks:**
<img width="1247" height="460" alt="image" src="https://github.com/user-attachments/assets/ed740d87-158e-49d4-889e-9c7dda482a63" />
<img width="552" height="210" alt="image" src="https://github.com/user-attachments/assets/76b9e46e-304e-480c-9a57-af0aba6e937a" />

- [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
2026-08-13 14:32:47 +03:00
Lazizbek Ergashev
28026fe2cf videoio: fix FFmpeg VideoCapture ignoring mid-stream pixel format change
(cherry picked from commit f3c9241611cfb46dd17de2b3e3f25f6fe36b71f8)
2026-08-13 14:34:45 +05:00
Madan mohan Manokar
c6e84d494c Merge pull request #29394 from amd:fast_accumulate
imgproc: Optimized accumulate with AVX512 dispatch and AVX2 kernels improved #29394

- Add AVX512_SKX/AVX512_ICL to accum dispatch
- Fine tune AVX2 kernels for float, cn = 1 and 3 cases.

### 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-08-13 12:21:29 +03:00
Aaron
bfa07fc52a Merge pull request #29638 from aarochu:feature-medianblur-arbitrary-channels
imgproc: support arbitrary channel counts in medianBlur #29638

## Summary

Fixes #29592.

`cv::medianBlur`/`cv2.medianBlur` rejects `CV_8U` images with channel counts other than 1, 3, or 4 whenever the optimized large-kernel path is needed — `ksize >= 7` always, and `ksize == 5` on SIMD-enabled builds (the `ksize == 3`/`ksize == 5`-without-SIMD "sort net" path already handles arbitrary channel counts generically, so this only affects the fast path):

```
src.depth() == CV_8U && (cn == 1 || cn == 3 || cn == 4)
```

Median filtering is channel-independent, so there's no correctness reason for this restriction — it's an implementation detail of the optimized SIMD kernels (which hard-code 1/3/4-channel-interleaved layouts), not a property of the algorithm. Users with 2, 5, 6, 9+ channel images (multispectral, feature maps, stacked masks) currently have to split, filter, and re-concatenate manually outside the library — exactly the workaround already implemented downstream in Albucore, per the issue.

## Fix

In `cv::medianBlur` (`modules/imgproc/src/median_blur.dispatch.cpp`), before dispatching to HAL/OpenCL/the optimized SIMD path: if the channel count isn't 1, 3, or 4, split the image into individual channels, run `medianBlur` on each one independently (a single channel is always supported by every existing path, recursively), and merge the results back together. This touches none of the performance-critical kernels — it's a fallback that only runs for channel counts those kernels don't support, and the existing 1/3/4-channel fast paths are completely unaffected.

## Test plan

- [x] Added `Imgproc_MedianBlur.arbitrary_channel_count_29592` in `modules/imgproc/test/test_filter.cpp`, covering channel counts `{1,2,3,4,5,6,9}` × kernel sizes `{3,5,7,9}`. For each combination it asserts `medianBlur` doesn't throw, preserves size/type, and — critically — produces output bit-identical to filtering each channel independently via `cv::split`/`cv::merge` (the reference/expected behavior).
- [x] Built `opencv_core` + `opencv_imgproc` + `opencv_test_imgproc` locally (MSVC) and ran the new test — passes.
- [x] Ran the full existing `Imgproc_MedianBlur.*`, `Imgproc_Filter2D.*`, `Imgproc_Blur.*`, `Imgproc_GaussianBlur.*` suites — all 14 pass, no regressions.
- Note: `GaussianBlurVsBitexact`, `sepFilter2D_types`, and `StackBlur` tests in the same binary fail/crash in this local environment, but reproduce identically on unmodified `4.x` with no changes at all — confirmed pre-existing and unrelated to this change (not investigated further, out of scope here).
2026-08-13 11:35:16 +03:00
Alexander Smorkalov
4afa329a78 Merge pull request #29696 from Parth1353:fix/29694-avx512icl-baseline-dispatch
core, imgproc: fix build when AVX512_ICL is in the baseline
2026-08-13 10:03:13 +03:00
Parth Saini
e24dc1ff4c core: add CV_CPU_GET_FN_PTR_<OPT>() to resolve dispatched function pointers
The generated cv_cpu_helper.h sets CV_TRY_<OPT> to 1 both when <OPT> is a
dispatch target and when it is part of the baseline, but an opt_<OPT> namespace
is only emitted for the dispatch case: __ocv_add_dispatched_file() guards it
with CPU_DISPATCH_FINAL, and a baseline optimization is deliberately kept out of
that list. Code that hand-rolls "#if CV_TRY_<OPT> ... opt_<OPT>::fn" therefore
fails to compile as soon as the optimization lands in the baseline, e.g. with
-DCPU_BASELINE=AVX512_ICL or -march=native on an ICL capable CPU:

  lut.dispatch.cpp:22:16: error: 'opt_AVX512_ICL' has not been declared

CV_CPU_CALL_<OPT>() already handles the namespace selection for a call. Add the
same thing for code that needs the function pointer instead:

  CV_CPU_GET_FN_PTR_<OPT>(fn)       per optimization
  CV_CPU_GET_FN_PTR_BASELINE(fn)    chain terminator
  CV_CPU_DISPATCH_FN(fn, modes)     full chain, mirrors CV_CPU_DISPATCH()

In the baseline case it resolves to cpu_baseline::fn, which is the <OPT> build
of the kernel, so no implementation is lost and no second copy is emitted. In
the dispatch case it keeps the cv::checkHardwareSupport() test and returns
opt_<OPT>::fn, and it compiles out when the optimization is unavailable.

Use it in the two places that hit this, which also removes the hand-written
preprocessor blocks. Generated code for the dispatch configuration is unchanged
(byte-identical .text with -DCPU_BASELINE=SSE3 -DCPU_DISPATCH=AVX512_ICL).

Fixes #29694
2026-08-12 18:10:38 +05:30
Parth Saini
3043094d71 imgproc: document per-code depth support on cvtColor/demosaicing src param
cvtColor's @param src promised 8U, 16U and 32F unconditionally, but the accepted
depths depend on the conversion code: CV_16U is rejected by COLOR_BGR2HSV,
COLOR_BGR2Lab, COLOR_BGR2Luv and the packed 16-bit codes, while COLOR_BGR2GRAY,
COLOR_BGR2XYZ, COLOR_BGR2YUV and RGB<->RGB accept it. That is what #26447
reported.

State it on @param src and point at the [8U]/[16U]/[32F] markers already
documented on ColorConversionCodes. The @note only said the source "must be of
an appropriate type", which is now redundant, so drop it from both functions.

demosaicing has the same problem: the Variable Number of Gradients codes accept
8-bit input only, while the other Bayer codes also accept 16-bit.

Fixes #26447
2026-08-12 12:35:49 +05:30
Alexander Smorkalov
21d60a9afe Merge pull request #29693 from asmorkalov:as/handeye_test_4.x
Backported python tests for calibrateHandEye and calibrateRobotWorldHandEye
2026-08-11 17:25:59 +03:00
Alexander Smorkalov
f347805418 Merge pull request #29533 from Aadhu23:fix-29504-clean
videoio: fix build with FFmpeg 9 after AVCodec::pix_fmts removal
2026-08-11 17:21:05 +03:00
Alexander Smorkalov
5fe174365d Backported python tests for calibrateHandEye and calibrateRobotWorldHandEye. 2026-08-11 15:28:32 +03:00
Alexander Smorkalov
c0166c617d Code review fixes. 2026-08-11 13:01:55 +03:00
Arnesh Banerjee
83ed22ca28 videoio(ffmpeg): use avcodec_get_supported_config for framerates on FFmpeg 9
AVCodec::supported_framerates was deprecated in FFmpeg 7.1 and removed in
FFmpeg 9, so direct field access no longer builds against FFmpeg 9.

Read the supported frame rate list through avcodec_get_supported_config()
when building against libavcodec 61.13.100 or newer. That call returns the
same list plus its entry count, so the loop iterates by count instead of the
old sentinel terminator. Older FFmpeg keeps the previous field access.
2026-08-11 12:10:00 +03:00
Aadhu23
700cd32ffd videoio: support FFmpeg after AVCodec::pix_fmts removal 2026-08-11 12:07:21 +03:00
Alexander Smorkalov
49c8d21f16 Merge pull request #29674 from karpovantonme:docs/read-options-param
imgcodecs: name the parameter setReadOptions actually takes 🤖🤖🤖
2026-08-11 09:34:52 +03:00
Alexander Smorkalov
bbab7da39f Merge pull request #29563 from developer0hye:agent/msmf-close-event-handle
videoio(MSMF): close leaked SourceReaderCB Event handle 🤖🤖🤖
2026-08-11 09:31:30 +03:00
Alexander Smorkalov
dea9ce421d Merge pull request #28517 from asmorkalov:as/charuco_bindings
Fixed bindings generation for Charuco boards #28517

Fixes https://github.com/opencv/opencv/issues/28512

### 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-08-10 19:45:53 +03:00
Alexander Smorkalov
d53047927b Merge pull request #29661 from anupamme:fix-repo-opencv-v004-bilateral-filter-integer-overflow
harden: add integer overflow check in bilateralFilter.cpp
2026-08-10 19:33:49 +03:00
aryan chaudhary
9b1aa94e69 Merge pull request #29623 from Aryan171:fix/features2d-akaze-subsample-overflow
features2d: fix heap buffer overflow in AKAZE generateDescriptorSubsample #29623

Prevent out-of-bounds write in `generateDescriptorSubsample()` during AKAZE MLDB descriptor generation when `nchannels < 3` (e.g. `nchannels = 2`).

Fixes #29613 

### Summary of Changes

- **Module:** `features2d` (AKAZE)
- **Problem:** When `generateDescriptorSubsample()` is called with `nchannels < 3`, the code hardcoded 3-channel matrix index offsets (`+ 0`, `+ 1`, `+ 2`). Since `comps` allocates rows based on `nchannels * npicks`, writing to index offset `+ 2` when `nchannels = 2` causes a heap buffer overflow past the last row of `comps`.
- **Fix:** Replaced hardcoded 3-channel matrix index assignments with a dynamic loop that iterates over `0` to `nchannels - 1`.
- **Regression Test:** Added `Features2D_AKAZE.Subsample_Channels_Overflow_Fix` in `modules/features2d/test/test_akaze.cpp`.
- 
### Acknowledgments

Thanks to @abhishek-gola for reviewing the test and suggesting the correct approach.

### 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 (`4.x`)
- [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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-08-10 15:26:45 +03:00
Anton Karpov
2459ac65fe imgcodecs: name the parameter setReadOptions actually takes 2026-08-07 15:04:27 +03:00
Abhishek Gola
77dfa297d0 Merge pull request #29640 from yvonnelxxxx/fix/int-overflow-absdiff
fix: signed-integer-overflow in c_absdiff<int>
2026-08-06 19:29:06 +05:30
Abhishek Gola
59a0461d50 Merge pull request #29567 from Adel-Ayoub/fix/tiff-planar-decode
imgcodecs: fix decoding of TIFF images with separate planes
2026-08-06 19:09:46 +05:30
Abhishek Gola
49ca26154e Merge pull request #29554 from mvanhorn/fix/29279-ipp-warpaffine-nearest-bitexact
imgproc: route IPP warpAffine INTER_NEAREST to native kernel for bit-exactness 🤖🤖🤖
2026-08-06 19:09:35 +05:30
Abhishek Gola
3ea443b670 Merge pull request #29667 from intel-staging/ipp/iw_build_fix
Build fix: IPP integration wrapers
2026-08-06 13:37:50 +05:30
Abhishek Gola
a21f7a1d1b Merge pull request #29668 from karpovantonme/docs/memset-param-names
dnn: fix the parameter names documented for memset 🤖🤖🤖
2026-08-06 13:32:30 +05:30
Adel-Ayoub
ff6112c09e imgcodecs: fix decoding of TIFF images with separate planes 2026-08-05 23:26:27 +01:00
Anton Karpov
f625c00f5a dnn: fix the parameter names documented for memset
The four memset overloads in cuda4dnn document their first parameter as
src while it is called dest, and the directions are the wrong way round:
the output buffer is marked [in] and the 8-bit fill value is marked [out].

The prose above two of them already says dest, only the tags disagree.
2026-08-05 15:48:52 +03:00
Victor Getmanskiy
64a04b540a Build fix: IPP integration wrapers 2026-08-05 12:41:12 +02:00
anupamme
5940b25d34 fix: V-004 security vulnerability
Automated security fix generated by OrbisAI Security
2026-08-04 14:18:09 +00:00
Abhishek Gola
4bee6895eb Merge pull request #29643 from uwezkhan/apng-dispose-elem-size
fix apng background dispose overrun in png readData
2026-08-04 09:56:19 +05:30
Yvonne
5a5ac33c87 make absdiff overflow test accept saturate or wraparound 2026-08-04 11:55:18 +08:00
Yvonne
154dac563f fix test for ARM 2026-08-03 17:05:41 +08:00
Abhishek Gola
6e82dddfb5 Merge pull request #29649 from kaingwade/thead_rvv_check
Update T-Head RVV check
2026-08-03 12:58:47 +05:30
Yvonne
de15c6af68 core(arithm): add regression test for cv::absdiff CV_32S overflow 2026-08-03 14:51:35 +08:00
kaingwade
caaabca123 Update T-Head RVV check 2026-08-03 10:54:36 +08:00
Uwez Khan
6ad702680e fix apng background dispose overrun in png readData 2026-08-01 02:13:45 +05:30
Matt Van Horn
92d1ebe1a0 docs: trim the NEAREST-fallback comments per review 2026-07-31 08:02:50 -07:00
Yvonne
4edef8f4bf fix signed-int-overflow in c_absdiff<int> 2026-07-31 16:53:42 +08:00
Abhishek Gola
e35ad60e4e Merge pull request #29544 from xi-guo-0/core-optimize-extract-channel-8uc2
core: optimize 8UC2 channel extraction
2026-07-30 16:49:19 +05:30
Abhishek Gola
f42fa7b214 Merge pull request #29553 from mvanhorn/fix/26746-warn-external-grfmt-fallback
cmake: warn when external image-codec library is requested but not found 🤖🤖🤖
2026-07-30 16:38:23 +05:30