Commit Graph

27632 Commits

Author SHA1 Message Date
abhishek-gola
925ce46ef0 tests: pass the mask in AccumulateWeighted.Mask and check the #24966 CRF fix directly
Signed-off-by: abhishek-gola <abhishek@opencv.org>
2026-11-18 16:39:39 +05:30
Alexander Smorkalov
2ba4647c89 Merge pull request #30893 from pctablet505:fix-video-dis-stale-initial-flow-5x
video: clear stale initial flow in DISOpticalFlow::calc() 🤖🤖🤖
2026-11-18 10:19:25 +03:00
Alexander Smorkalov
772cd730e9 Merge pull request #30898 from RITU940:fix/multiview-visibility-mask-stride
calib: handle non-contiguous detection masks in calibrateMultiview
2026-11-18 10:18:00 +03:00
Abhishek Gola
80db42de85 Merge pull request #30887 from abhishek-gola/fix/sphinx-docs-warnings
Fix Sphinx documentation warning sources
2026-11-18 08:49:36 +05:30
Ritu Baskey
148ba7826b calib: respect detection mask row stride 2026-11-17 20:29:04 +00:00
pctablet505
521dd6bcdb video: fix DISOpticalFlow::calc() crash after collectGarbage()
DISOpticalFlowImpl::collectGarbage() cleared variational_refinement_processors
even though only the constructor populates it, and indexed
finest_scale..coarsest_scale (out of bounds before the first calc()).
Call collectGarbage() across variational_refinement_processors without
clearing the vector, and release the remaining internal buffers.
2026-11-17 20:43:08 +05:30
pctablet505
85d93fdbb6 video: clear stale initial flow in DISOpticalFlow::calc()
prepareBuffers() kept initial_Ux and initial_Uy from an earlier call
when use_flow was false.
2026-11-17 20:43:07 +05:30
Alexander Smorkalov
7fd928ae70 Merge pull request #30867 from pratham-mcw:cornersubpix_opt_5x
imgproc: parallelize cornerSubPix using parallel_for_
2026-11-17 15:05:07 +03:00
Vadim Pisarevsky
a30d2be6ea Merge pull request #30618 from vpisarev:dft_opt
Further FFT/DFT/DCT optimizations - #30618

Merge together with https://github.com/opencv/opencv_extra/pull/1456

### Summary

Follow-up to #30061 and relates to #30467. It fixes the 64F 1D regressions measured on x86 after that PR, removes the O(r²) memory of the big prime radix, adds radix-8 stages, and makes the twiddle tables ~1 ulp accurate. Everything below was measured without IPP (`WITH_IPP=OFF`), so the numbers compare the OpenCV code paths only; the IPP logic is not touched.

Four commits, each self-contained:

1. **Memory, plan overhead, vectorization** (784be814b2)
   - Root cause of the x86 1D regressions: `cv::dft()` builds a plan per call, and at n = 65536 the engine allocated three MB-sized blocks per call (twiddles, permutation, workspace). glibc trims the heap after every free (its dynamic trim threshold is 2x the largest freed block), so every call page-faulted the buffers again: 65536 64FC2 ran at 620 us, ~215 us of it outside the transform. Fix: tables, permutation and the owner's workspace are **one allocation** per plan. No memory is retained between calls, no plan cache.
   - Static, lazily built tables for power-of-two lengths nc ≤ 1024 (stage twiddles, digit-reversal, real-FFT twiddles): plan building for 256..2048 points is table lookups only (0.06 us).
   - Generic odd radix: `cs/sn` tables of r entries with a cyclic index instead of h×h (h = (r−1)/2). n = 4093 in double: peak RSS 72.6 MB → 7.7 MB.
   - `DFT_STAGE_SIMD128`: stages with span shorter than the full vector but ≥ 128 bits run on `v_float32x4`/`v_float64x2` instead of scalar code (span 4 on AVX2 floats, i.e. every 4^k length).
   - Fused twiddle-free first stage of radix 3 and 5 for odd lengths (e.g. 4725), fused last radix-4 stage writing the interleaved scaled output, depth-first chunking of the leading stages for long transforms.
