Optimize audio buffer duration calculation in MSMF capture. Fixes#27969#28017
### Description
Cache the repeated calculation of `(bit_per_sample/8)*nChannels` in a local variable to avoid redundant computations in `grabFrame()` and `configureAudioFrame()` functions.
### Changes
- Added `bytesPerSample` local variable in both functions
- Replaced 6 repeated calculations with the cached variable
- Improves performance in frequently called audio processing code
Fixes#27969
Added BitShift option to CLAHE #28014
Briefly, this PR is the fix of https://github.com/opencv/opencv/issues/28002
### 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
docs(py): add pip-based install tutorial #27943
- New tutorial: `doc/tutorials/py_tutorials/py_setup/py_pip_install/py_pip_install.markdown` with anchor `{#tutorial_py_pip_install}`.
- Python setup TOC updated to include the new page near the top.
- Windows/Ubuntu/Fedora pages: added **Quick start (pip)** callout
- Expanded troubleshooting in the pip tutorial (env mismatch, headless GUI notes, wheel mismatches, Raspberry Pi/ARM guidance).
This aligns with the issue request to make `pip install opencv-python` the default path for Python newcomers and reduce confusion from legacy content.
Fixes#24360
### 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
Building OpenCV with oneAPI #28003
### 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
### Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
resolves https://github.com/opencv/opencv/issues/27580
- [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
imgproc: supports CV_SIMD_SCALABLE in pointSetBoundingRect #27479
### 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
Fixed standard HoughLines output shift for rho. #27992
Closes: https://github.com/opencv/opencv/issues/25038
Replaces: https://github.com/opencv/opencv/pull/25043
Merge with https://github.com/opencv/opencv_extra/pull/1288
The original implementation introduces systematic shift (-rho/2) for odd indexes. Integer division just gives proper rounding.
### 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
Added CMake define option to enforce IPP calls in IPP HAL when building with IPP integration #27925
Extra build option needed to simplify custom builds with IPP integration to ensure the IPP calls done even in cases when the results are not bitwise compliant to the reference OpenCV implementation. Option name is ```WITH_IPP_CALLS_ENFORCED```, and it is disabled by default.
Requested by some IPP customers and might be used in general as a way providing calls with better performance for the cases the aligned precision is not as important aspect.
Supposed to be used in HAL only, so added only in IPP HAL CMake, currently it affects only Warp Affine, Warp Perspective and Remap integrations since the results may vary depending on HW and algorithm implementations.
### 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
Fixed unrichable code with MSVC on x86 32-bit systems. #27991
Suppress the following warnings:
```
Warning: C:\GHA-OCV-5\_work\opencv\opencv\opencv\modules\gapi\src\streaming\onevpl\file_data_provider.cpp(131): warning C4702: unreachable code [C:\GHA-OCV-5\_work\opencv\opencv\build\modules\gapi\opencv_gapi.vcxproj]
Warning: C:\GHA-OCV-5\_work\opencv\opencv\opencv\modules\gapi\src\streaming\onevpl\source.cpp(77): warning C4702: unreachable code [C:\GHA-OCV-5\_work\opencv\opencv\build\modules\gapi\opencv_gapi.vcxproj]
Warning: C:\GHA-OCV-5\_work\opencv\opencv\opencv\modules\gapi\src\streaming\onevpl\source.cpp(82): warning C4702: unreachable code [C:\GHA-OCV-5\_work\opencv\opencv\build\modules\gapi\opencv_gapi.vcxproj]
Warning: C:\GHA-OCV-5\_work\opencv\opencv\opencv\modules\gapi\src\streaming\onevpl\source.cpp(103): warning C4702: unreachable code [C:\GHA-OCV-5\_work\opencv\opencv\build\modules\gapi\opencv_gapi.vcxproj]
Warning: C:\GHA-OCV-5\_work\opencv\opencv\opencv\modules\gapi\src\streaming\onevpl\source.cpp(90): warning C4702: unreachable code [C:\GHA-OCV-5\_work\opencv\opencv\build\modules\gapi\opencv_gapi.vcxproj]
Warning: C:\GHA-OCV-5\_work\opencv\opencv\opencv\modules\gapi\src\streaming\onevpl\source.cpp(94): warning C4702: unreachable code [C:\GHA-OCV-5\_work\opencv\opencv\build\modules\gapi\opencv_gapi.vcxproj]
Warning: C:\GHA-OCV-5\_work\opencv\opencv\opencv\modules\gapi\src\streaming\onevpl\source.cpp(86): warning C4702: unreachable code [C:\GHA-OCV-5\_work\opencv\opencv\build\modules\gapi\opencv_gapi.vcxproj]
Warning: C:\GHA-OCV-5\_work\opencv\opencv\opencv\modules\gapi\src\streaming\onevpl\source.cpp(99): warning C4702: unreachable code [C:\GHA-OCV-5\_work\opencv\opencv\build\modules\gapi\opencv_gapi.vcxproj]
Warning: C:\GHA-OCV-5\_work\opencv\opencv\opencv\modules\gapi\src\streaming\gstreamer\gstreamersource.cpp(366): warning C4702: unreachable code [C:\GHA-OCV-5\_work\opencv\opencv\build\modules\gapi\opencv_gapi.vcxproj]
Warning: C:\GHA-OCV-5\_work\opencv\opencv\opencv\modules\gapi\src\streaming\gstreamer\gstreamersource.cpp(360): warning C4702: unreachable code [C:\GHA-OCV-5\_work\opencv\opencv\build\modules\gapi\opencv_gapi.vcxproj]
Warning: C:\GHA-OCV-5\_work\opencv\opencv\opencv\modules\gapi\src\streaming\gstreamer\gstreamerpipeline.cpp(77): warning C4702: unreachable code [C:\GHA-OCV-5\_work\opencv\opencv\build\modules\gapi\opencv_gapi.vcxproj]
```
### 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
Fix missing vec_cvfo on IBM POWER9 due to unavailable VSX float64 conversion #27990
Replaces https://github.com/opencv/opencv/pull/27633
Closes https://github.com/opencv/opencv/issues/27635
### 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
docs(js): Fix Mat.clone() documentation to use mat_clone() for deep copy #27985
- Update code example to use ```mat_clone()``` instead of ```clone()```
- Add explanatory note about shallow copy issue due to Emscripten embind
Problem
- OpenCV.js documentation shows ```Mat.clone()``` usage, but this method performs shallow copy instead of deep copy due to Emscripten embind limitations, causing unexpected behavior where modifications to cloned matrices affect the original.
Related Issues and PRs
- Fixes documentation aspect of issue #27572
- Related to PR #26643 (js_clone_fix)
### 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
Force empty output type where it's defined in API #27972
The PR replaces:
- https://github.com/opencv/opencv/pull/27936
- https://github.com/opencv/opencv/pull/21059
Empty matrix has undefined type, so user code should not relay on the output type, if it's empty. The PR introduces some exceptions:
- copyTo documentation defines, that the method re-create output buffer and set it's type.
- convertTo has output type as parameter and output type is defined and expected.
Fix alpha handling for blending in PNG format #27981
### Pull Request Readiness Checklist
closes#27974
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
Remove performance bottleneck caused by redundant type conversions in the
initGMMs() function's tight nested loops that iterate over all image pixels.
Changes:
- Changed storage vectors from Vec3f to Vec3b to store pixel data directly
without intermediate conversion
- Modified kmeans preparation to convert Vec3b data to CV_32FC1 only when
creating the Mat for clustering (using convertTo instead of per-pixel cast)
- Explicitly convert Vec3b to Vec3d only when calling addSample() method
Performance Impact:
Previously: Vec3b -> Vec3f (in loop) -> Vec3d (implicit in addSample)
Now: Vec3b (in loop) -> Vec3d (explicit, only in addSample call)
This eliminates one unnecessary type conversion per pixel in the tight loop,
reducing computational overhead especially for large images.
Fixes#27968
Add BUILD_INFO_SKIP_SYSTEM_VERSION option to exclude the host kernel version
from build outputs, enabling reproducible builds across systems with different
kernel versions.
Changes:
- Modified CMakeLists.txt to conditionally include CMAKE_HOST_SYSTEM_VERSION
in the build platform status based on BUILD_INFO_SKIP_SYSTEM_VERSION flag
- Updated 3rdparty/tbb/CMakeLists.txt to set TBB_HOST_VERSION conditionally
- Modified 3rdparty/tbb/version_string.ver.cmakein to use the new variable
When BUILD_INFO_SKIP_SYSTEM_VERSION=ON is set, the host system version is
excluded from both the CMake status output and the TBB version strings,
producing identical binaries on equivalent build systems regardless of
kernel version differences.
Default behavior is unchanged (version included) for backward compatibility.
Fixes#27961
[calib3d] Add estimateTranslation2D() #27950
Merge with opencv_extra PR: opencv/opencv_extra#1286
### **Description**
This PR adds a new API, `cv::estimateTranslation2D()`, to the **calib3d** module.
It computes a **pure 2D translation** between two sets of corresponding points using robust methods (`RANSAC` and `LMedS`).
The function mirrors the interface and behavior of `estimateAffine2D()` and `estimateAffinePartial2D()`, but constrains the transformation to translation only.
This model is particularly useful for cases where the motion between images is purely translational, such as:
- Aerial stitching and planar mosaics.
- Image alignment in fixed-camera systems.
- Lightweight pipelines where affine or homography models are unnecessarily complex.
The implementation introduces a new internal class `Translation2DEstimatorCallback` and integrates seamlessly into OpenCV’s existing robust estimation framework (`PointSetRegistrator`).
---
### **Key Features**
- Implements `cv::estimateTranslation2D()` in the `calib3d` module.
- Supports robust methods **RANSAC** and **LMedS**.
- Adds accuracy and performance tests.
- Provides full **C++ and Python bindings**.
- Includes **Doxygen documentation** consistent with OpenCV’s standards.
- Verified correctness across noise, outlier, and datatype variations.
---
### **Testing & Verification**
**Unit Tests** (`modules/calib3d/`)
- **Minimal sample:**
`test1Point` validates that a single correspondence recovers the correct translation under both **RANSAC** and **LMedS** across 500 randomized trials.
- **Robustness to noise and outliers:**
`testNPoints` generates 100 correspondences, injects noise and outliers (≤40% for RANSAC, ≤50% for LMedS), and verifies that:
- Estimated **T** closely matches ground truth (`cvtest::norm(..., NORM_L2)`).
- Inlier mask consistency and correctness are maintained.
- **Datatype conversion:**
`testConversion` checks mixed input datatypes (integer → float) to ensure correct conversion and consistent results.
- **Input immutability:**
`dont_change_inputs` confirms that input arrays remain unchanged after function execution, mirroring affine behavior.
**Performance Tests** (`modules/calib3d/`)
- `EstimateTranslation2DPerf` benchmarks **RANSAC** and **LMedS** using:
- Point counts: 1000
- Confidence levels: 0.95
- Refinement iterations: 10, 0
These tests confirm **numerical stability**, **performance scaling**, and **consistency** across datatypes and noise levels.
---
### Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch (`4.x`)
- [x] There is a clear description, motivation, and validation summary in this PR
- [x] There are accuracy and performance tests in the calib3d module
- [x] The feature is well documented and sample code can be built with CMake
- [x] The feature has Python bindings and verified documentation output
- [x] There is test data or sample code in the opencv_extra repository (if applicable)
- [ ] There is a reference to the original bug report or related issue (if applicable)
Fixed ptrdiff_t cast on windows 32-bit #27976
### 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
Fixed pre-built ffmpeg diagnostics on Windows for ARM. #27977
### 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
Add macOS support for Orbbec Gemini330 camera #27930
### Description of Changes
Adds macOS support for Orbbec Gemini330 in videoio by integrating OrbbecSDK v2. Completes the non-macOS work in [#27230](https://github.com/opencv/opencv/pull/27230).
#### Motivation
[#27230](https://github.com/opencv/opencv/pull/27230) skipped macOS. On macOS, UVC alone lacks required device controls; OrbbecSDK v2 provides them.
#### Key Change
- macOS: fetch/link OrbbecSDK v2.5.5 (replaces v1.9.4).
- videoio (macOS): switch OrbbecSDK API usage from v1 to v2.
### 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] The feature is well documented and sample code can be built with the project CMake
Try to fix distant points to save time when ThickLine() calls FillConvexPoly() #27366
Proposal for #27365
cv::clipLine() is useful, but one should take care of a margin to preserve line caps.
### 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
Clarified supported types in cv::patchNaNs() documentation #27959
### 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
Updated the docs for cv::patchNaNs() to specify that both CV_32F and CV_64F types are supported. Fixes incomplete information.
In `fisheye::initUndistortRectifyMap` states, that the function 'compensate radial and tangential lens distortion'. But in fact, fisheye camera model in OpenCV does not uses tangential distortion. It uses only radial distortions, with 4 distortion k_1, k_2, k_3, k_4, which all are radial. In the code of the function all of those koeficients indeed are used as radial lens distortion coefficients. Possible reason of that issue is similar documentation of pinhole camera, that as first four coefficients uses 2 radial and 2 tangential lens distortion coefficients - k_1, k_2, p_1, p_2.