Skip to content

5.x merge 4.x #27435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
47d0bed
Updating doc markdown to include newly added FastCV HAL and Extension…
adsha-quic May 28, 2025
9f7793c
Merge pull request #27375 from CodeLinaro:doc_update
asmorkalov May 28, 2025
d26aa99
Updating doc markdown to include API in FastCV gemm HAL
adsha-quic May 30, 2025
8a0ea78
Merge pull request #27149 from liane-lin:4.x
liane-lin May 30, 2025
b3cb517
Merge pull request #27385 from CodeLinaro:doc_update
asmorkalov May 30, 2025
e1f6e85
Update HoughLinesWithAccumulator binding
MaximSmolskiy Jun 1, 2025
a39f61b
Merge pull request #27390 from MaximSmolskiy:update_HoughLinesWithAcc…
asmorkalov Jun 2, 2025
e92cfb3
Merge pull request #27389 from MaximSmolskiy:add_HoughCirclesWithAccu…
MaximSmolskiy Jun 2, 2025
4033043
Fix empty ND-array construction
vrabaud May 26, 2025
cd0699a
Merge pull request #27384 from Kumataro:fix27382
Kumataro Jun 2, 2025
5205e26
Fixed bug in ifdef state machine in header parser for bindings.
asmorkalov Jun 2, 2025
17d9427
Merge pull request #27393 from asmorkalov:as/elseif_hdr_parser
asmorkalov Jun 3, 2025
0ccbd21
Relax remap relative test to handle the case when HAL implements not …
asmorkalov Jun 3, 2025
e258f25
Merge pull request #26299 from s-trinh:feat/getClosestEllipsePoints_2
s-trinh Jun 3, 2025
a2c381a
Merge pull request #27398 from asmorkalov:as/relax_remap_relative
asmorkalov Jun 4, 2025
9e18169
Merge pull request #27355 from asmorkalov:as/gapi_control_msmf
asmorkalov Jun 4, 2025
aef6ae4
Merge pull request #27396 from abhishek-gola:hdr_bug_fix
abhishek-gola Jun 5, 2025
987548d
Use older version of IPP for Android x86 32bit to resolve linkage iss…
asmorkalov Jun 5, 2025
beeda17
Merge pull request #27362 from vrabaud:tsan
asmorkalov Jun 6, 2025
a503070
Merge pull request #27406 from asmorkalov:as/revert_android_ipp
asmorkalov Jun 6, 2025
d97e926
Merge pull request #27403 from CodeLinaro:apreetam_6thPost
quic-apreetam Jun 6, 2025
b9cab7e
Fix remap16s to pass Imgproc_WarpPerspective.
amane-ame Jun 8, 2025
d6864cd
Merge pull request #27418 from dkurt:fix_valgrind_warnings
dkurt Jun 9, 2025
62b3649
Merge pull request #27153 from 03kiko:fix-videowriter-writing-colorle…
03kiko Jun 9, 2025
ebfee90
Merge pull request #27414 from amane-ame:remap_fix
asmorkalov Jun 9, 2025
7ca36d9
Merge pull request #27408 from KAVYANSHTYAGI:Umat-vector-contructor
KAVYANSHTYAGI Jun 9, 2025
b13704b
Fix coordinate generation in drawing sample
KAVYANSHTYAGI Jun 9, 2025
4b69cc5
Merge pull request #27422 from KAVYANSHTYAGI:codex/find-and-fix-major…
asmorkalov Jun 10, 2025
809090f
Merge pull request #27421 from dkurt:dkurt-patch-1
dkurt Jun 10, 2025
6b4f5b4
Merge pull request #27419 from FleeOvernight:fixUpdCameraId
FleeOvernight Jun 10, 2025
bbe2f50
Cmake protobuf_generate_cpp deprecated use protobuf_generate
phanirithvij Jun 10, 2025
85b4565
Merge pull request #27428 from phanirithvij:dnn-cmake-protobuf-generate
asmorkalov Jun 10, 2025
fcc76c1
Merge pull request #27430 from CodeLinaro:dsp_markdown
quic-apreetam Jun 11, 2025
dd87ffc
Merge branch 4.x
asmorkalov Jun 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 3rdparty/fastcv/fastcv.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function(download_fastcv root_dir)

# Commit SHA in the opencv_3rdparty repo
set(FASTCV_COMMIT "abe340d0fb7f19fa9315080e3c8616642e98a296")
set(FASTCV_COMMIT "2265e79b3b9a8512a9c615b8c4d0244e88f45a9d")