2. **`AutoBuffer` alignment** (02c6f39c82): `alignas(max(alignof(_Tp), 8))` on the local storage, so `AutoBuffer<uchar>` used as raw storage for double/int64 data is 8-byte aligned on every platform (it was only 4-byte aligned on 32-bit targets).
3. **Radix-8 stages and cache-set padding** (c7bf418d06): the power-of-two part is factored as r0·8^a·4^b (256: 2 middle stages instead of 3, 4096: 3 instead of 5, 65536: 5 instead of 7). The butterfly follows FFTW's `t1fv_8` (odd legs first, W8 rotations folded into the outputs with FMAs). The real reason an earlier radix-8 attempt was slower turned out to be **4K aliasing**: with a span of a 4 KB multiple, the data legs, the twiddle leg tables and the re/im arrays of one butterfly all map to one L1 set. One cache line of padding between the twiddle legs and between re and im gives 1.3–1.4x at n ≥ 16384 on its own; radix-8 adds 1.1–1.4x on top for complex transforms.
4. **Accurate twiddle generation** (2831df79c8): the tables were built by rotation recurrences and chained leg products and were 12–27 ulps off in double. Now every entry is one product of exactly computed seeds (Cephes sin/cos polynomials on an integer-reduced octant, ~0.5 ulp), computed in double, vectorized and rounded once. The real-FFT twiddles are stored as one table (`rtw_im = rtw_re + nc/2`).

Also: `perf_dft.cpp` gains 256x256 and 512x512 2D sizes (matchTemplate / filter2D tile sizes); `test_dxt.cpp` sweep gains prime and 2·prime lengths (257, 1009, 2018).

### Performance vs 5.x head (c4f7634256)

Environment: Intel Core Ultra 7 255H, Ubuntu 26.04, GCC 15.2, Release, default `CPU_BASELINE`/`CPU_DISPATCH` (AVX2 kernels are dispatched), `WITH_IPP=OFF`. Each binary was run twice and the minimum per case taken; the tables show the speedup `t(5.x) / t(PR)` as geomean over the flags (and row/column for 1D). Everything single-threaded unless stated.

**1D DFT (`dft1d`)**

|  | 32FC1 | 64FC1 | 32FC2 | 64FC2 |
|---|---|---|---|---|
| 256 | 2.11 | 1.84 | 2.25 | 1.73 |
| 1000 | 1.39 | 1.17 | 0.99 | 1.04 |
| 1024 | 2.62 | 2.07 | 2.49 | 1.68 |
| 4096 | 1.38 | 1.36 | 1.58 | 1.44 |
| 4725 | 1.81 | 1.71 | 1.86 | 1.72 |
| 65536 | 1.79 | 1.55 | 2.05 | 1.38 |

geomean 1.66 over 192 cases, min 0.98.

**1D DCT (`dct1d`)**

|  | 32FC1 | 64FC1 |
|---|---|---|
| 256 | 1.65 | 1.51 |
| 1000 | 1.50 | 1.22 |
| 1024 | 1.96 | 1.63 |
| 4096 | 1.52 | 1.37 |
| 65536 | 1.82 | 1.29 |

**2D DFT, 1 thread** (geomean over flags; `DFT_ROWS` cases in the second group)

|  | 32FC1 | 64FC1 | 32FC2 | | ROWS 32FC1 | ROWS 64FC1 | ROWS 32FC2 |
|---|---|---|---|---|---|---|---|
| 256x256 | 1.14 | 1.02 | 1.33 | | 0.97 | 0.97 | 1.70 |
| 512x512 | 1.14 | 1.04 | 1.04 | | 1.44 | 1.01 | 1.09 |
| 320x480 | 0.98 | 1.00 | 1.16 | | 0.98 | 1.00 | 1.62 |
| 800x600 | 1.10 | 1.00 | 0.99 | | 1.34 | 0.98 | 1.00 |
| 1280x1024 | 1.12 | 1.02 | 1.26 | | 1.00 | 1.00 | 1.43 |
| 1920x1080 | 1.12 | 1.00 | 0.99 | | 1.39 | 1.03 | 1.00 |
| 2048x2048 | 1.09 | 1.04 | 1.07 | | 1.34 | 0.99 | 1.21 |

