Commit Graph

26398 Commits

Author SHA1 Message Date
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
Parchuri Poojith Kumar
a026427b14 imgproc: reject NaN arguments in HoughCircles
The arguments of HoughCircles are checked with dp <= 0, minDist <= 0, param1 <= 0, param2 <= 0 and param2 >= 1, and NaN is false for all of them, so a NaN got through. With HOUGH_GRADIENT_ALT a NaN dp ended in an accumulator without columns (cvRound of NaN is INT_MAX or 0 on some platforms) and crashed, and a NaN minDist, param1 or param2 was silently accepted for both methods. Write the checks as !(x > 0) and !(x < 1) so that NaN is rejected. The result for any other value is unchanged. Add a test.
2026-11-23 20:31:09 +05:30
Prasadayus
19066b3ccd video: keep ECC stripe counters private to the stripe 2026-11-23 19:07:49 +05:30
aswanth-07
e53927a621 calib3d: make Schur complement solver deterministic
Port of #30175 (Savya Sanchi Sharma) to 4.x. JAccumulator added each
image's contribution to the shared U, ea and error under a mutex, so
the order of the sums, and the calibration result, followed thread
scheduling. Images now go into at most 16 fixed buckets (fewer when
the bucket matrices would exceed 256 MiB). Each bucket accumulates
without a lock, and reduceGlobal() adds the buckets and per-image
errors in a fixed order.
2026-11-23 16:50:04 +05:30
Prasadayus
98abe1285c core: give cv::reduce rows a per-call accumulator to stop false sharing 2026-11-23 16:13:19 +05:30
Abhishek Gola
ede3313ae7 Merge pull request #31041 from GeekQAQ/fix-yaml-dash-line
core: report an error for a '-' line after the first YAML document
2026-11-23 09:26:38 +05:30
Parchuri Poojith Kumar
01fcbe2b16 imgproc: stop approxPolyDP from looping forever on an open curve with an infinite coordinate
For an open curve, a zero epsilon and an infinite segment, eps * segment_len_2 is NaN, so the test that stops splitting a slice was always false and the slices never got smaller. Write the test so that NaN counts as within the tolerance. Results for finite input are unchanged. Add tests.
2026-11-22 18:02:35 +05:30
Pu Cheng
29a31a187d core: report an error for a '-' line after the first YAML document
After the first document, YAMLParser::parse() expects the next one to
start with '---'. A line that starts with an alphanumeric character is
rejected with "The YAML streams must start with '---', except the first
one", but a line that starts with '-' and is not '---' is neither
consumed nor rejected, so the loop that looks for the next document
never advances and FileStorage::open() does not return.

Report the same parse error for such a line.
2026-11-22 03:39:22 +08:00
Abhishek Gola
9ab3c8cd13 Merge pull request #30776 from tribhu05/fix-applycolormap-1x256-lut
imgproc: allow 1x256 custom lookup tables in applyColorMap 🤖🤖🤖

Updated the custom colormap dimension validation in applyColorMap to accept both Size(1, 256) (vertical 256x1) and Size(256, 1) (horizontal 1x256), while ensuring userColor.empty() and dims > 2 are rejected:
if (userColor.empty() || userColor.dims() > 2 ||
    (userColor.size() != Size(1, 256) && userColor.size() != Size(256, 1)))
    CV_Error(Error::StsAssert, "cv::LUT only supports tables of size 256.");
