From 925ce46ef0eafdfb80a459de459fcccdebcbdea6 Mon Sep 17 00:00:00 2001 From: abhishek-gola Date: Wed, 18 Nov 2026 16:39:39 +0530 Subject: [PATCH] tests: pass the mask in AccumulateWeighted.Mask and check the #24966 CRF fix directly Signed-off-by: abhishek-gola --- modules/imgproc/test/ocl/test_accumulate.cpp | 4 +- modules/photo/test/test_hdr.cpp | 43 +++++++------------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/modules/imgproc/test/ocl/test_accumulate.cpp b/modules/imgproc/test/ocl/test_accumulate.cpp index 2351d97318..14f3e7c221 100644 --- a/modules/imgproc/test/ocl/test_accumulate.cpp +++ b/modules/imgproc/test/ocl/test_accumulate.cpp @@ -211,8 +211,8 @@ OCL_TEST_P(AccumulateWeighted, Mask) { random_roi(); - OCL_OFF(cv::accumulateWeighted(src_roi, dst_roi, alpha)); - OCL_ON(cv::accumulateWeighted(usrc_roi, udst_roi, alpha)); + OCL_OFF(cv::accumulateWeighted(src_roi, dst_roi, alpha, mask_roi)); + OCL_ON(cv::accumulateWeighted(usrc_roi, udst_roi, alpha, umask_roi)); OCL_EXPECT_MATS_NEAR(dst, 1e-2); } diff --git a/modules/photo/test/test_hdr.cpp b/modules/photo/test/test_hdr.cpp index c361d9de54..14325d4681 100644 --- a/modules/photo/test/test_hdr.cpp +++ b/modules/photo/test/test_hdr.cpp @@ -354,40 +354,25 @@ TEST(Photo_CalibrateDebevec, bug_24966) vector all_images; vector all_times; loadExposureSeq(test_path + "exposures/", all_images, all_times); - // Use a balanced subset of exposures - vector selected_indices = {1,2,3,4,5}; vector images; vector times; - for (int idx : selected_indices) { + for (int idx : {1, 2, 3, 4, 5}) { images.push_back(all_images[idx]); times.push_back(all_times[idx]); } - // Run CRF estimation for different sample points - vector sample_points = {200,300,400}; - vector responses; - for (int samples : sample_points) { - Ptr calibrate = createCalibrateDebevec(samples); - Mat response; - calibrate->process(images, response, times); - Mat roi = response.rowRange(15, 240); //Checking CRF only in the middle of the image - responses.push_back(roi); - } + Ptr calibrate = createCalibrateDebevec(); + Mat response, response_ext; + calibrate->process(images, response, times); - // Compare consecutive pairs of CRFs - for (size_t i = 0; i < responses.size()-1; ++i) { - Mat diff = abs(responses[i] - responses[i+1]); - double max_diff; - minMaxLoc(diff, nullptr, &max_diff); - cout << "max_diff = " << max_diff << endl; - #if defined(__aarch64__) && defined(__APPLE__) - ASSERT_LT(max_diff, 10) << "CRF instability detected between samples=" - << sample_points[i] << " and " << sample_points[i+1] - << " (max diff = " << max_diff << ")"; - #else - ASSERT_LT(max_diff, 5) << "CRF instability detected between samples=" - << sample_points[i] << " and " << sample_points[i+1] - << " (max diff = " << max_diff << ")"; - #endif - } + // #24966: pixels at 0 and 255 get (almost) zero weight, so a fully saturated and a fully black + // exposure only add zero-weight equations and must not change the response. + images.push_back(Mat(images[0].size(), images[0].type(), Scalar::all(255))); + times.push_back(times.front() * 2); + images.push_back(Mat(images[0].size(), images[0].type(), Scalar::all(0))); + times.push_back(times[4] / 2); + calibrate->process(images, response_ext, times); + + double max_diff = cvtest::norm(response.rowRange(15, 240), response_ext.rowRange(15, 240), NORM_INF); + EXPECT_LT(max_diff, 0.5); } }} // namespace