2D DCT, 1 thread: 0.99–1.23 (geomean 1.06). With the default number of threads the 2D geomeans are the same (dft 1.07, dct 1.09) but individual cases are noisy on this hybrid-core CPU (0.75–1.76 between runs of the same code).

**imgproc**: matchTemplate 1.00–1.25 per image/template size (geomean 1.07), filter2D 1.00–1.03.

The one case consistently below 0.95 in the 1-thread tables, 2D 256x256 32FC2 `DFT_INVERSE` (0.84), is bimodal (0.11 / 0.19 ms) with both the old and the new library: it depends on the addresses malloc returns for the row buffers (set aliasing between src/dst and the 2D driver's buffers), so the per-run winner is luck. It is a candidate for a follow-up.

**Plain `cv::dft()` loop** (outside the perf harness, one thread, time per call in us, `create` = plan + workspace, `apply` = transform):

| n | type | 5.x total | PR total | 5.x create / apply | PR create / apply |
|---|---|---|---|---|---|
| 256 | 32FC1 | 0.54 | 0.23 | 0.35 / 0.09 | 0.06 / 0.09 |
| 1024 | 32FC2 | 1.88 | 0.76 | 0.82 / 0.97 | 0.06 / 0.58 |
| 4096 | 64FC2 | 13.3 | 8.7 | 5.1 / 9.1 | 2.3 / 5.7 |
| 4725 | 64FC2 | 47.6 | 17.9 | 8.2 / 24.7 | 3.0 / 14.5 |
| 65536 | 32FC2 | 358 | 109 | 97 / 175 | 26 / 80 |
| 65536 | 64FC2 | 632 | 199 | 155 / 255 | 33 / 159 |

At 65536 the 5.x numbers include ~90–220 us of page faults per call (the glibc trimming described above); the perf harness hides part of this because its warm-up changes the heap state.

### Accuracy

`cv::dft` output vs a long double reference, error in units of eps (2^−52 for double):

| n | impulse response, 5.x | PR | random input (rel. to max\|X\|), 5.x | PR |
|---|---|---|---|---|
| 256 | 12.1 | 0.9 | 15.9 | 0.8 |
| 1024 | 2.4 | 1.1 | 5.2 | 1.25 |
| 4096 | 26.6 | 1.35 | 29.5 | 1.1 |
| 65536 | 11.7 | 1.2 | | |
| 1048576 | 26.4 | 1.4 | | |

Float tables are correctly rounded (0.25 eps). Round trip `idft(dft(x))` at n = 4093 (generic odd radix): max error 5.2e-13 → 7.0e-15.

### Memory

n = 4093 64FC2 (prime length → generic odd radix 4093): peak RSS 72.6 MB → 7.7 MB. No memory is kept between calls apart from the static tables of the power-of-two lengths ≤ 1024 (34 KB float + 67 KB double, built on first use).

### Tests

- `opencv_test_core` (18297 tests) with AVX2 and with `OPENCV_CPU_DISABLE=AVX2`; `Core_DFT`/`Core_DCT` sweeps now include prime lengths.
- `opencv_test_imgproc` matchTemplate / filter2D / phaseCorrelate.
- `dxt.cpp` / `dxt.simd.hpp` syntax-checked for aarch64 NEON, riscv64 RVV, x86 without SIMD, AVX2 baseline, and with `-Wall -Wextra -Wshadow`.

### Pull Request Readiness Checklist

- [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
- [ ] The feature is well documented and sample code can be built with the project CMake

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-11-17 14:41:43 +03:00
Alexander Smorkalov
82028f2e5c Merge pull request #30847 from pratham-mcw:inpaint_opt_5x
photo: vectorize cv::inpaint (Telea/NS) inner loops
2026-11-17 12:10:27 +03:00
Alexander Smorkalov
e04069c2b7 Merge pull request #30709 from peters:dnn/cuda102-reduce
dnn: fix CUDA 10.2 build of N-D reduce kernels 🤖🤖🤖
2026-11-17 12:05:34 +03:00
Alexander Smorkalov
6d711375a1 Merge pull request #30886 from sshivensolanki:core-magnitude-phase-nd
core: support N-D Mats in cv::magnitude and cv::phase
2026-11-17 12:00:15 +03:00
Alexander Smorkalov
cfc236d75e Merge pull request #30879 from pratham-mcw:cvtColor_opt_5x
imgproc: speed up RGB2Gray and RGB2YCrCb on ARM NEON
2026-11-17 11:37:24 +03:00
Alexander Smorkalov
5c98cb61a8 Merge pull request #30877 from sshivensolanki/core-convert-bool-negative-zero
core: fix convertTo(CV_Bool) turning -0.0 into true for CV_16F and CV_16BF
2026-11-17 11:18:32 +03:00
Alexander Smorkalov
84c8ba4e39 Merge pull request #30872 from pratham-mcw:sortIdx_opt_5x
core: parallelize sortIdx over independent rows/columns
2026-11-17 08:58:06 +03:00
uwezkhan
d4783f1025 ptcloud: check attribute counts against vertices in PlyEncoder 🤖🤖🤖 (#30837)
* ptcloud: check attribute counts against vertices in PlyEncoder

* ptcloud: throw on attribute count mismatch in PlyEncoder, split obj and ply tests
2026-11-17 11:04:39 +05:30
pbkx
043c56d04c features2d: clear knnMatch output before matching (#30856)
The current implementation of DescriptorMatcher::knnMatch() passes the output vector to the matcher implementation without clearing it. This means that when the output is reused, BFMatcher will add more query-result vectors to the output. Similarly, FLANN will add matches to existing inner vectors. If the query is empty, then the previous results are retained.

This PR adds back the call to matches.clear() in the common wrapper. It also adds new regression tests for multiple calls to BFMatcher and FLANN. It also covers empty queries and empty stored training collections.
2026-11-17 11:02:19 +05:30
Shiven Solanki
7c475d2785 core: support N-D Mats in cv::magnitude and cv::phase 2026-11-17 12:09:11 +08:00
Pratham Kumar
75178bb006 imgproc: speed up RGB2Gray and RGB2YCrCb on ARM NEON 2026-11-16 23:26:18 +05:30
Shiven Solanki
9465727b84 core: fix convertTo(CV_Bool) turning -0.0 into true for CV_16F and CV_16BF 2026-11-17 00:16:46 +08:00
Alexander Smorkalov
5d0660acfe Merge pull request #30852 from vrabaud:avif
imgcodecs(avif): fix MSVC C2666 ambiguity in CV_CheckEQ (#30843)
2026-11-16 17:58:32 +03:00
Alexander Smorkalov
ff92bf2147 Merge pull request #30840 from sshivensolanki:core-foreach-1d-position
core: fix forEach position for 1D Mat
2026-11-16 17:56:54 +03:00
Abhishek gola
315ddafc6c Fix Sphinx API targets, navigation and documentation warnings 2026-11-16 20:13:32 +05:30
Pratham Kumar
1c67b283ac core: parallelize sortIdx over independent rows/columns 2026-11-16 18:04:18 +05:30
Pratham Kumar
aed88a153e imgproc: parallelize cornerSubPix using parallel_for_ 2026-11-16 17:46:53 +05:30
Vincent Rabaud
81e04b7edc imgcodecs(avif): fix MSVC C2666 ambiguity in CV_CheckEQ (#30843)
Use (size_t)1 instead of 1L to match animation.frames.size() type on 64-bit Windows (LLP64).

Fixes #30843
2026-11-16 11:01:20 +01:00
Pratham Kumar
e700fa430a photo: vectorize cv::inpaint (Telea/NS) inner loops 2026-11-16 13:23:56 +05:30
Shiven Solanki
7a8d99e6b2 doc(core): note unspecified NaN handling in minMaxLoc and minMaxIdx (#30809) 2026-11-16 09:35:26 +05:30
Shiven Solanki
ac79228d5e core: fix forEach position for 1D Mat 2026-11-16 00:32:28 +08:00
Abhishek Gola
b3d14b1caf Merge pull request #30774 from tanveer-arch/fix-applycolormap-1x256
imgproc: accept 1x256 user colormap in applyColorMap
2026-11-15 13:35:12 +05:30
Muhammad Usman Mateen
d87ac83e05 dnn: compute LogSoftmax without taking the log of softmax (5.x) 🤖🤖🤖 (#30816)
* dnn: test LogSoftmax far below the maximum

LogSoftmax must give x - max - log(sum(exp(x - max))) for values about 104 or more below the row maximum, where exp underflows in float32. Covers a short row and one long enough for the SIMD loops, on the CPU and OpenCL targets. Port of the test from #30545.

* dnn: compute LogSoftmax without taking the log of softmax

logSoftmax() took the log of the softmax output, so elements whose exp(x - max) underflows came out as -inf. The dispatched softmax kernel already has the row maximum and the sum of exp((x - max) * scale), so softmax() takes a logSoftmax flag and the log path writes (x - max) * scale - log(sum) directly.

The OpenCL kernels had the same problem with LOG_SOFTMAX: they now keep x - max, add up exp(x - max) and return x - max - log(sum). This covers the generic kernels in softmax.cl and the subgroup kernels in softmax_loss.cl.

Port of #30545 to 5.x.
2026-11-15 12:50:26 +05:30
Shiven Solanki
cc26a67b62 doc(core): fix LUT index formula for CV_8S and CV_16S inputs (#30793)
* doc(core): fix LUT index formula for CV_8S and CV_16S inputs

LUT reads CV_8S and CV_16S values as the unsigned numbers with the same bits, so negative values index the upper half of the table (-1 maps to entry 255 for CV_8S). The docs said the index was src + 128 (CV_8S) or src + 32768 (CV_16S), which is wrong for every value. Also remove a stray 'ref' in the compare docs.

* doc(core): fix LUT index rule in HAL interface docs

cv_hal_lut and cv_hal_lut16 docs still said 128 or 32768 is added to the index for 8s and 16s inputs. Use the same rule as the LUT docs: the input is read as unsigned with the same bits, and no offset is added.
2026-11-15 12:49:38 +05:30
Madan mohan Manokar
b6185cb365 Merge pull request #30679 from amd/port_5.x_pyrDown
imgproc: port 4.x Optimized OpticalFlowPyrLK to 5.x
2026-11-15 12:40:45 +05:30
Shiven Solanki
efe44093c3 Merge pull request #30706 from sshivensolanki/core-locateroi-1d (#30706)
core: fix locateROI and getUMat for 1D Mat and UMat

Problem
For a 1D Mat, Mat::locateROI divides by step[0] (the element size), so it counts every element as a row and returns a wrong wholeSize and offset. Because of this, adjustROI doesn't grow 1D slices, and getUMat on a 1D slice recurses until the stack overflows. UMat::locateROI has the same bug.

Fix
Mat::locateROI and UMat::locateROI: for dims == 1, compute the offset and whole size from the element size: ofs = (delta1 / esz, 0) and wholeSize = (delta2 / esz, 1). The width is clamped to at least ofs.x + cols, like the 2D code.
Mat::getUMat: for a 1D slice, cut the result out of the whole UMat with a Range instead of a Rect, so the returned UMat stays 1D. Cutting with a Rect always made it 2D.
2D Mats and UMats are unchanged.
2026-11-13 16:16:51 +05:30
Abhishek Gola
f62ce23b91 Merge pull request #30655 from sshivensolanki/core-add-sub-64-saturate ( #30655)
core: saturate cv::add and cv::subtract on CV_64S and CV_64UProblem
cv::add and cv::subtract are documented to saturate, and they do on every depth up to 32 bits. On 64 bits there is no wider type to hold the result, so add wrapped on CV_64S and CV_64U, and subtract wrapped on CV_64S. For example, INT64_MAX + 1 gave INT64_MIN. Signed overflow is also undefined behaviour in C++.

Fix
Added int64_t and uint64_t overloads of EwAdd::scl and an int64_t overload of EwSub::scl. They check for overflow before computing the result, like the existing uint64_t overload in EwSub.
Updated the comment on EwAdd::scl, which described 32-bit and 64-bit results as wrapping.
Other depths still use the generic scl, so their behaviour does not change.
2026-11-13 16:15:41 +05:30
Kaustubh Arora
998f72949d dnn: keep INT4/UINT4 QuantizeLinear off the AVX2 per-tensor fast path (#30616)
* dnn: keep INT4/UINT4 QuantizeLinear off the AVX2 per-tensor fast path

The x86 AVX2 path for per-tensor float to int8/uint8 returns before the
4-bit saturation added in #30596, so INT4/UINT4 outputs were still
clamped to the 8-bit range there. Skip it for 4-bit output and add a
per-tensor INT4/UINT4 test that reaches that path on x86.

* dnn: clamp INT4/UINT4 inside the AVX2 per-tensor QuantizeLinear path

Pass the output range into the AVX2 kernel instead of skipping it, so
per-tensor INT4/UINT4 keeps the vectorized, parallel path; the kernel
already clamps in float before converting. The post-pass from #30596
is only reached by the generic path now. Widen the regression test to
35 elements so it covers the 8-lane loop and the scalar tail on x86.

* dnn: drop the PR reference from the INT4 QuantizeLinear test comment

---------

Co-authored-by: Kaustubh Arora <arorakaustubh681@gmail.com>
2026-11-13 16:06:37 +05:30
velonica0
07b31f1e2e video: dis: vectorize Densification_ParBody with scalable intrinsics (#30546)
* video: dis: vectorize Densification_ParBody with scalable intrinsics

* video: dis: address review comments: braces, parameterized test on all platforms

* video: dis: restore useOptimized with a scope guard in the DIS reference test
2026-11-13 15:38:44 +05:30
Shiven Solanki
76bae0c542 core: support CV_16F and CV_16BF in finiteMask (#30620)
* core: support CV_16F and CV_16BF in finiteMask

finiteMask asserted CV_32F or CV_64F input, so 16-bit float arrays,
which can hold NaN and infinity too, could not be checked.

Add finiteMask16_, which marks a pixel as finite if no channel has an
all-ones exponent (0x7c00 for CV_16F, 0x7f80 for CV_16BF), for 1 to 4
channels. getFiniteMaskFunc now takes the depth. The OpenCL kernel only
handles float and double, so other depths fall back to the CPU path.

* core: use SIMD and typed templates in 16-bit finiteMask

Use hfloat and bfloat as the template parameter of finiteMask16_ instead
of the raw exponent masks, and add a universal-intrinsics path for 1 to
4 channels.

Add Core_FiniteMask_bits, which checks exact bit patterns at the edges
of the exponent: largest finite, subnormal, signalling, quiet and
negative NaN, and both infinities.

* core: use the scalar loop for 1-channel 16-bit finiteMask

With 1 channel, the compiler vectorizes the scalar loop, and it runs
faster than the explicit SIMD path. Use the SIMD path only for 2 to 4
channels.
2026-11-13 15:36:54 +05:30
Shiven Solanki
6519feb194 Merge pull request #30778 from sshivensolanki/fix-flip-1d (#30778)
core: keep 1D Mat 1D in cv::flip
2026-11-13 14:35:35 +05:30
Abhishek Gola
1ea6b2b662 Merge pull request #29904 from rsnk96/farneback-reuse-polyexp
video: reuse the polynomial expansion between Farneback optical flow calls 🤖🤖🤖
2026-11-13 13:32:19 +05:30
Minsoo Kim
f7375101ab Document BORDER_TRANSPARENT for warpPerspective 🤖🤖🤖 (#29765)
* Document transparent border for warpPerspective

* Keep warpPerspective clarification documentation-only

Remove the focused transparent-border test as requested in review. Preserve the documented border behavior and leave the existing image-warp test suite unchanged.
2026-11-13 08:19:44 +05:30
Shiven Solanki
fcfa24dfb7 core: support 1D Mat inputs in gemm (#30704)
* core: support 1D Mat inputs in gemm

A 1D Mat is a single row, but its step[0] is the element size, not the row size, so gemm passed a too-small row step to the HAL kernels and failed with "_step >= minstep". Give 1D A, B and C an ordinary 2D one-row header before calling the kernels.

Fixes #30703

* core: support preallocated 1D output in gemm

When the caller passes a 1D Mat of the right size as the output, _matD.create() keeps it as is, so D still had step[0] == elemSize() and the kernel failed with "_step >= minstep". Give a 1D D a 2D one-row header too. The result is still written into the caller's buffer.

* core: use TEST_P for the 1D gemm test
2026-11-13 08:17:17 +05:30
MEG-1453
5033ae460f Merge pull request #30772 from MEG-1453/trackernano-small-targets (#30772)
video(TrackerNano): do not clamp the target size to 10 px
2026-11-13 07:45:40 +05:30
Abhishek Gola
bb1bcfd583 Merge pull request #30789 from Aletimo03/pnp-ransac-planar-27098-5x (#30789)
geometry: fix solvePnPRansac returning the mirrored pose of planar objects
2026-11-13 07:44:57 +05:30
Alessio Timofte
d9ab52e4ad geometry: fix solvePnPRansac returning the mirrored pose of planar objects
Port of #30434 to 5.x. Since 4.7.0 the final SOLVEPNP_ITERATIVE
refinement starts from the minimal sample model. For a planar object
this model can be the mirrored pose, and Levenberg-Marquardt stays in
that local minimum. For planar inliers, also refine from the homography
based initialization of SOLVEPNP_ITERATIVE and keep the pose with the
lower reprojection error. Non-planar objects are not affected.

Fixes #27098
2026-11-12 11:42:07 +01:00
Tanveer
38f42fcaa5 imgproc: accept 1x256 user colormap in applyColorMap 2026-11-12 13:36:46 +05:30
RS Nikhil Krishna
75ff081cfb video: reuse the polynomial expansion between Farneback calls
Add OPTFLOW_FARNEBACK_REUSE_EXPANSION, an opt-in flag set through
FarnebackOpticalFlow::setFlags() / create(..., flags). When set, calc() keeps
the polynomial expansion of the previous call's next frame and reuses it as
the expansion of the following call's prev frame, which saves roughly 9-14%
on consecutive-frame sequences. Results are bit-identical with reuse on and
off. The flag adds no virtual methods, is ignored by calcOpticalFlowFarneback()
and by the OpenCL path, and clearing it or calling collectGarbage() frees the
cache.

Tests go into test_OF_accuracy.cpp and test_OF_reproducibility.cpp and seed
their data from theRNG(). Includes a perf test and a tutorial section.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 22:32:58 -05:00
Shiven Solanki
a20d208db5 doc(core): note unsupported input depths in inRange and addWeighted
inRange rejects CV_Bool and CV_8F inputs and addWeighted rejects CV_Bool inputs, but the docs did not say so. Also fix type-name typos in core.hpp (CV8S, CV_8S1) and two other spelling mistakes.
2026-11-12 07:55:35 +08:00
Shiven Solanki
2404ce75c1 core: add insertChannel and extractChannel test for all depths (#30625)
* core: add insertChannel and extractChannel test for all depths

insertChannel had no CPU test that checks its values, and extractChannel
was only checked on CV_8UC3. Add a test for every depth with 2 to 4
channels: inserting into one channel must leave the others unchanged,
and extractChannel must return the inserted channel.

* core: use CV_DEPTH_CURR_MAX in insertChannel test

Cover every depth with a range instead of listing them by hand, so new
depths are tested automatically.
2026-11-11 14:45:51 +05:30
Christos
8d9f0cb447 Merge pull request #30738 from cstamatopoulos/xfeat-reference-sampling (#30738 )
features: sample cv::XFeat maps like the reference XFeat
2026-11-11 12:57:40 +05:30