# Define actual FastCV versions
if(ANDROID)
Expand All @@ -16,8 +16,8 @@ function(download_fastcv root_dir)
endif()
elseif(UNIX AND NOT APPLE AND NOT IOS AND NOT XROS)
if(AARCH64)
set(FCV_PACKAGE_NAME "fastcv_linux_aarch64_2025_04_29.tgz")
set(FCV_PACKAGE_HASH "e2ce60e25c8e4113a7af2bd243118f4c")
set(FCV_PACKAGE_NAME "fastcv_linux_aarch64_2025_05_29.tgz")
set(FCV_PACKAGE_HASH "decd490524f786e103125b8b948151f3")
else()
message("FastCV: fastcv lib for 32-bit Linux is not supported for now!")
endif()
Expand Down
12 changes: 9 additions & 3 deletions 3rdparty/ippicv/ippicv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ function(download_ippicv root_var)
set(OPENCV_ICV_NAME "ippicv_2022.0.0_lnx_intel64_20240904_general.tgz")
set(OPENCV_ICV_HASH "63717ee0f918ad72fb5a737992a206d1")
else()
set(IPPICV_COMMIT "7f55c0c26be418d494615afca15218566775c725")
set(OPENCV_ICV_NAME "ippicv_2021.12.0_lnx_ia32_20240425_general.tgz")
set(OPENCV_ICV_HASH "85ffa2b9ed7802b93c23fa27b0097d36")
if(ANDROID)
set(IPPICV_COMMIT "c7c6d527dde5fee7cb914ee9e4e20f7436aab3a1")
set(OPENCV_ICV_NAME "ippicv_2021.10.1_lnx_ia32_20231206_general.tgz")
set(OPENCV_ICV_HASH "d9510f3ce08f6074aac472a5c19a3b53")
else()
set(IPPICV_COMMIT "7f55c0c26be418d494615afca15218566775c725")
set(OPENCV_ICV_NAME "ippicv_2021.12.0_lnx_ia32_20240425_general.tgz")
set(OPENCV_ICV_HASH "85ffa2b9ed7802b93c23fa27b0097d36")
endif()
endif()
elseif(WIN32 AND NOT ARM)
set(OPENCV_ICV_PLATFORM "windows")
Expand Down
7 changes: 7 additions & 0 deletions doc/opencv.bib
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ @article{ChambolleEtAl
publisher = {Walter de Gruyter},
url = {https://hal.science/hal-00437581v1}
}
@misc{Chatfield2017,
author = {Chatfield, Carl},
title = {A Simple Method for Distance to Ellipse},
year = {2017},
publisher = {GitHub},
howpublished = {\url{https://blog.chatfield.io/simple-method-for-distance-to-ellipse/}},
}
@article{Chaumette06,
author = {Chaumette, Fran{\c c}ois and Hutchinson, S.},
title = {{Visual servo control, Part I: Basic approaches}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ HAL and Extension list of APIs
| | |fcvFilterSobel7x7u8s16 |
| |boxFilter |fcvBoxFilter3x3u8_v3 |
| | |fcvBoxFilter5x5u8_v2 |
| | |fcvBoxFilterNxNf32 |
| |adaptiveThreshold |fcvAdaptiveThresholdGaussian3x3u8_v2 |
| | |fcvAdaptiveThresholdGaussian5x5u8_v2 |
| | |fcvAdaptiveThresholdMean3x3u8_v2 |
| | |fcvAdaptiveThresholdMean5x5u8_v2 |
| |pyrUp & pyrDown |fcvPyramidCreateu8_v4 |
| |pyrDown |fcvPyramidCreateu8_v4 |
| |cvtColor |fcvColorRGB888toYCrCbu8_v3 |
| | |fcvColorRGB888ToHSV888u8 |
| |gaussianBlur |fcvFilterGaussian5x5u8_v3 |
Expand All @@ -167,10 +168,15 @@ HAL and Extension list of APIs
| |addWeighted |fcvAddWeightedu8_v2 |
| |subtract |fcvImageDiffu8f32_v2 |
| |SVD & solve |fcvSVDf32_v2 |
| |gemm |fcvMatrixMultiplyf32_v2 |
| | |fcvMultiplyScalarf32 |
| | |fcvAddf32_v2 |


**FastCV based OpenCV Extensions APIs list :**

These OpenCV extension APIs are implemented under the **cv::fastcv** namespace.

|OpenCV Extension APIs |Underlying FastCV API for OpenCV acceleration |
|----------------------|----------------------------------------------|
|matmuls8s32 |fcvMatrixMultiplys8s32 |
Expand All @@ -195,8 +201,10 @@ HAL and Extension list of APIs
|remap |fcvRemapu8_v2 |
|remapRGBA |fcvRemapRGBA8888BLu8 |
| |fcvRemapRGBA8888NNu8 |
|resizeDownBy2 |fcvScaleDownBy2u8_v2 |
|resizeDownBy4 |fcvScaleDownBy4u8_v2 |
|resizeDown |fcvScaleDownBy2u8_v2 |
| |fcvScaleDownBy4u8_v2 |
| |fcvScaleDownMNInterleaveu8 |
| |fcvScaleDownMNu8 |
|meanShift |fcvMeanShiftu8 |
| |fcvMeanShifts32 |
| |fcvMeanShiftf32 |
Expand Down Expand Up @@ -246,3 +254,65 @@ HAL and Extension list of APIs
| |fcvTrackLKOpticalFlowu8 |
|warpPerspective2Plane |fcv2PlaneWarpPerspectiveu8 |
|warpPerspective |fcvWarpPerspectiveu8_v5 |
|arithmetic_op |fcvAddu8 |
| |fcvAdds16_v2 |
| |fcvAddf32 |
| |fcvSubtractu8 |
| |fcvSubtracts16 |
|integrateYUV |fcvIntegrateImageYCbCr420PseudoPlanaru8 |
|normalizeLocalBox |fcvNormalizeLocalBoxu8 |
| |fcvNormalizeLocalBoxf32 |
|merge |fcvChannelCombine2Planesu8 |
| |fcvChannelCombine3Planesu8 |
| |fcvChannelCombine4Planesu8 |
|split |fcvDeinterleaveu8 |
| |fcvChannelExtractu8 |
|warpAffine |fcvTransformAffineu8_v2 |
| |fcvTransformAffineClippedu8_v3 |
| |fcv3ChannelTransformAffineClippedBCu8 |


**FastCV QDSP based OpenCV Extension APIs list :**
These OpenCV extension APIs are implemented under the **cv::fastcv::dsp** namespace.
This namespace provides optimized implementations that leverage QDSP (**Qualcomm's Digital Signal Processor**) acceleration using FastCV's Q-suffixed APIs. These functions require DSP initialization (fcvQ6Init).

|OpenCV Extension APIs |Underlying FastCV API for OpenCV acceleration |
|----------------------|----------------------------------------------|
|filter2D |fcvFilterCorr3x3s8_v2Q |
| |fcvFilterCorrNxNu8Q |
| |fcvFilterCorrNxNu8s16Q |
| |fcvFilterCorrNxNu8f32Q |
|FFT |fcvFFTu8Q |
|IFFT |fcvIFFTf32Q |
|fcvdspinit |fcvQ6Init |
|fcvdspdeinit |fcvQ6DeInit |
|Canny |fcvFilterCannyu8Q |
|sumOfAbsoluteDiffs |fcvSumOfAbsoluteDiffs8x8u8_v2Q |
|thresholdOtsu |fcvFilterThresholdOtsuu8Q |

**How to Use FastCV QDSP based OpenCV Extension APIs**

This section outlines the essential steps required to use OpenCV Extension APIs that are accelerated using FastCV on QDSP(**Qualcomm's Digital Signal Processor**).

1. Initialize QDSP:
- Call **cv::fastcv::dsp::fcvdspinit()** to initialize the QDSP.

2. Allocate memory using **Qualcomm's memory allocator** for all buffers that are being fed to the OpenCV extension API.:
- Use **cv::fastcv::getQcAllocator()** to assign the allocator to the buffers.
- Example:
cv::Mat src;
src.allocator = cv::fastcv::getQcAllocator(); **// Set Qualcomm's memory allocator**
\
After setting Qualcomm's memory allocator, any buffer created using methods like src.create(...), cv::imread(...) etc., will have its memory allocated using Qualcomm's memory allocator.

3. Call the OpenCV extension API from 'cv::fastcv::dsp':
- Example: **cv::fastcv::dsp::thresholdOtsu(src, dst, binaryType);**
where 'src' and 'dst' are 'cv::Mat' objects with the Qualcomm's memory allocator,
     and 'binaryType' is a boolean indicating the thresholding mode.

4. Deinitialize QDSP:
- Call **cv::fastcv::dsp::fcvdspdeinit()** to deinitialize the QDSP.


**Reference Example**:
Refer to a working test case using the OpenCV Extension APIs in the opencv_contrib repository:[opencv_contrib/modules/fastcv/test/test_thresh_dsp.cpp](https://github.com/opencv/opencv_contrib/blob/4.x/modules/fastcv/test/test_thresh_dsp.cpp)
Binary file modified doc/tutorials/others/images/ldr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion hal/riscv-rvv/src/imgproc/warp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class RemapTable
for (int i = 0; i < 8; i++)
coeffs[t*8+i] = 0;
coeffs[t*8+3] = 1;
return;
continue;
}

float sum = 0;
Expand Down
6 changes: 5 additions & 1 deletion modules/3d/test/test_solvepnp_ransac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,11 @@ class CV_solvePnPRansac_Test : public cvtest::BaseTest
}
}

solvePnPRansac(points, projectedPoints, intrinsics, distCoeffs, rvec, tvec, false, pointsCount, 0.5f, 0.99, inliers, method);
bool isEstimateSuccess = solvePnPRansac(points, projectedPoints, intrinsics, distCoeffs, rvec, tvec, false, pointsCount, 0.5f, 0.99, inliers, method);
if (!isEstimateSuccess)
{
return false;
}

bool isTestSuccess = inliers.size() + numOutliers >= points.size();

Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ void finalizeHdr(Mat& m)
m.rows = m.cols = -1;
if(m.u)
m.datastart = m.data = m.u->data;
if( m.data )
if( m.data && d > 0 )
{
m.datalimit = m.datastart + m.size[0]*m.step[0];
if( m.size[0] > 0 )
Expand All @@ -736,7 +736,7 @@ void finalizeHdr(Mat& m)
m.dataend = m.datalimit;
}
else
m.dataend = m.datalimit = 0;
m.dataend = m.datalimit = m.data;
}

//======================================= Mat ======================================================
Expand Down
19 changes: 19 additions & 0 deletions modules/core/test/test_mat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,25 @@ TEST(Core_Mat, regression_9507)
EXPECT_EQ(25u, m2.total());
}

TEST(Core_Mat, empty)
{
// Should not crash.
uint8_t data[2] = {0, 1};
cv::Mat mat_nd(/*ndims=*/0, /*sizes=*/nullptr, CV_8UC1, /*data=*/data);
cv::Mat1b mat(0, 0, /*data=*/data, /*steps=*/1);
EXPECT_EQ(mat_nd.dims, 0);
EXPECT_EQ(mat.dims, 2);
#if CV_VERSION_MAJOR < 5
EXPECT_LE(mat_nd.total(), 0u);
EXPECT_TRUE(mat_nd.empty());
#else
EXPECT_LE(mat_nd.total(), 1u);
EXPECT_FALSE(mat_nd.empty());
#endif
EXPECT_EQ(mat.total(), 0u);
EXPECT_TRUE(mat.empty());
}

TEST(Core_InputArray, empty)
{
vector<vector<Point> > data;
Expand Down
18 changes: 16 additions & 2 deletions modules/dnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,22 @@ if(HAVE_PROTOBUF)

if(PROTOBUF_UPDATE_FILES)
file(GLOB proto_files "${CMAKE_CURRENT_LIST_DIR}/src/tensorflow/*.proto" "${CMAKE_CURRENT_LIST_DIR}/src/caffe/opencv-caffe.proto" "${CMAKE_CURRENT_LIST_DIR}/src/onnx/opencv-onnx.proto")
set(PROTOBUF_GENERATE_CPP_APPEND_PATH ON) # required for tensorflow
protobuf_generate_cpp(fw_srcs fw_hdrs ${proto_files})
if(CMAKE_VERSION VERSION_LESS "3.13.0")
set(PROTOBUF_GENERATE_CPP_APPEND_PATH ON) # required for tensorflow
protobuf_generate_cpp(fw_srcs fw_hdrs ${proto_files})
else()
protobuf_generate(
APPEND_PATH # required for tensorflow
LANGUAGE cpp
IMPORT_DIRS ${Protobuf_IMPORT_DIRS}
OUT_VAR fw_srcs
PROTOC_EXE ${Protobuf_PROTOC_EXECUTABLE}
PROTOS ${proto_files})
set(fw_hdrs "${fw_srcs}")
# separate the header files and source files
list(FILTER fw_srcs EXCLUDE REGEX ".+\.h$")
list(FILTER fw_hdrs INCLUDE REGEX ".+\.h$")
endif()
else()
file(GLOB fw_srcs "${CMAKE_CURRENT_LIST_DIR}/misc/tensorflow/*.cc" "${CMAKE_CURRENT_LIST_DIR}/misc/caffe/opencv-caffe.pb.cc" "${CMAKE_CURRENT_LIST_DIR}/misc/onnx/opencv-onnx.pb.cc")
file(GLOB fw_hdrs "${CMAKE_CURRENT_LIST_DIR}/misc/tensorflow/*.h" "${CMAKE_CURRENT_LIST_DIR}/misc/caffe/opencv-caffe.pb.h" "${CMAKE_CURRENT_LIST_DIR}/misc/onnx/opencv-onnx.pb.h")
Expand Down
59 changes: 39 additions & 20 deletions modules/imgcodecs/src/grfmt_jpegxl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,34 @@ bool JpegXLEncoder::write(const Mat& img, const std::vector<int>& params)
return false;
}

// get distance param for JxlBasicInfo.
float distance = -1.0; // Negative means not set
for( size_t i = 0; i < params.size(); i += 2 )
{
if( params[i] == IMWRITE_JPEGXL_QUALITY )
{
#if JPEGXL_MAJOR_VERSION > 0 || JPEGXL_MINOR_VERSION >= 10
int quality = params[i+1];
quality = MIN(MAX(quality, 0), 100);
distance = JxlEncoderDistanceFromQuality(static_cast<float>(quality));
#else
CV_LOG_ONCE_WARNING(NULL, "Quality parameter is supported with libjxl v0.10.0 or later");
#endif
}
if( params[i] == IMWRITE_JPEGXL_DISTANCE )
{
int distanceInt = params[i+1];
distanceInt = MIN(MAX(distanceInt, 0), 25);
distance = static_cast<float>(distanceInt);
}
}

JxlBasicInfo info;
JxlEncoderInitBasicInfo(&info);
info.xsize = img.cols;
info.ysize = img.rows;
info.uses_original_profile = JXL_FALSE;
// Lossless encoding requires uses_original_profile = true.
info.uses_original_profile = (distance == 0.0) ? JXL_TRUE : JXL_FALSE;

if( img.channels() == 4 )
{
Expand Down Expand Up @@ -576,30 +599,26 @@ bool JpegXLEncoder::write(const Mat& img, const std::vector<int>& params)
return false;

JxlEncoderFrameSettings* frame_settings = JxlEncoderFrameSettingsCreate(encoder.get(), nullptr);
// set frame settings from params if available
for( size_t i = 0; i < params.size(); i += 2 )

// set frame settings with distance params
if(distance == 0.0) // lossless
{
if( params[i] == IMWRITE_JPEGXL_QUALITY )
if( JXL_ENC_SUCCESS != JxlEncoderSetFrameLossless(frame_settings, JXL_TRUE) )
{
#if JPEGXL_MAJOR_VERSION > 0 || JPEGXL_MINOR_VERSION >= 10
int quality = params[i+1];
quality = MIN(MAX(quality, 0), 100);
const float distance = JxlEncoderDistanceFromQuality(static_cast<float>(quality));
JxlEncoderSetFrameDistance(frame_settings, distance);
if (distance == 0)
JxlEncoderSetFrameLossless(frame_settings, JXL_TRUE);
#else
CV_LOG_ONCE_WARNING(NULL, "Quality parameter is supported with libjxl v0.10.0 or later");
#endif
CV_LOG_WARNING(NULL, "Failed to call JxlEncoderSetFrameLossless()");
}
if( params[i] == IMWRITE_JPEGXL_DISTANCE )
}
else if(distance > 0.0) // lossy
{
if( JXL_ENC_SUCCESS != JxlEncoderSetFrameDistance(frame_settings, distance) )
{
int distance = params[i+1];
distance = MIN(MAX(distance, 0), 25);
JxlEncoderSetFrameDistance(frame_settings, distance);
if (distance == 0)
JxlEncoderSetFrameLossless(frame_settings, JXL_TRUE);
CV_LOG_WARNING(NULL, "Failed to call JxlEncoderSetFrameDistance()");
}
}

// set frame settings from params if available
for( size_t i = 0; i < params.size(); i += 2 )
{
if( params[i] == IMWRITE_JPEGXL_EFFORT )
{
int effort = params[i+1];
Expand Down
Loading