Commit Graph

26414 Commits

Author SHA1 Message Date
Abhishek Gola
086e686016 core: enable FP16 conversions on MSVC ARM64 (#31185)
Three changes:

intrin_neon.hpp — MSVC versions of v_load_expand / v_pack_store over the raw intrinsics
system.cpp — report FP16 on Windows ARM64, matching the aarch64 branch at line 585. Baseline
features are verified at startup, so without this the library builds and then refuses to run
cpu_fp16.cpp — MSVC ARM64 branch for the check, written with _ARM64_DISTINCT_NEON_TYPES set
so the check and the library agree. The old one did not, which is why it passed while the build
failed
2026-11-30 22:38:11 +05:30
NIKHILA
d3dea48372 imgproc: avoid pointPolygonTest integer overflow for large coordinates 🤖🤖🤖 (#31213)
* test: cover pointPolygonTest with large integer coordinates

* test: exercise overflowing diagonal products

* imgproc: avoid overflow in pointPolygonTest cross products

* imgproc: clarify coordinate product precondition and sign
2026-11-30 22:37:24 +05:30
Pratham Kumar
e621405b9d video: parallelize FarnebackPolyExp and FarnebackUpdateMatrices using parallel_for_ (#30586)
* video: parallelize FarnebackPolyExp and FarnebackUpdateMatrices using parallel_for_

* tune Farneback parallel_for_ stripes and extend tests

* use scoped thread count in Farneback threading test

* hoist Farneback matrices update and parallelize Gaussian flow loop

* bound Farneback PolyExp stripes and consolidate thread test

* add large odd-size case to Farneback multithread test
2026-11-30 22:34:57 +05:30
Pratham Kumar
8f0e25a89d Merge pull request #31129 from pratham-mcw/decolor-opt
Replace the std::pow calls with repeated multiplication (decolorPow), which for exponents 0/1/2 is the exact same arithmetic, not an approximation.
Take row pointers (Mat::ptr) instead of Mat::at in both polynomial loops.
Transpose dest/dest1 once in gradvector and read them row-major instead of walking columns.
Thread the full-resolution pass in grayImContruct with parallel_for_ over image rows, the polynomial terms are gathered once up front and each row accumulates independently, so the result is scheduler-independent. Below the element-count cutoff it runs as a single invocation.
Added a perf test (modules/photo/perf/perf_decolor.cpp).
2026-11-30 22:29:13 +05:30
Abhishek Gola
99c35458fe Merge pull request #31267 from abhishek-gola/fix/rvv-boxfilter-reflect-4x
Fix RVV box filter with reflective ROI borders (4.x)
2026-11-30 21:06:30 +05:30
Pratham Kumar
6bcac1ae69 imgproc: parallelize and vectorize cv::warpPolar forward map build (#30997)
In cv::warpPolar(), the forward path (no WARP_INVERSE_MAP) builds both remap tables, mapx and mapy, in a serial scalar loop over the output rows before calling remap(). Every output row is independent, so this loop can be threaded and vectorized.
2026-11-30 18:33:20 +05:30
Abhishek Gola
b8051721da Fix RVV box filter with reflective ROI borders 2026-11-30 18:20:19 +05:30
Abhishek Gola
1e611f6fc0 dnn: keep the TopK axis attribute unchanged in finalize (#31261)
TopKLayerImpl::finalize previously normalized the axis attribute by
overwriting this->axis with normalize_axis(axis, input_shape.size()).
When the layer was created with a negative axis (such as the default -1),
this replaced the relative index with a positive index fixed to the rank
of the first input.

Subsequent runs on an input of different rank then either:
- evaluated TopK along the wrong axis (e.g. axis 1 instead of axis 2
  when moving from a 2D tensor to a 3D tensor), or
- triggered an out-of-range assertion in getMemoryShapes (e.g. axis 2
  on a 2D tensor when moving from a 3D tensor to a 2D tensor).

Fix this by keeping this->axis unmodified and storing the normalized axis
separately for execution. Add unit tests for both increasing and decreasing
rank inputs on the same TopK layer instance.
2026-11-30 18:13:48 +05:30
Ishita Singh
e55e631516 dnn: keep the TopK axis attribute unchanged in finalize
TopKLayerImpl::finalize previously normalized the axis attribute by
overwriting this->axis with normalize_axis(axis, input_shape.size()).
When the layer was created with a negative axis (such as the default -1),
this replaced the relative index with a positive index fixed to the rank
of the first input.

Subsequent runs on an input of different rank then either:
- evaluated TopK along the wrong axis (e.g. axis 1 instead of axis 2
  when moving from a 2D tensor to a 3D tensor), or
- triggered an out-of-range assertion in getMemoryShapes (e.g. axis 2
  on a 2D tensor when moving from a 3D tensor to a 2D tensor).

Fix this by keeping this->axis unmodified and storing the normalized axis
separately for execution. Add unit tests for both increasing and decreasing
rank inputs on the same TopK layer instance.
2026-11-30 16:14:05 +05:30
Kumataro
109ce5361d imgcodecs(jpegxl): preserve alpha channel on uniform opaque alpha with libjxl >= 0.13 (#31219)
* imgcodecs(jpegxl): preserve alpha channel on uniform opaque alpha with libjxl >= 0.13

Starting with libjxl 0.13.0 (libjxl/libjxl#4981), the default frame setting
strips alpha channels when all pixels are opaque during lossy encoding,
turning 4-channel input images into 3 channels on decode.

Set JXL_ENC_FRAME_SETTING_STRIP_ALPHA to 0 when building against libjxl
0.13.0 or later to keep 4 channels intact, and add parameterized tests
covering 8U/16U/32F, transparent/opaque alpha, and quality 95/100.

* Update warning message to be human readable.
2026-11-30 15:56:17 +05:30
Abhishek Gola
8cd8ba4a8d Merge pull request #31225 from hskad/calib3d-stereobm-xsobel-table-size
calib3d: remove unused entries from prefilterXSobel lookup table
2026-11-30 15:53:56 +05:30
Abhishek Gola
4408b9d959 Merge pull request #31253 from hskad/core-sortidx-empty-input
core: support empty input in cv::sortIdx
2026-11-30 13:21:49 +05:30
Dmitry Kurtaev
1972259d2b Fix RotatedRest NMS bug 2026-11-29 20:41:14 +03:00
hskad
9a27fc240c core: support empty input in cv::sortIdx 2026-11-29 22:58:12 +05:30
hskad
e3c4eca6bd calib3d: remove unused entries from prefilterXSobel lookup table 2026-11-29 12:13:42 +05:30
Prasadayus
6ba5c02d8e core: enable FP16 conversions on MSVC ARM64 2026-11-27 13:42:40 +05:30
guptaaarushg
08da8bc27a imgcodecs: fix PFM dimensions under grouped numeric locales (#31071)
* imgcodecs: fix PFM dimensions under grouped numeric locales

* Keep PFM formatting local and isolate locale regression tests

* Remove locale test and test-runner change as requested
2026-11-26 18:01:44 +05:30
Abhishek Gola
c6d8ac831f Merge pull request #31155 from amd/fix_boxfilter
imgproc: keep float boxFilter on blockSum
2026-11-26 10:29:10 +05:30
Abhishek Gola
c213b26387 Merge pull request #31147 from sshivensolanki/dnn-einsum-uppercase-letters-4x
dnn: fix Einsum index for uppercase subscript letters
2026-11-26 10:18:58 +05:30
Abhishek Gola
90eff4c1c9 Merge pull request #31150 from pbkx/fix-core-solvepoly-coefficient-scaling-4x
core: preserve solvePoly roots under coefficient rescaling

This PR makes it so that a shared power of two is now applied to scale the internal polynomial coefficients before degree determination and root initialisation. The shift is limited to preserve non-zero components. Leading terms with exactly zero coefficients are removed, while the iteration method, input coefficients and output format are the same as before.
2026-11-26 10:16:08 +05:30
Madan Mohan Manokar
88685c4a3c imgproc: keep float boxFilter on blockSum
- Route 32F and 64F to blockSum for kernels up to 5x5
- Restore pre-#28224 out-of-place path in blockSum
- Keep the in-place ROI fix from #28224
- Drop float paths unused by fused 3x3/5x5 kernels
2026-11-25 14:33:50 +00:00
Alexander Smorkalov
4a401fd4aa Merge pull request #31146 from asmorkalov:as/android_36_4.x
Android SDK 36, NDK 30 in 4.x - #31146

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:31:56 +03:00
Madan mohan Manokar
2d668dabc2 Optimized Blur and Box filters by implementing a combined row-and-column separable approach (#28224)
* imgproc: improve blur and box filter with combined row+column separable filter

- Combined row+column separable filter for small filter sizes (3x3 and 5x5) added to avoid intermediate row buffer storage.
- FilterEngine has been modified to use combined rowColumnFilter.
- Vectorize separable row sums.
- Fix normalized 8U/16U/16S/32S scaling in ColumnSum.
- Pass an inner-region flag to row and column filters.
- Use the fused path on x86 for out-of-place, centered-anchor 3x3/5x5.
- Add AVX512_ICL dispatch for box_filter.

* imgproc: fix in-place boxFilter on ROI

- Drop unused kcn/processInnerRegion column-filter args
- Skip fused path when src and dst overlap
- Add Imgproc_Blur.inplace_roi test

* imgproc: deduplicate box filter kernels

- Share row-slide helpers between RowSum and templates
- Merge ColumnSum specializations
- Share Sum3x3/Sum5x5 setup and tails
- Round CV_16S power-of-two normalization
- Use ptrdiff_t for dst row offsets
- Initialize Cn4 row-sum carry in native lane order
- Keep scalar int -> short column sum on RISC-V (GCC 13 ICE)

* imgproc: run fused box filter on row bands on all platforms

- Split the fused 3x3/5x5 pass into bands of ~256 KB of rows (min 8)
- Fixes the large-image slowdowns vs 4.x; output unchanged
- Route out-of-place 3x3/5x5 32F/64F boxFilter/blur to the fused kernels everywhere, not only x86
- Fixes the 32F slowdowns vs 4.x on Mac M5

* imgproc: address box filter review comments
- Drop always-true processInnerRegion arg from row filters and fillRowData
- Gate 8U/16U/16S fused box kernels on !CV_NEON instead of x86-only

* imgproc: run fused box filter bands in parallel
- Split fused 3x3/5x5 bands across threads when there is >= 1 MB of work per thread
- Fix false src/dst overlap detection that sent the fused path to the row-buffered fallback
2026-11-25 17:38:02 +05:30
Hardik K
06dbed2175 calib3d: fix USAC getLambda out-of-bounds on single support vectors (#31058)
* calib3d: fix USAC getLambda out-of-bounds on single support vectors

Fixes #27487

In usac::getLambda(), the median calculation had an inverted odd/even
parity check and accessed supports[size/2 + 1] when size % 2 was
non-zero. When evaluating a single model (supports.size() == 1),
supports[1] was accessed out of bounds, which triggered a debug
assertion (vector subscript out of range) in debug builds and caused
undefined reads in release builds.

This patch:
- Inlines getLambda in usac.hpp without CV_EXPORTS to avoid altering
  the 4.x shared library ABI.
- Corrects the median calculation to use supports[size/2] for odd sizes
  and (supports[size/2 - 1] + supports[size/2]) * 0.5 for even sizes.
- Guards empty support vectors and clamps denominators to avoid
  divisions by zero.

* calib3d: add deterministic test coverage for getLambda

Add direct regression tests in test_usac.cpp:
- Empty support vector returns 1.0 and sets min_non_random_inliers to 1.
- Single-element vector (supports.size() == 1) validates fix against out-of-bounds read and crash.
- Even-sized vector (supports.size() == 4) validates two-middle-element median.
- Odd-sized vector (supports.size() == 3) validates middle-element median.
- Validates denominator handling and min_non_random_inliers when is_independent is true.
2026-11-25 16:52:45 +05:30
pbkx
d6e8218faa preserve solvePoly roots under coefficient rescaling 2026-11-25 02:32:07 -08:00
Sohail Shaikh
881e934a0b Merge pull request #30810 from sohailshk/fix/carotene-mul-scale-edge-cases
carotene: fix CV_16U/16S/32S multiply with tiny power-of-two scales and large CV_32S products
2026-11-25 16:00:22 +05:30
Shiven Solanki
d53f83e34a dnn: fix Einsum index for uppercase subscript letters 2026-11-25 17:11:00 +08:00
Abhishek Gola
c6906bc064 Merge pull request #31128 from Prasadayus/fix/filter-tile-nstripes
imgproc: keep each thread's filter tiles contiguous
2026-11-25 13:17:01 +05:30
Chris Dzoba
90dd252196 Merge pull request #30429 from dzoba/imgproc-medianblur-5x5-network
This PR replaces it with an 85 compare-exchange network that needs 146 min/max operations. The network is from Bert Dobbelaere's list of median selection networks (https://bertdobbelaere.github.io/median_networks.html), found with his SorterHunter program, and is also in the SorterHunter repository under the MIT License (https://github.com/bertdobbelaere/SorterHunter/blob/master/Networks/Median/Median_25_85_16.json). I checked with Bert Dobbelaere before opening this, and he is fine with it being used here. The PR reorders its compare-exchanges to reduce register pressure on targets with 16 vector registers. Nothing else changes: loads, stores, border and tail handling are untouched. For integer types the output is bit-identical. For floating point it is identical except in the NaN and signed-zero cases described in the notes below.
2026-11-25 12:50:02 +05:30
Abhishek Gola
fb7e3a8614 Merge pull request #30726 from pbkx/fix-phasecorr-odd-fft-origin-4x
imgproc: fix phaseCorrelate origin for odd FFT sizes
2026-11-25 12:16:29 +05:30
Abhishek Gola
3e3136a658 Merge pull request #30414 from sshivensolanki/fix-norm-l2-int-overflow
core: fix NORM_L2 overflow for CV_16S and CV_32S at the type minimum
2026-11-25 12:14:53 +05:30
Hardik K
ec6675011a Merge pull request #31055 from hardikkaurani/fix/flann-neon-hamming-tail
flann: handle non-multiple of 16 vector sizes in NEON Hamming distance - #31055

Fixes #30940

On ARM NEON, \cvflann::Hamming<unsigned char>\ loaded 16 bytes per iteration using \or (size_t i = 0; i < size; i += 16)\ without tail handling. Whenever \size\ was not a multiple of 16, the final iteration read up to 15 bytes past each vector (\ld1q_u8\), adding those unrelated bits to the distance calculation and causing \heap-buffer-overflow\ under AddressSanitizer. This affected AKAZE descriptors (61 bytes) and any non-multiple-of-16 binary feature vector.

### Changes
- Adjust the main loop termination condition to \i + 16 <= size\.
- Process remaining 0..15 tail bytes directly with scalar \cvflann::HammingLUT\ after the vector reduction for both binary vector comparison and the \ZeroIterator\ overload.
- Add regression tests in \	est_hamming.cpp\ verifying tail bounds across vector lengths from 1 to 65 (including AKAZE's 61 bytes) and checking consistency against \cvflann::HammingLUT\ and \cv::norm(..., NORM_HAMMING)\.

### 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 09:35:07 +03:00
胡晨宇
d2916b7cce RVV: add fused rotation for three-channel images (#30447)
This PR extends the RVV fused rotation implementation from #30057 to three-channel images, including RGB/BGR images.

Three-channel images currently fall back to separate transpose and flip operations for 90-degree rotation. The new implementation combines these operations into a single vectorized pass and writes directly to the final output positions.

It supports 1-, 2-, 4-, and 8-byte channels, corresponding to pixel sizes of 3, 6, 12, and 24 bytes. No public API changes are required.
2026-11-25 11:59:27 +05:30
Alexander Smorkalov
d32234d897 Merge pull request #31124 from sshivensolanki/imgproc-integral-depth-docs-4x
doc(imgproc): fix supported depths for integral and thresholdWithMask (4.x)
2026-11-25 09:29:05 +03:00
Pu Cheng
a85f8a0de9 Merge pull request #31094 from GeekQAQ/fix-mjpeg-gray-scale
videoio: fix the scale of grayscale frames in the built-in MJPEG encoder

Raised the tolerance from 10 to 16. The ARM64 difference comes from the encoder, not the decoder: the NEON DCT truncates the quantized coefficients where the scalar code rounds. For this frame the maximum error at quality 75, 90 and 100 is 11, 6 and 7 on AArch64 (under qemu) and 2 on x86. Without the fix the error is 255 at quality 75, so the test still fails on both.
2026-11-25 09:18:42 +05:30
Abhishek Gola
572449ce97 Merge pull request #30923 from pctablet505/fix-dnn-cuda-gemm-square-transpose
dnn: avoid transposing square Gemm weights in-place in initCUDA 🤖🤖🤖
2026-11-24 19:25:26 +05:30
Parchuri Poojith Kumar
296cb2053f imgproc: do not put a bogus vertex into the result of approxPolyN (#31068)
* imgproc: do not put a bogus vertex into the result of approxPolyN

A vertex can only be contracted if the lines of the two edges next to the removed edge meet beyond it. For parallel edges, as in a rectangle, the code marked the vertex with the area FLT_MAX and the point (-1, -1), but still contracted it when nothing else was left, so the point (-1, -1) ended in the result. Nearly parallel edges, like in a regular octagon, gave a vertex billions of units away, because the check for parallel edges used a fixed threshold. Test for parallel edges relative to the edge lengths, treat edges that diverge the same way, and stop when no vertex can be contracted, as the documentation already allows for the epsilon limit. The result for any polygon that could be contracted is unchanged. Add tests and a note to the documentation.

* imgproc: add tests with nearly parallel sides for approxPolyN

The tests with a rectangle and an octagon with integer coordinates only have exactly parallel sides, which the old check for 1e-8 rejected as well. Add a test with a square whose top side is tilted by about 2e-7 radians, which gave a vertex 4e8 units away, and a test with regular octagons computed with float cos and sin for 16 rotations, which gave vertices billions of units away for some of them.
2026-11-24 17:52:26 +05:30
Madan mohan Manokar
deee720b0b Merge pull request #28970 from amd/bugFix_countViolations
Earlier wrong cv::multiply api usage has been fixed. Scale param has been set to 6 by mistake by passing CV_64F.
cv::abs returns tiny negative value due to float32 sign-bit problem. This issue has been fixed.
Relative errors has been adjusted in perf_dot, perf_stat, perf_moments to avoid introducing new error while changing scale from 6 to 1 in cv::multiply.
2026-11-24 16:24:31 +05:30
Shiven Solanki
48c6f9d0b9 doc(imgproc): fix supported depths for integral and thresholdWithMask (#30978)
* doc(imgproc): fix supported depths for integral and thresholdWithMask

* doc(imgproc): note extra integral depth combinations on the OpenCL path
2026-11-24 18:28:29 +08:00
Prasadayus
ff93a54630 imgproc: keep each thread's filter tiles contiguous 2026-11-24 15:37:24 +05:30
Abhishek Gola
f5b814c968 calib3d: document image points order for SOLVEPNP_IPPE_SQUARE (#30888)
The docs list the required order of the 4 object points for SOLVEPNP_IPPE_SQUARE, but do not say anything about the image points. In ippe.cpp (PoseSolver::solveSquare) the image points are used by index, so they must be given in the same order as the object points.

This PR adds that sentence everywhere the object point order is listed (SolvePnPMethod enum, solvePnP, solvePnPGeneric, solvePnPRefine docs and solvePnP.markdown). In solvePnP.markdown I also added that, when the marker faces the camera, this order is top-left, top-right, bottom-right, bottom-left, which is the same corner order returned by ArucoDetector::detectMarkers.

I checked this with a small script: with the same order solvePnP returns the true pose, with reversed image points the rotation is wrong.

Docs only, no code changes.
2026-11-24 15:34:46 +05:30
Abhishek Gola
df4630186b Merge pull request #31088 from aswanth-07/fix/calib3d-schur-determinism-4x
calib3d: make Schur complement solver deterministic
2026-11-24 15:11:15 +05:30
Alexander Smorkalov
7312b07398 Merge pull request #31100 from poojithparchuri-iiitk:hough-circles-nan
imgproc: reject NaN arguments in HoughCircles
2026-11-24 11:33:25 +03:00
Alexander Smorkalov
2d570df34f Merge pull request #31099 from Prasadayus:fix/ecc-stripe-accumulators
video: fix false sharing in ECC multi-scale stripe accumulators
2026-11-24 11:04:57 +03:00
KVR Vishnu
4d6a848f5e Merge pull request #31069 from VISHNU0906:fix-30955-hdr-colorspace
videoio(ffmpeg): keep HDR transfer and primaries so HLG/PQ frames are not clipped 🤖🤖🤖 - #31069

Merge with https://github.com/opencv/opencv_extra/pull/1473

Fixes #30955

Hi @peterroelants, thanks for the detailed report and the ramp repro, it made this easy to pin down.

### What changed

Since #27755, with swscale >= 8.12.100 the conversion is set up by `sws_scale_frame()` from the two frames. `rgb_picture` had no colour properties, so swscale treated the output as SDR BT.709 and converted HLG and PQ input to it, clipping everything above SDR white to 255. This is option 1 from the issue: copy the source primaries and transfer to `rgb_picture` before the call. swscale then has no colour conversion to do and returns the decoded values like the old `sws_scale()` path (and like `ffmpeg -pix_fmt bgr24` with no output tags). The matrix and range don't need copying, swscale always treats an RGB frame as RGB, full range.

Older FFmpeg (swscale < 8.12.100) still goes through `sws_init_context()`, which ignores these fields, so nothing changes there.

### Test

New `videoio_ffmpeg_hdr.keep_decoded_values_30955` (hlg, pq) reads a 64x4 10-bit gray ramp tagged HLG or PQ (samples in the opencv_extra PR) and checks every pixel against the plain limited-range mapping, with a 3 level margin for swscale's dither. Without the fix both cases fail (mid-tones off by 10 to 20 levels, the right side of the ramp at 255).

- Debian 13 x86_64, self-built FFmpeg n8.1 (swscale 9.5.100): new tests fail before the fix, pass after. Full `opencv_test_videoio` with opencv_extra data: 564/564 pass.
- Same with the distro FFmpeg 7.1 (swscale 8.3.100): 564/564 pass, the new tests pass with or without the fix as expected.
- I also tried a PQ file with mastering display metadata: values stay within 1 level of the plain ramp.

I used AI assistance for parts of this change and tested it locally against the full test suite.

### 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-24 10:59:58 +03:00
Parchuri Poojith Kumar
c776338cf8 Merge pull request #31042 from poojithparchuri-iiitk:qr-encoder-validate
objdetect: validate the QR encoder version and correction level - #31042

QRCodeEncoder::create accepts any version and correction level, and the encoder then uses them as indexes into its tables. A version above 40 crashes or hangs it, and an unknown correction level crashes it too. With the Python package this is easy to see: set params.version = 41 or params.correction_level = 100 and call encode() on the encoder, and the process segfaults. With version 100 or 255 it hangs (I stopped it after 15 seconds), and with version 40 and correction_level 4 it crashes with SIGFPE, an arithmetic error.. The tables have MAX_VERSION + 1 entries, so version 41 reads past the end.

This adds two checks to the constructor of the encoder: the version must be in [0, 40], where 0 still selects it automatically, and the correction level must be one of the four known values. Anything else raises an error. Valid values are not affected.

I added three tests: an invalid version, an invalid correction level, and one that checks that the lowest and highest valid values (version 0, 1 and 40 with all four levels) still encode. On Windows with MSVC, without the change the two tests for invalid values fail, because the encoder accepts the bad values, and with the change they pass. The self-contained existing encoder tests also pass (Kanji, structured append, auto version, long text). I did not run the existing encoder tests that need images from opencv_extra, so CI will be the first run of those. My AI assistant also reproduced the crashes on the released 4.14.0 and 5.1.0 Python packages, and qrcode_encoder.cpp is the same in 4.14.0 and current 4.x.

This is separate from my open PR #30773, which changes the decoder part of the same file, so they do not touch the same lines.

I built and tested it myself on Windows, and an AI assistant (Claude) helped me find the problem and write the change and the tests.

- [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
      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-24 10:57:55 +03:00
Alexander Smorkalov
ef8d6510ad Merge pull request #31109 from poojithparchuri-iiitk:clahe-tile-grid
imgproc: reject a CLAHE tile grid without tiles
2026-11-24 10:36:34 +03:00
Pratham Kumar
26c5aa0ab5 Merge pull request #31065 from pratham-mcw:seamlessClone_opt
photo: parallelize and vectorize the Poisson solver - #31065

## Summary

- All four cloning APIs (seamlessClone, colorChange, illuminationChange, textureFlattening) solve the three colour channels one after another in Cloning::poisson(). Each solve is two DST passes, which are cv::dft calls, and without IPP the DFT has no threading of its own. The channel solves are independent, so they can run in parallel.

## Changes

- Cloning::poisson runs the three channel solves through parallel_for_.
- Cloning::dst transposes once and reads in row order, instead of striding down a column.
- Four data-parallel loops in dst and solve use universal intrinsics (v_float32, vx_load, VTraits<>::vlanes()), each with a scalar tail.
- The per-element arithmetic is unchanged, so the output is bit-identical to the original.
- Adds perf tests for the four APIs in perf_cloning.cpp.

## Performance Benchmarks
<img width="647" height="240" alt="image" src="https://github.com/user-attachments/assets/5ab39c64-e236-4f35-9868-9bba4b8444a1" />
2026-11-24 09:51:55 +03:00
Alexander Smorkalov
26e5376a8c Merge pull request #31095 from Prasadayus:fix/reduce-row-buffer-alignment-4x
core: fix false sharing in cv::reduce row reduction
2026-11-24 09:39:51 +03:00
Parchuri Poojith Kumar
5e74b2e340 imgproc: reject a CLAHE tile grid without tiles
CLAHE_Impl::apply divides by the numbers of tiles and takes the remainder of them in several places, and nothing checked that they are positive. A tile grid with a zero, for example Size(0, 0) given to createCLAHE or setTilesGridSize, ended in a division by zero and a crash of the process, and a negative size was only rejected by accident, when a matrix with a negative size was created. Check both numbers at the start of apply. The result for any valid grid is unchanged. Add a test.
2026-11-24 01:04:06 +05:30