Because ColorMap::operator() checks _lut.isContinuous() and accesses the table sequentially via raw pointers (_lut.ptr<lut_pixel_t>(0)), continuous 1x256 and 256x1 matrices lay out identically in memory. Index lookup srcLUT[pixel_val] works identically without requiring buffer reallocation or reshaping.
2026-11-21 14:37:09 +05:30
Abhishek Gola
3ab5a2c9c3 Merge pull request #31021 from sohailshk/fix/pyrup-empty-src
imgproc: do not crash in pyrUp on an empty source
2026-11-21 12:25:21 +05:30
Rahul Kumar
163e11b600 features2d: do not apply AKAZE max_points limit in compute() on provided keypoints 🤖🤖🤖 (#30912)
* features2d: skip AKAZE max_points cut when keypoints are provided

Do not sort or truncate caller-supplied keypoints by max_points in AKAZE_Impl::detectAndCompute() when useProvidedKeypoints is true, preserving input count and order in compute() while keeping the limit for detection.

* features2d: document that AKAZE max_points applies only to detected keypoints

compute() and detectAndCompute() with provided keypoints keep the
keypoints they are given.
2026-11-21 09:46:50 +05:30
Pu Cheng
0c948e3684 video: make clear() reset the MOG2 and KNN background models (#30992)
* video: make clear() reset the MOG2 and KNN background models

cv::Algorithm::clear() is documented to clear the algorithm state, but
BackgroundSubtractorMOG2 and BackgroundSubtractorKNN inherit the empty
base implementation. After clear(), apply() keeps updating the old model
and reports foreground against the previous scene.

Override clear() in both implementations to drop the model, so the next
apply() initializes a new one as it does on a newly created object.

* video: clear MOG2 and KNN models without going through initialize()

clear() called initialize(Size(), 0). With OpenCL active this builds the
apply and getBackgroundImage kernels for frame type 0 and runs create()
and setTo() on zero-size UMats; the setTo() call dereferences an empty
vector in ocl::checkOptimalVectorWidth() and crashes.

Release the model buffers (Mat and UMat) instead and reset the frame size,
frame type, frame counter and KNN's update counters to their constructor
values. The algorithm parameters are kept. The next apply() initializes
the model for the actual frame, as on a new object.

Add UMat variants of the clear() regression tests so the OpenCL path is
covered when OpenCL is available.

* video: do not assign theRNG() in the clear() tests

The clear_resets_model tests reseeded theRNG() before each of the two
apply() calls they compare. That is not needed: KNN takes its update
points from theRNG() only after a frame has been processed, so the
first apply() on an empty model gives the same mask and background
image whatever the RNG state is. Leave the global RNG as the test
system set it.
2026-11-21 09:18:48 +05:30
Alexander Smorkalov
bc02403223 Merge pull request #30994 from lazerg/fix/issue-30991-filestorage-release-memory
core: free FileStorage session buffers in release()
2026-11-20 16:24:34 +03:00
Abhishek Gola
f0d9c67dc8 Merge pull request #30982 from abhishek-gola/tests/test-fixes-4x
tests: pass the mask in AccumulateWeighted.Mask
2026-11-20 17:08:07 +05:30
Abhishek Gola
38333d558f Merge pull request #30993 from GeekQAQ/fix-mjpeg-jflush-overflow
videoio: avoid signed overflow in BitStream::jflush
2026-11-20 14:33:02 +05:30
Pratham Kumar
6e772459fc Merge pull request #30472 from pratham-mcw/denoising_opt
photo: vectorize fastNlMeansDenoising with universal intrinsics

Adds a universal-intrinsics path that processes four elements per iteration for single-channel uchar and ushort images.
Vectorizes the column distance update, the initial distance sums at the start of each row, and the weighted accumulation.
Uses the same integer arithmetic as the scalar code, so results are bit-exact.
The scalar loops are unchanged and handle the remaining elements at the end of each row.
2026-11-20 13:26:56 +05:30
Abhishek Gola
6e0162fb08 photo: fix NORMCONV domain filter above 5.6 MP (#30863)
Domain_Filter::compute_NCfilter encoded summed-area-table positions as float linear indices over 3 * h * (w + 1) elements and decoded them back into (row, col, channel). Above 2^24 (~5.59 MP for 3-channel images), float loses integer precision and reads neighbouring rows. Index box_filter directly by row i and integer column bounds from upper_idx and lower_idx.
2026-11-20 13:19:14 +05:30