1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

37229 Commits

Author SHA1 Message Date
Abhishek Gola 873a4635c6 Merge pull request #28752 from abhishek-gola:net_profiling
Added net profiling support #28752

### 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-14 14:47:38 +03:00
Alexander Smorkalov ba925f9b07 Merge pull request #29030 from asmorkalov:as/cube_root_ub
Suppressed UB warning in cubeRoot function.
2026-05-14 13:56:09 +03:00
Rafael Muñoz Salinas cc1ab3e3ac Merge pull request #28773 from rmsalinas:imgproc_find_truco_contours
imgproc: add findTRUContours - lock-free parallel contour extraction #28773

Integrates the TRUCO algorithm (Threaded Raster Unrestricted Contour Ownership, @cite TRUCO2026) as a transparent fast path inside `cv::findContours`. No API change is required: existing code automatically benefits when `mode=RETR_LIST` and no hierarchy output is requested.

### How it works

When `mode=RETR_LIST` and the caller does not request hierarchy, `findContours` delegates to the TRUCO parallel engine instead of Suzuki-Abe. All ContourApproximationModes are supported; approximation is applied in parallel after extraction. In all other cases the original Suzuki-Abe path is used unchanged.

### Key design ideas
- Row-strip domain decomposition parallelised via `cv::parallel_for_`
- Start-point ownership rule + speculative downward tracing eliminate tile stitching and synchronisation primitives (lock-free)
- 8-bit state space instead of the 32-bit integer labeling required by Suzuki-Abe, giving higher SIMD throughput and lower memory-bandwidth pressure
- Paged contour buffer (`TRUCOPagedContour`) avoids heap reallocation on the hot tracing path
- SIMD-accelerated row scanning via `cv::v_uint8` intrinsics
- Thread count controlled globally via `cv::setNumThreads()`, consistent with OpenCV conventions

### Output correctness

Significant effort has gone into ensuring the output is identical to the original `findContours` in every respect: same contour set, same ordering, and same approximation results for all methods. A dedicated test suite (`test_contours_truco.cpp`) verifies exact match against Suzuki-Abe across all four `ContourApproximationModes` and thread counts from 1 to 39, using noise images, circles, nested rectangles, and mixed scenes.

### Performance vs. Suzuki-Abe (from submitted paper)
- single-thread: ~1.8–1.9× faster (8-bit SIMD advantage)
- 20 threads: ~14–20× faster on i7-13700H (6P+8E, 20T)
- 20 threads: ~10–12× faster on Xeon Silver 4510 (12C/24T)

### 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-14 13:55:39 +03:00
Alexander Smorkalov fb3054d814 Suppressed UB warning in cubeRoot function. 2026-05-14 11:26:40 +03:00
Giles Payne 7cc6d8576c Merge pull request #28704 from komakai:replace-jazzy-with-docc
Use Xcode DocC tool for buiding Apple platform docs + add quick-start tutorial #28704

### 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

This PR resolves https://github.com/opencv/opencv/issues/28702 and https://github.com/opencv/opencv/issues/28703
Additionally it resolves build issues on Apple platforms by making build scripts run with Python 3
2026-05-14 11:22:04 +03:00
Pratham Kumar eadaab5fbb Merge pull request #28664 from pratham-mcw:armpl_dft_opt
Add ARMPL support for DFT Function #28664

- This PR introduces hal/armpl/ with implementation of 1D, 2D DFT and DCT routines using ARM Performance Libraries as a custom HAL replacement for OpenCV's DFT & DCT Function.
- ArmPL MSI package is automatically downloaded and extracted via CMake when building on Windows ARM64, with a WITH_ARMPL option that defaults to ON for that platform.
- Forward and inverse real DFT calls in dxt.cpp are routed through ArmPL when available, with scaling applied only when needed.
- Test error thresholds in test_dxt.cpp are relaxed (from 1e-5 to 2e-4 for float ) to account for numerical differences between ArmPL and OpenCV's reference DFT results.

**Performance Benchmarks :**
<img width="993" height="835" alt="image" src="https://github.com/user-attachments/assets/76def647-6d20-4bce-8bc9-7363e723669f" />

- [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-05-14 10:56:21 +03:00
Alexander Smorkalov 851e0196b4 Merge pull request #29012 from asmorkalov:as/int_scissors
Moved IntelligentScissors to photo module.
2026-05-14 09:21:47 +03:00
manfred 550f95a923 gapi/fluid: add Universal Intrinsics SIMD for InRange kernel
- Implement inrange_simd() covering uchar/ushort/short, chan=1/2/3/4
- Replace legacy CV_SIMD128 run_inrange3 with modern CV_SIMD API
- Extend perf tests to cover all added type/channel combinations
- Resolves TODO introduced in #12608 (2018)
2026-05-14 13:48:15 +08:00
orbisai0security 357ad24262 Merge pull request #28915 from orbisai0security:fix-v-001-filter-memcpy-bounds-check
fix: Guard ndsrvp filter center copy when source span is empty #28915

## Summary
This adds a defensive guard around the centre-region `memcpy` in the ndsrvp HAL filter padding path.

**Description**: Multiple memcpy calls in the ndsrvp HAL filter, bilateral filter, and median blur routines use computed sizes (e.g., cnes * (rborder - j), cn * (rborder - j), src_step * height) without validating that the computed byte count fits within the destination buffer. An attacker supplying a crafted image with manipulated dimensions, channel counts, or border parameters can cause the computed copy size to exceed the allocated destination buffer, resulting in a heap buffer overflow that corrupts adjacent memory.

## Changes
- `hal/ndsrvp/src/filter.cpp`

## Verification
- [x] Build passes
- [x] Scanner re-scan confirms fix
- [x] LLM code review passed

---
*Automated security fix by [OrbisAI Security](https://orbisappsec.com)*
2026-05-14 07:52:08 +03:00
Alexander Smorkalov 0ba56c3ecc Moved IntelligentScissors to photo module. 2026-05-13 10:53:09 +03:00
Abhishek Gola 914c0b2bc8 Merge pull request #28963 from abhishek-gola:custom_layers
Added custom layer support in new DNN engine #28963

Closes: https://github.com/opencv/opencv/issues/26200
Merge with: https://github.com/opencv/opencv_extra/pull/1358

### 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-13 10:31:25 +03:00
Abhishek Gola 72e0bc2bf3 Merge pull request #28957 from abhishek-gola:fusion_block_layout_extension
Extend attention fusion for runtime QK scale and add MatMul to Gemm rewriter #28957

### 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-13 08:32:00 +03:00
omrope79 7b6dc220b1 Merge pull request #28722 from omrope79:fix-dnn-fusion
fixes a bug in ENGINE_NEW of incorrect fusion of conv+relu+batchnorm #28722

### Pull Request Readiness Checklist

OpenCV Extra: https://github.com/opencv/opencv_extra/pull/1325
Closes Issue https://github.com/opencv/opencv/issues/28689

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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-12 23:23:31 +03:00
Prasad Ayush Kumar 223b110c30 Merge pull request #28968 from Prasadayus:Identity_function_fix_for_0D
Fixes the issue for Identity functions for 0D #28968

Closes https://github.com/opencv/opencv/issues/25763

### 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-12 14:43:46 +03:00
Prasad Ayush Kumar 2ad46b860b Merge pull request #28982 from Prasadayus:fix_unconnected_out_layers
fix getUnconnectedOutLayers() in new engine #28982

Solves https://github.com/opencv/opencv/issues/26491

### 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-12 13:34:01 +03:00
donotsleepy e640a9bfb8 Merge pull request #28995 from donotsleepy:fix/png-found-status-guard
cmake: fix PNG status display when BUILD_PNG=ON #28995

### Description

Fixes #28657.

On macOS (and other Apple platforms), `BUILD_PNG=ON` is the default. The build system correctly clears `PNG_FOUND` in `OpenCVFindLibsGrfmt.cmake` and builds libpng from the bundled source. However, during the subsequent module processing phase, a downstream `find_package(PNG)` call — triggered transitively via `include()` in the **same scope** — overwrites not only `PNG_FOUND`, but also `PNG_INCLUDE_DIR`, `PNG_LIBRARIES`, and `PNG_VERSION_STRING`.

#### Root Cause: FindPNG.cmake Has Asymmetric Guards

Reading CMake 4.3's `FindPNG.cmake` (`/opt/homebrew/share/cmake/Modules/FindPNG.cmake`) reveals:

| Variable | Guard? | Fate |
|---|---|---|
| `PNG_LIBRARY` | `if(NOT PNG_LIBRARY)` at line 138 — **guarded** | Preserved |
| `PNG_PNG_INCLUDE_DIR` | `find_path(...)` at line 115 — **no guard** | **Overwritten** |
| `PNG_INCLUDE_DIR` | Derived from `PNG_PNG_INCLUDE_DIR` | **Chain-overwritten** |
| `PNG_LIBRARIES` | Derived from `PNG_LIBRARY` + `ZLIB_LIBRARY` | **Partly overwritten** |
| `PNG_VERSION_STRING` | Parsed from `PNG_PNG_INCLUDE_DIR/png.h` | **Overwritten** |

`PNG_LIBRARY` survives because FindPNG itself checks `if(NOT PNG_LIBRARY)`. But `find_path(PNG_PNG_INCLUDE_DIR)` runs unconditionally — re-searching and overwriting the bundled path with the system one.

#### Fix: Three Coordinated Changes

**Part A — Status guard** (`CMakeLists.txt`): When `BUILD_PNG=ON`, pass `FALSE` as the condition to always show `"build"` regardless of `PNG_FOUND`.

**Part B — Variable lock** (`cmake/OpenCVFindLibsGrfmt.cmake`): After building from bundled source, lock `PNG_PNG_INCLUDE_DIR` as `CACHE INTERNAL`. CMake's `find_path()` checks the cache first — if the variable exists with a valid path, it skips re-searching. The system path is never found.

**Part C — Cache cleanup** (`cmake/OpenCVFindLibsGrfmt.cmake`): Add `PNG_PNG_INCLUDE_DIR` to the `ocv_clear_internal_cache_vars()` call in the `else` branch. When a user switches `BUILD_PNG=OFF`, the cached variable is cleared, allowing `find_path` to search for the system libpng normally. Prevents stale cache leakage across configuration changes.

#### Verification (macOS 26, CMake 4.3, Homebrew libpng 1.6.58)

```
BEFORE downstream find_package(PNG):
  PNG_LIBRARY   = libpng
  PNG_INCLUDE_DIR = .../3rdparty/libpng
  PNG_VERSION_STRING = 1.6.37

AFTER downstream find_package(PNG) [with fix]:
  PNG_LIBRARY   = libpng          ← preserved (FindPNG guard)
  PNG_INCLUDE_DIR starts with .../3rdparty/libpng  ← locked (Part B)
  PNG_VERSION_STRING = 1.6.53     ← from bundled png.h
  Status display: build (ver 1.6.53)  ← correct (Part A)
```

The full reproduction and analysis are in the attached `bugReview/` directory.

### Checklist

- [x] There is a reference to the original bug report and related work
- [x] The test case is in `bugReview/` directory
- [x] Tested on macOS 26 (arm64) with CMake 4.3 + Homebrew libpng 1.6.58
- [x] Cache hygiene verified for BUILD_PNG ON→OFF→ON transitions
2026-05-12 12:40:57 +03:00
Alexander Smorkalov 594cd4204a Merge pull request #28999 from Teddy-Yangjiale:rvv-sigmoid-opt
dnn: vectorize SigmoidFunctor using universal intrinsics
2026-05-12 11:29:12 +03:00
Rafael Muñoz Salinas b7ae67e8ec Merge pull request #28990 from rmsalinas:fix-flann-radiussearch-output-size
flann: fix Index::radiusSearch output size mismatch #28990

## Problem

`Index::radiusSearch` returns `nn` — the number of neighbors found within the radius — but the output arrays `_indices` and `_dists` are always allocated with `maxResults` columns regardless of how many neighbors were actually found. This creates two inconsistencies:

1. When `nn < maxResults`, the output arrays contain stale entries beyond position `nn`, so `nn != indices.cols` and callers cannot rely on the output size to know how many results are valid.
2. When `nn > maxResults`, the return value exceeds the capacity of the output arrays, which have only `maxResults` columns. The extra neighbors were never stored, so the return value is misleading.

The following snippet reproduces both cases:

```cpp
int testFLANN(){
    std::vector<cv::Point2f> corners={{3679.83,1857.22},{3324.43,1850.67},{3278.83,1502.32},{3621.32,1508.69},{3662.26,1837.97},{3336.06,1839.28},{3291.74,1516.03},{3608.94,1518.72},{2980.66,1843.22},{2628.11,1837.14},{2607.73,1491.57},{2948.22,1496.76},{2289.31,1830.19},{1943.99,1824.17},{1945.51,1482.34},{2280.68,1487.39},{1607.47,1819.11},{1260.04,1813.26},{1283.94,1470.34},{1620.03,1475.85},{923.063,1808.08},{576.193,1802.4},{624.713,1459.78},{959.715,1464.93},{3270.25,1494.98},{2952.95,1492.19},{2922.75,1190.02},{3231.05,1194.81},{3284.82,1507.62},{2942.74,1502.59},{2912.32,1178.33},{3242.98,1183.19},{2612.82,1496.37},{2276.44,1491.63},{2267.61,1170.13},{2593.64,1174.43},{1949.73,1486.61},{1614.92,1480.64},{1626.77,1160.34},{1952,1165.51},{1289.38,1476.21},{953.709,1470.21},{986.779,1148.92},{1311.98,1154.89},{3567.28,1195.1},{3237.51,1189.03},{3197.63,884.15},{3518.61,888.76},{2918.31,1183.62},{2588.69,1179.37},{2570.64,875.672},{2889.87,878.902},{2271.97,1174.25},{1947.62,1169.61},{1948.56,868.197},{2263.8,872.533},{1630.99,1164.6},{1306.74,1159.52},{1327.81,858.358},{1642.69,862.765},{992.896,1155.52},{666.107,1149.96},{705.246,845.776},{1023.25,851.582},{3204.48,889.981},{2883.49,885.252},{2859.31,593.752},{3175.43,594.736},{2575.86,880.331},{2259.44,876.647},{2252.33,589.235},{2560.47,592.332},{1954.36,873.708},{1636.7,868.068},{1646.93,580.76},{1956.14,584.797},{1332.02,862.624},{1017.11,856.71},{1045.32,572.178},{1350.95,577.635},{3481.36,605.324},{3169.05,601.083},{3138.84,324.116},{3446.12,325.545},{2866.14,599.61},{2555.38,597.142},{2541.51,320.931},{2845.5,322.419},{2256.79,593.253},{1950.17,590.12},{1951.8,317.445},{2250.88,319.418},{1654.16,587.663},{1344.83,582.787},{1362.8,309.253},{1663.89,313.056},{1050.94,577.867},{741.476,571.648},{776.433,300.444},{1076.97,304.56},{3327.05,1847.65},{2977.74,1840.48},{2945.48,1499.68},{3281.82,1504.97},{2630.85,1834.22},{2287.2,1828.06},{2278.56,1489.51},{2610.64,1494.31},{1946.11,1822.05},{1604.75,1816.18},{1617.11,1478.59},{1947.62,1484.48},{1262.96,1810.53},{920.46,1805.05},{956.712,1467.57},{1286.66,1473.27},{3618.7,1511.71},{3281.82,1504.97},{3240.24,1186.11},{3564.22,1192.53},{2945.48,1499.68},{2610.64,1494.31},{2591.52,1176.55},{2915.32,1180.97},{2278.56,1489.51},{1947.62,1484.48},{1949.81,1167.56},{2269.79,1172.18},{1617.11,1478.59},{1286.66,1473.27},{1308.98,1157.53},{1628.88,1162.47},{956.712,1467.57},{627.315,1462.81},{669.943,1146.75},{989.494,1151.86},{3240.25,1186.11},{2915.32,1180.98},{2887.03,881.727},{3200.69,886.725},{2591.52,1176.55},{2269.79,1172.19},{2261.62,874.587},{2573.63,878.324},{1949.81,1167.55},{1628.88,1162.47},{1640.44,864.751},{1950.74,870.259},{1308.98,1157.53},{989.494,1151.86},{1019.41,854.787},{1329.92,860.49},{3515.88,891.68},{3200.69,886.725},{3171.89,598.263},{3478.26,602.785},{2887.04,881.725},{2573.63,878.324},{2558.28,594.392},{2863.1,597.005},{2261.62,874.587},{1950.74,870.259},{1952.4,588.114},{2254.56,591.241},{1640.44,864.751},{1329.92,860.49},{1348.65,579.559},{1650.55,584.209},{1019.41,854.787},{708.649,849.44},{745.388,568.534},{1047.42,574.313},{3171.89,598.263},{2863.1,597.005},{2842.6,325.169},{3141.93,326.654},{2558.28,594.392},{2254.56,591.241},{2248.65,321.425},{2544.55,323.537},{1952.4,588.113},{1650.55,584.209},{1660.07,316.284},{1954.02,319.457},{1348.65,579.559},{1047.43,574.312},{1073.06,307.674},{1366.42,312.707}};

    cv::flann::KDTreeIndexParams indexParams(1);
    cv::Mat data = cv::Mat(corners).reshape(1, static_cast<int>(corners.size()));
    auto index = std::make_shared<cv::flann::Index>(data, indexParams);

    int maxResults = 4;
    int nTimesError1 = 0;  // nn != indices.size()
    int nTimesError2 = 0;  // nn > maxResults
    for (size_t i = 0; i < corners.size(); i++) {
        std::vector<int> indices(4);
        std::vector<float> dists(4);
        int nn = index->radiusSearch(data.row(static_cast<int>(i)), indices, dists, 100, maxResults);
        if (nn != (int)indices.size()) { nTimesError1++; }
        if (nn > maxResults)           { nTimesError2++; }
    }
    std::cout << "nTimesError1: " << nTimesError1 << std::endl;  // > 0 before fix
    std::cout << "nTimesError2: " << nTimesError2 << std::endl;  // > 0 before fix

    return 1;
}
```

## Fix

- Capture the search result in `rsearch_ret` instead of returning early from each `switch` case (this also required adding the missing `break` statements that would otherwise have caused fall-through between type-incompatible distance specialisations).
- Cap `rsearch_ret` at `maxResults` so the return value never exceeds the capacity of the output arrays.
- When `rsearch_ret < maxResults`, trim `_indices` and `_dists` to `query.rows × rsearch_ret` via `colRange(0, rsearch_ret).copyTo(...)` so the output dimensions always match the returned count.
2026-05-12 10:41:01 +03:00
Varun Jaiswal 3cebf7d61e Merge pull request #28969 from varun-jaiswal17:update_ort_version-1.25.1
update default ONNX Runtime version to 1.25.1 #28969

Bump ONNX Runtime default version to latest version: 1.25.1

Includes the following update:
 https://github.com/microsoft/onnxruntime/pull/27164 : Adds LpNormalization opset-22 kernel support missing in 1.24.2. 

### 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-12 07:29:22 +03:00
Teddy-Yangjiale 4b1c861ab7 dnn: vectorize SigmoidFunctor using universal intrinsics 2026-05-12 02:22:19 +08:00
Abhishek Gola 8cc3f68cd4 Merge pull request #28964 from abhishek-gola:extend_primitive_core_ops
Extended primitive core operations to support new types #28964

The support was already there, this PR tests them on edge cases and patch the fix.

closes: https://github.com/opencv/opencv/issues/24580
### 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-08 17:32:56 +03:00
Abhishek Gola cc2b7659b4 Merge pull request #28966 from abhishek-gola:dequantized_issue_fix
Fixed dequantizelinear slicing bug #28966

closes: https://github.com/opencv/opencv/issues/25999

### 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-08 16:57:24 +03:00
Pratham Kumar 9929b5ceb9 Merge pull request #28610 from pratham-mcw:core-norm_mask-opt
core : add NEON intrinsics support for norm_mask function #28610

- This PR adds NEON intrinsics-based implementations for masked norm operations in norm.simd.hpp for ARM64 architecture.
- The optimized implementation uses ARM NEON intrinsics to accelerate masked norm computations (Infinity norm, L1 norm, and L2 norm) used by the norm function when a mask is provided.
- In the x64 architecture, masked norm operations benefit from IPP-based optimized implementations. However, on ARM64, the execution falls back to scalar implementations, which results in lower performance.
- To achieve performance parity with x64, NEON-based SIMD implementations have been added for ARM64.
- Additionally, scalar loop unrolling optimizations have been added for non-masked norm operations.
- After introducing these changes, masked norm operations showed significant performance improvements on ARM64 platforms, particularly for single-channel (cn=1) operations where NEON intrinsics provide the greatest benefit.
<img width="952" height="822" alt="image" src="https://github.com/user-attachments/assets/12d35f93-a316-4520-9d9c-12ce6b371ddb" />

- [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-05-08 09:57:09 +03:00
Alexander Smorkalov 5488f4e11d Merge pull request #28961 from dkurt:d.kurtaev/ov_avgpool_opset16
Enable 1D int8 AvgPool with OpenVINO with 2025.3
2026-05-08 08:48:32 +03:00
Alexander Smorkalov 0b1e4f54da Merge pull request #28959 from Kumataro:fix28930
core: fix signed overflow UB in Point/Point3i::dot()
2026-05-07 21:25:07 +03:00
Abhishek Gola 642a7307c4 Merge pull request #27560 from abhishek-gola:convTranspose_layer_add
Added fully functional convTranspose layer to new DNN engine #27560

Closes https://github.com/opencv/opencv/issues/26307

### 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-07 21:20:39 +03:00
Dmitry Kurtaev 92139a6dc4 Enable 1D int8 AvgPool with OpenVINO with 2025.3 2026-05-07 21:14:04 +03:00
Alexander Smorkalov 80046ae2d8 Merge pull request #28958 from asmorkalov:as/qt5_world
Fixed OpenCV World module build with QT 5.
2026-05-07 16:12:56 +03:00
Kumataro a7603daf18 core: fix signed overflow UB in Point/Point3i::dot() 2026-05-07 21:37:21 +09:00
Alexander Smorkalov e98e3ffc17 Fixed OpenCV World module build with QT 5. 2026-05-07 15:13:33 +03:00
Alexander Smorkalov bf4a5803c6 Merge pull request #28951 from vrabaud:ubsan
Add CV_DISABLE_UBSAN to disable undefined behavior sanitizer
2026-05-07 08:12:20 +03:00
jiajia Qian 60858fce9e core: implement OpenCL kernel for UMat::diag to avoid aliasing races
The previous OpenCL implementation of UMat::diag() relied on a sequence of
operations involving buffer initialization followed by copy/transpose on
an aliased diag() view. Although these operations were enqueued on an
in-order command queue, this implicitly assumed memory visibility between
kernels operating on aliased regions of the same buffer.

According to the OpenCL specification, in-order command queues only guarantee
command scheduling order, while memory visibility between commands is only
established through explicit command-level synchronization points (e.g.
events, barriers, or clFinish).Under OpenCL’s relaxed memory model, such
assumptions are not guaranteed without an explicit command-level synchronization
point, and can lead to data races and incorrect results, especially for very
small matrices (e.g. 1x1). The issue is more likely to be exposed on Mesa-based drivers
when the GPU is running at lower frequencies (e.g. 500 MHz).

This change introduces a dedicated OpenCL kernel to construct the diagonal
matrix in a single kernel invocation, avoiding intermediate aliasing and
eliminating the need for implicit ordering assumptions. If the OpenCL path
is unavailable or unsupported, the implementation transparently falls back
to the CPU path.

Signed-off-by: jiajia Qian <jiajia.qian@nxp.com>
2026-05-07 09:18:29 +08:00
Vincent Rabaud 504899d433 Add CV_DISABLE_UBSAN to disable undefined behavior sanitizer
Also fix code here and there that triggered the fuzzer.
2026-05-06 16:56:38 +02:00
Prasad Ayush Kumar e519173241 Merge pull request #28839 from Prasadayus:Block-Layout-Support
Extend several operations to support block layout #28839

Requires opencv_extra: https://github.com/opencv/opencv_extra/pull/1347

After this PR, we observed the following improvements in the listed models:


Model | Before (ENGINE_NEW) | After (ENGINE_NEW) | ENGINE_ORT | % Improvement (Before v/s After)
-- | -- | -- | -- | --
Face_Paint | 514.68ms | 384.40ms | 394.38ms | 25.31%
BlazeFace | 1.03ms | 0.83ms | 0.66ms | 19.42%

**Device details:**
 Model name: Intel(R) Core(TM) i9-14900KS, x86_64, 32 Cores, Ubuntu 22.04.5 LTS

Operations covered:

- [x] Pad
- [x] Resize
- [x] Reshape
- [x] Shape
- [x] InstanceNorm
- [x] GroupNorm

### 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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-06 16:20:45 +03:00
Alex Wu 30fffe2fa0 Merge pull request #28887 from milllemonman:4.x
hal/riscv-rvv: implement laplacian #28887

OpenCV Extra: https://github.com/opencv/opencv_extra/pull/1353

An implementation of laplacian for riscv-rvv hal

Added benchmark in perf_laplacian.cpp
The performance is evaluated on K1 by running 
./opencv_perf_imgproc --gtest_filter="Perf_Laplacian*"
Results are attached in the figure below.

CV_8U fast path supports ksize=3 with BORDER_CONSTANT/BORDER_REPLICATE; unsupported combinations fall back to default implementation. See performance results bellow.

### 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
      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-05-06 16:05:28 +03:00
Alexander Smorkalov 6c0699c8c3 Merge pull request #28946 from mshabunin:fix-gst-ubuntu26
videoio: workaround GStreamer tests on Ubuntu 26
2026-05-06 15:31:01 +03:00
Alexander Smorkalov ca8e6f0ba1 Merge pull request #28830 from AlrIsmail:imgproc-parallel-filter-26074
imgproc: implement thread-safe, 2D-tiled parallel execution for FilterEngine
2026-05-06 15:27:55 +03:00
Alexander Smorkalov 96d8a78537 Merge pull request #28895 from vrabaud:cxx
Port CvLevMarq to C++
2026-05-06 12:20:08 +03:00
Abhishek Gola 2760c0c08a Merge pull request #28931 from abhishek-gola:extended_fusions
Extended graph fusion for transformer models #28931

### Pull Request Readiness Checklist

Performance numbers on Intel(R) Core(TM) i9-14900KS:
```
AlexNet::DNNTestNetwork::OCV/CPU                           7.143   6.871     1.04   
AlexNet::DNNTestNetwork::OCV/OCL                           7.471   7.047     1.06   
AlexNet::DNNTestNetwork::OCV/OCL_FP16                      7.157   6.907     1.04   
BERT::DNNTestNetwork::OCV/CPU                              9.454   9.154     1.03   
BERT::DNNTestNetwork::OCV/OCL                              9.657   9.138     1.06   
BERT::DNNTestNetwork::OCV/OCL_FP16                         9.590   9.271     1.03   
CRNN::DNNTestNetwork::OCV/CPU                             18.194  17.020     1.07   
CRNN::DNNTestNetwork::OCV/OCL                             17.855  17.433     1.02   
CRNN::DNNTestNetwork::OCV/OCL_FP16                        17.629  17.277     1.02   
DenseNet_121::DNNTestNetwork::OCV/CPU                     24.735  23.863     1.04   
DenseNet_121::DNNTestNetwork::OCV/OCL                     24.991  25.140     0.99   
DenseNet_121::DNNTestNetwork::OCV/OCL_FP16                24.598  24.019     1.02   
EAST_text_detection::DNNTestNetwork::OCV/CPU              26.929  27.084     0.99   
EAST_text_detection::DNNTestNetwork::OCV/OCL              26.863  27.531     0.98   
EAST_text_detection::DNNTestNetwork::OCV/OCL_FP16         26.884  27.082     0.99   
EfficientDet::DNNTestNetwork::OCV/CPU                     62.667  62.716     1.00   
EfficientDet_int8::DNNTestNetwork::OCV/CPU                34.446  34.796     0.99   
EfficientNet::DNNTestNetwork::OCV/CPU                     11.875  11.786     1.01   
EfficientNet::DNNTestNetwork::OCV/OCL                     12.434  11.806     1.05   
EfficientNet::DNNTestNetwork::OCV/OCL_FP16                11.886  11.899     1.00   
FastNeuralStyle_eccv16::DNNTestNetwork::OCV/CPU           15.104  14.327     1.05   
FastNeuralStyle_eccv16::DNNTestNetwork::OCV/OCL           15.071  14.670     1.03   
FastNeuralStyle_eccv16::DNNTestNetwork::OCV/OCL_FP16      15.262  14.072     1.08   
GoogLeNet::DNNTestNetwork::OCV/CPU                         5.030   5.031     1.00   
GoogLeNet::DNNTestNetwork::OCV/OCL                         5.075   5.017     1.01   
GoogLeNet::DNNTestNetwork::OCV/OCL_FP16                    5.053   5.055     1.00   
Inception_5h::DNNTestNetwork::OCV/CPU                      6.777   6.430     1.05   
Inception_5h::DNNTestNetwork::OCV/OCL                      7.309   6.683     1.09   
Inception_5h::DNNTestNetwork::OCV/OCL_FP16                 6.624   6.549     1.01   
Inception_v2_Faster_RCNN::DNNTestNetwork::OCV/CPU         86.676  82.918     1.05   
Inception_v2_Faster_RCNN::DNNTestNetwork::OCV/OCL         85.460  84.873     1.01   
Inception_v2_SSD_TensorFlow::DNNTestNetwork::OCV/CPU      16.007  15.723     1.02   
Inception_v2_SSD_TensorFlow::DNNTestNetwork::OCV/OCL      15.974  16.015     1.00   
Inception_v2_SSD_TensorFlow::DNNTestNetwork::OCV/OCL_FP16 16.219  15.593     1.04   
MPHand::DNNTestNetwork::OCV/CPU                            3.273   3.313     0.99   
MPHand::DNNTestNetwork::OCV/OCL                            3.466   3.318     1.04   
MPHand::DNNTestNetwork::OCV/OCL_FP16                       3.314   3.258     1.02   
MPPalm::DNNTestNetwork::OCV/CPU                            2.839   1.973     1.44   
MPPalm::DNNTestNetwork::OCV/OCL                            2.773   2.132     1.30   
MPPalm::DNNTestNetwork::OCV/OCL_FP16                       2.783   2.133     1.30   
MPPose::DNNTestNetwork::OCV/CPU                            7.644   8.711     0.88   
MPPose::DNNTestNetwork::OCV/OCL                            7.555   7.210     1.05   
MPPose::DNNTestNetwork::OCV/OCL_FP16                       7.564   7.559     1.00   
MobileNet_SSD_Caffe::DNNTestNetwork::OCV/CPU               9.040   8.813     1.03   
MobileNet_SSD_Caffe::DNNTestNetwork::OCV/OCL               8.692   9.481     0.92   
MobileNet_SSD_Caffe::DNNTestNetwork::OCV/OCL_FP16          8.792   8.884     0.99   
MobileNet_SSD_v1_TensorFlow::DNNTestNetwork::OCV/CPU       7.893   7.735     1.02   
MobileNet_SSD_v1_TensorFlow::DNNTestNetwork::OCV/OCL       8.233   7.816     1.05   
MobileNet_SSD_v1_TensorFlow::DNNTestNetwork::OCV/OCL_FP16  7.949   7.817     1.02   
MobileNet_SSD_v2_TensorFlow::DNNTestNetwork::OCV/CPU      14.373  15.282     0.94   
MobileNet_SSD_v2_TensorFlow::DNNTestNetwork::OCV/OCL      14.218  15.788     0.90   
MobileNet_SSD_v2_TensorFlow::DNNTestNetwork::OCV/OCL_FP16 14.473  14.853     0.97   
MobileNetv2_ONNX::DNNTestNetwork::OCV/CPU                  1.507   1.440     1.05   
MobileNetv2_ONNX::DNNTestNetwork::OCV/OCL                  1.529   1.394     1.10   
MobileNetv2_ONNX::DNNTestNetwork::OCV/OCL_FP16             1.448   1.433     1.01   
PPHumanSeg::DNNTestNetwork::OCV/CPU                        2.302   1.919     1.20   
PPHumanSeg::DNNTestNetwork::OCV/OCL                        2.097   1.865     1.12   
PPHumanSeg::DNNTestNetwork::OCV/OCL_FP16                   2.129   1.908     1.12   
PPOCRv3::DNNTestNetwork::OCV/CPU                          20.612  20.858     0.99   
PPOCRv3::DNNTestNetwork::OCV/OCL                          21.672  21.444     1.01   
PPOCRv3::DNNTestNetwork::OCV/OCL_FP16                     22.660  20.857     1.09   
ResNet50_QDQ_ONNX::DNNTestNetwork::OCV/CPU                 6.443   6.718     0.96   
ResNet50_QDQ_ONNX::DNNTestNetwork::OCV/OCL                 6.842   6.823     1.00   
ResNet50_QDQ_ONNX::DNNTestNetwork::OCV/OCL_FP16            6.895   6.579     1.05   
ResNet_50_v1_ONNX::DNNTestNetwork::OCV/CPU                 7.669   7.629     1.01   
ResNet_50_v1_ONNX::DNNTestNetwork::OCV/OCL                 7.514   7.473     1.01   
ResNet_50_v1_ONNX::DNNTestNetwork::OCV/OCL_FP16            7.598   7.513     1.01   
SFace::DNNTestNetwork::OCV/CPU                             3.427   3.334     1.03   
SFace::DNNTestNetwork::OCV/OCL                             3.420   3.337     1.02   
SFace::DNNTestNetwork::OCV/OCL_FP16                        3.497   3.375     1.04   
SSD::DNNTestNetwork::OCV/CPU                              83.165  83.476     1.00   
SSD::DNNTestNetwork::OCV/OCL                              83.531  84.121     0.99   
SSD::DNNTestNetwork::OCV/OCL_FP16                         82.447  83.234     0.99   
SqueezeNet_v1_1::DNNTestNetwork::OCV/CPU                   1.334   1.308     1.02   
SqueezeNet_v1_1::DNNTestNetwork::OCV/OCL                   1.279   1.313     0.97   
SqueezeNet_v1_1::DNNTestNetwork::OCV/OCL_FP16              1.429   1.290     1.11   
VIT_Base_Patch16_224::DNNTestNetwork::OCV/CPU             71.211  75.013     0.95   
VIT_Base_Patch16_224::DNNTestNetwork::OCV/OCL             71.988  71.218     1.01   
VIT_Base_Patch16_224::DNNTestNetwork::OCV/OCL_FP16        73.700  82.285     0.90   
VitTrack::DNNTestNetwork::OCV/CPU                          4.096   2.091     1.96   
VitTrack::DNNTestNetwork::OCV/OCL                          3.830   2.056     1.86   
VitTrack::DNNTestNetwork::OCV/OCL_FP16                     3.796   2.110     1.80   
YOLOX::DNNTestNetwork::OCV/CPU                            24.346  23.079     1.05   
YOLOX::DNNTestNetwork::OCV/OCL                            24.442  23.459     1.04   
YOLOX::DNNTestNetwork::OCV/OCL_FP16                       23.947  23.327     1.03   
YOLOv3::DNNTestNetwork::OCV/CPU                           59.140  59.140     1.00   
YOLOv3::DNNTestNetwork::OCV/OCL                           46.725  45.292     1.03   
YOLOv3::DNNTestNetwork::OCV/OCL_FP16                      46.939  45.382     1.03   
YOLOv4::DNNTestNetwork::OCV/CPU                           70.062  68.145     1.03   
YOLOv4::DNNTestNetwork::OCV/OCL                           219.570 214.823    1.02   
YOLOv4::DNNTestNetwork::OCV/OCL_FP16                      219.276 213.472    1.03   
YOLOv4_tiny::DNNTestNetwork::OCV/CPU                       8.362   8.221     1.02   
YOLOv4_tiny::DNNTestNetwork::OCV/OCL                       8.373   8.095     1.03   
YOLOv4_tiny::DNNTestNetwork::OCV/OCL_FP16                  8.830   8.088     1.09   
YOLOv5::DNNTestNetwork::OCV/CPU                            9.237   8.484     1.09   
YOLOv5::DNNTestNetwork::OCV/OCL                            8.776   8.537     1.03   
YOLOv5::DNNTestNetwork::OCV/OCL_FP16                       8.747   8.536     1.02   
YOLOv8::DNNTestNetwork::OCV/CPU                           11.019  11.463     0.96   
YOLOv8::DNNTestNetwork::OCV/OCL                           11.204  10.766     1.04   
YOLOv8::DNNTestNetwork::OCV/OCL_FP16                      11.355  10.764     1.05   
YuNet::DNNTestNetwork::OCV/CPU                             3.371   3.466     0.97   
YuNet::DNNTestNetwork::OCV/OCL                             3.396   3.105     1.09   
YuNet::DNNTestNetwork::OCV/OCL_FP16                        3.150   3.130     1.01   
```

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.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-05-06 11:54:40 +03:00
Alexander Smorkalov a05ee608f2 Merge pull request #28933 from intel-staging:ippicv_20260327
Update IPPICV binaries (20260327)
2026-05-06 11:48:35 +03:00
Anand Mahesh ad50964f78 Merge pull request #28879 from manand881:feat/akaze-ocl-performance
Feat: Add OpenCL support for AKAZE features #28879

Implement OpenCL-accelerated AKAZE feature
detection and descriptor extraction

Benchmarked on RTX 5060 Ti: 1.2x to 3.31x faster
for image sizes from 640x480 to 3840x2160

- Added 8 OpenCL kernels for feature detection and descriptor extraction
- Refactored compute_kcontrast to use OpenCV magnitude() for consistency
- Added comprehensive tests with >95% accuracy vs CPU baseline

### 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-05-06 11:14:47 +03:00
Alexander Smorkalov 847fca1056 Merge pull request #28939 from ssam18:fix/minmaxidx-fpointer-uab
Fix indirect call type mismatch in minMaxIdx dispatch table
2026-05-06 11:01:47 +03:00
Maksim Shabunin 6ad2780b18 videoio: workaround GStreamer tests on Ubuntu 26 2026-05-06 10:46:50 +03:00
Samaresh Kumar Singh dbf872ac1b Fix indirect call type mismatch in minMaxIdx dispatch table
The minMaxIdx dispatch table in modules/core/src/minmax.cpp stored
seven differently typed functions through C-style casts to a single
MinMaxIdxFunc pointer type, which is undefined behaviour and trips
UBSan's -fsanitize=function for any CV_32F or CV_64F input. This
change switches the typedef and every depth-specific helper to take
void pointers for src, minval and maxval, with the original typed
pointer recovered at function entry. The dispatch table no longer
needs C-style casts and the int pointer punning at the call site
goes away. Fixes #28928.
2026-05-05 22:39:59 -05:00
Pierre Chatelier 808d2d596c Merge pull request #28909 from chacha21:autobuffer_api
Better AutoBuffer API #28909

Mimic std::vector<> to help replacing std::vector<T> by cv::AutoBuffer<T> when possible

### 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
      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-05-05 16:31:13 +03:00
Teddy-Yangjiale f7a467f882 Merge pull request #28914 from Teddy-Yangjiale:fix-issue-28904
videoio(dshow): fix crash in videoInput::start() when pVih is NULL #28914

### Summary
This PR fixes a critical application crash in the DirectShow backend when encountering certain legacy or virtual cameras (e.g., Microsoft's DirectShow "Ball" Sample).

### The Problem
In `modules/videoio/src/cap_dshow.cpp`, the function `videoInput::start()` calls `pConfig->GetConnectedMediaType(&mt)`. 
- In some edge cases, this call returns `S_OK`, indicating success.
- However, the associated format block `mt.pbFormat` (which `pVih` points to) can still be `NULL`.
- The current implementation uses `CV_Assert(pVih)`, which triggers a hard crash of the entire application when this occurs.

### The Fix
I have replaced the `CV_Assert(pVih)` with a null-pointer check. If `pVih` is `NULL`, the function now returns `false`. This allows the high-level `cv::VideoCapture` to handle the failure (e.g., by returning `false` from `.open()`) instead of crashing the process.

### Engineering Rationale
- Execution Path Consistency: For devices providing valid format headers, `pVih` remains non-NULL. In these cases, the conditional check is skipped, and the execution path is identical to the original implementation.
- Process Stability: Replacing `CV_Assert` prevents immediate process termination (SIGABRT) when a DirectShow filter provides an invalid or empty format block. 
- Error Propagation: Returning `false` in `videoInput::start()` allows the initialization failure to propagate through the call stack. This ensures that `cv::VideoCapture::open()` returns `false`, enabling the caller to detect the issue via the standard API (e.g., `isOpened()`) instead of the process being terminated.

### Evidence
I have manually reproduced this crash using the Microsoft DirectShow Ball Sample filter on Windows. As shown in the attached debugger screenshot:
- `deviceID` is 2 (the virtual camera).
- `hr` is `S_OK`.
- `pVih` is `NULL`.

<img width="773" height="1413" alt="dshow_null_pvih_debug_evidence" src="https://github.com/user-attachments/assets/5bc454b4-4a0b-4703-825d-0d5fd23cba28" />

Fixes #28904

### 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
- [ ] 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-05-05 15:55:52 +03:00
Alexander Smorkalov bc55040428 Merge pull request #28923 from Kumataro:safeHandlingCompressedFileStorage
core: safe handling of compressed file level extension (.gz[0-9])
2026-05-05 15:12:52 +03:00
ekharkov 5073e1eb3a Updated ICV package to version 2026.0 2026-05-05 03:51:53 -07:00
Alexander Smorkalov 73c9d28264 Merge pull request #28916 from Kumataro:fix28911
core(test): Fix Universal Intrinsics emulator tests for GCC 15+
2026-05-05 11:10:32 +03:00
Alexander Smorkalov 90fc83d926 Merge pull request #28922 from vrabaud:facefont
Add FontFace to js bindings.
2026-05-05 09:06:33 +03:00