From 0cfdeb800fcc1ca1ec25f813ddfacb67df4ecaba Mon Sep 17 00:00:00 2001 From: abhishek-gola Date: Wed, 18 Nov 2026 15:49:05 +0530 Subject: [PATCH] tests: reduce iterations, input sizes and perf grids of slow tests Signed-off-by: abhishek-gola --- modules/calib/test/test_cameracalibration.cpp | 4 ++- modules/core/test/test_dxt.cpp | 3 +- modules/core/test/test_misc.cpp | 2 +- modules/core/test/test_rand.cpp | 19 ++++++++---- modules/dnn/test/test_onnx_importer.cpp | 2 +- modules/features/test/ocl/test_feature2d.cpp | 2 +- .../test/test_descriptors_regression.cpp | 4 +-- modules/features/test/test_disk.cpp | 6 ++-- .../test/test_lightglue_normalization.cpp | 6 ++-- modules/flann/test/test_kmeans_index.cpp | 6 ++-- modules/geometry/test/test_homography.cpp | 3 +- modules/highgui/test/test_gui.cpp | 11 +++++-- modules/imgcodecs/perf/perf_decode_encode.cpp | 10 +++++-- modules/imgcodecs/perf/perf_png.cpp | 23 ++++++++++---- modules/imgcodecs/test/test_grfmt.cpp | 3 +- modules/imgproc/test/test_lsd.cpp | 24 +++++++++------ modules/photo/test/ocl/test_denoising.cpp | 2 ++ modules/photo/test/test_denoising.cpp | 20 +++++++++---- modules/stitching/perf/perf_stich.cpp | 4 +-- .../test/test_exposure_compensate.cpp | 6 +++- modules/stitching/test/test_matchers.cpp | 2 +- .../video/test/ocl/test_optflow_farneback.cpp | 5 ++++ modules/video/test/test_ecc.cpp | 30 +++++++++++-------- modules/videoio/test/test_ffmpeg.cpp | 13 ++++---- modules/videoio/test/test_gstreamer.cpp | 3 +- modules/videoio/test/test_video_io.cpp | 2 +- 26 files changed, 142 insertions(+), 73 deletions(-) diff --git a/modules/calib/test/test_cameracalibration.cpp b/modules/calib/test/test_cameracalibration.cpp index 78dfb0e972..4e90eed5f5 100644 --- a/modules/calib/test/test_cameracalibration.cpp +++ b/modules/calib/test/test_cameracalibration.cpp @@ -2249,9 +2249,11 @@ TEST(Calib_CalibrateCamera, deterministic_across_threads) { cv::Mat K, D, stdIntr, stdExtr, perViewErr, newObj, stdObj; std::vector rvecs, tvecs; + // a few LM steps exercise the parallel per-part accumulation; convergence is not under test cv::calibrateCameraRO(objectPoints, imagePoints, cv::Size(1280, 720), iFixedPoint, K, D, rvecs, tvecs, newObj, - stdIntr, stdExtr, stdObj, perViewErr); + stdIntr, stdExtr, stdObj, perViewErr, + 0, cv::TermCriteria(cv::TermCriteria::COUNT, 5, 0)); std::vector parts = { K.reshape(1, 1), D.reshape(1, 1), stdIntr.reshape(1, 1), stdExtr.reshape(1, 1) }; diff --git a/modules/core/test/test_dxt.cpp b/modules/core/test/test_dxt.cpp index 38094128a4..8d82c04037 100644 --- a/modules/core/test/test_dxt.cpp +++ b/modules/core/test/test_dxt.cpp @@ -1510,7 +1510,8 @@ TEST(Core_DFT, parallel_large) { RNG& rng = cvtest::TS::ptr()->get_rng(); int nthreads0 = getNumThreads(); - static const int sizes[][2] = { {1024, 1024}, {700, 1500}, {1, 1 << 20}, {1 << 18, 1}, {513, 2000} }; + // the 2D sizes keep >= 2 stripes in every pass of dftParallelStripes (rows, column batches, DCT lines) + static const int sizes[][2] = { {512, 512}, {350, 750}, {1, 1 << 20}, {1 << 18, 1}, {513, 1000} }; for (size_t si = 0; si < sizeof(sizes)/sizeof(sizes[0]); si++) { int rows = sizes[si][0], cols = sizes[si][1]; diff --git a/modules/core/test/test_misc.cpp b/modules/core/test/test_misc.cpp index a092ba4acf..27c0a569d0 100644 --- a/modules/core/test/test_misc.cpp +++ b/modules/core/test/test_misc.cpp @@ -417,7 +417,7 @@ public: // FP state is not supported // no checks } - std::this_thread::sleep_for(std::chrono::milliseconds(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(20)); } cv::details::FPDenormalsModeState base_state; diff --git a/modules/core/test/test_rand.cpp b/modules/core/test/test_rand.cpp index 2ebe34b96c..6e44c50a09 100644 --- a/modules/core/test/test_rand.cpp +++ b/modules/core/test/test_rand.cpp @@ -91,7 +91,10 @@ void Core_RandTest::run( int ) { -1000000, 1000000 }, { -1000, 1000 }, { -1000, 1000 }}; const int MAX_SDIM = 10; - const int N = 2000000; + const int N = 1000000; + // slice boundaries are drawn on the historical 2M length and scaled down, so the sequence of + // case parameters (depth, channels, distribution, ranges) drawn from the same rng is unchanged + const int N_DRAW = 2000000; const int maxSlice = 1000; const int MAX_HIST_SIZE = 1000; int progress = 0; @@ -109,7 +112,7 @@ void Core_RandTest::run( int ) int c, cn = (cvtest::randInt(rng) % 4) + 1; int type = CV_MAKETYPE(depth, cn); int dist_type = cvtest::randInt(rng) % (RNG::NORMAL+1); - int i, k, SZ = N/cn; + int i, k, SZ = N/cn, SZ_DRAW = N_DRAW/cn; Scalar A, B; double eps = 1.e-4; @@ -168,11 +171,15 @@ void Core_RandTest::run( int ) { tested_rng = saved_rng; int sz = 0, dsz = 0, slice; - for( slice = 0; slice < maxSlice && sz < SZ; slice++, sz += dsz ) + for( slice = 0; slice < maxSlice && sz < SZ_DRAW; slice++, sz += dsz ) { - dsz = slice+1 < maxSlice ? (int)(cvtest::randInt(rng) % (SZ - sz) + 1) : SZ - sz; - Mat aslice = arr[k].colRange(sz, sz + dsz); - tested_rng.fill(aslice, dist_type, A, B); + dsz = slice+1 < maxSlice ? (int)(cvtest::randInt(rng) % (SZ_DRAW - sz) + 1) : SZ_DRAW - sz; + int s0 = (int)((int64)sz*SZ/SZ_DRAW), s1 = (int)((int64)(sz + dsz)*SZ/SZ_DRAW); + if( s1 > s0 ) + { + Mat aslice = arr[k].colRange(s0, s1); + tested_rng.fill(aslice, dist_type, A, B); + } } } diff --git a/modules/dnn/test/test_onnx_importer.cpp b/modules/dnn/test/test_onnx_importer.cpp index ac12636148..be2cd6acd3 100644 --- a/modules/dnn/test/test_onnx_importer.cpp +++ b/modules/dnn/test/test_onnx_importer.cpp @@ -4115,7 +4115,7 @@ TEST_P(Test_ONNX_layers, getUnconnectedOutLayers) if (engine_forced == cv::dnn::ENGINE_ORT) applyTestTag(CV_TEST_TAG_DNN_SKIP_PARSER); - Net net = readNetFromONNX(_tf("models/yolov8x.onnx", false)); + Net net = readNetFromONNX(_tf("models/yolov8n.onnx", false)); ASSERT_FALSE(net.empty()); net.setPreferableBackend(backend); net.setPreferableTarget(target); diff --git a/modules/features/test/ocl/test_feature2d.cpp b/modules/features/test/ocl/test_feature2d.cpp index ccfddd712b..41f7d4f878 100644 --- a/modules/features/test/ocl/test_feature2d.cpp +++ b/modules/features/test/ocl/test_feature2d.cpp @@ -159,7 +159,7 @@ OCL_TEST(SIFT, Batch) vector imgs; vector descriptors; vector > keypoints; - int n = 6; + int n = 2; Ptr sift = SIFT::create(); for (int i = 0; i < n; i++) diff --git a/modules/features/test/test_descriptors_regression.cpp b/modules/features/test/test_descriptors_regression.cpp index c821118a38..dd536b357f 100644 --- a/modules/features/test/test_descriptors_regression.cpp +++ b/modules/features/test/test_descriptors_regression.cpp @@ -43,7 +43,7 @@ TEST( Features2d_DescriptorExtractor, batch_ORB ) string path = string(cvtest::TS::ptr()->get_data_path() + "detectors_descriptors_evaluation/images_datasets/graf"); vector imgs, descriptors; vector > keypoints; - int i, n = 6; + int i, n = 2; Ptr orb = ORB::create(); for( i = 0; i < n; i++ ) @@ -71,7 +71,7 @@ TEST( Features2d_DescriptorExtractor, batch_SIFT ) string path = string(cvtest::TS::ptr()->get_data_path() + "detectors_descriptors_evaluation/images_datasets/graf"); vector imgs, descriptors; vector > keypoints; - int i, n = 6; + int i, n = 2; Ptr sift = SIFT::create(); for( i = 0; i < n; i++ ) diff --git a/modules/features/test/test_disk.cpp b/modules/features/test/test_disk.cpp index 2c26a67562..fad67f8366 100644 --- a/modules/features/test/test_disk.cpp +++ b/modules/features/test/test_disk.cpp @@ -132,7 +132,8 @@ TEST(Features2d_DISK, MaxKeypointsAndThreshold) const std::string modelPath = cvtest::findDataFile("dnn/disk.onnx", false); - Ptr detector = DISK::create(modelPath); + // The cap and threshold logic is resolution independent; 384x384 still gives >1000 keypoints. + Ptr detector = DISK::create(modelPath, -1, 0.0f, Size(384, 384)); ASSERT_TRUE(detector); Mat img = imread(cvtest::findDataFile("shared/lena.png")); @@ -171,7 +172,8 @@ TEST(Features2d_DISK, MaskSupport) const std::string modelPath = cvtest::findDataFile("dnn/disk.onnx", false); - Ptr detector = DISK::create(modelPath); + // 384x384 keeps a non-unit image-to-net scale (512/384) for the coordinate and mask mapping. + Ptr detector = DISK::create(modelPath, -1, 0.0f, Size(384, 384)); Mat img = imread(cvtest::findDataFile("shared/lena.png")); ASSERT_FALSE(img.empty()); diff --git a/modules/features/test/test_lightglue_normalization.cpp b/modules/features/test/test_lightglue_normalization.cpp index 79983b45a2..29a06a11cf 100644 --- a/modules/features/test/test_lightglue_normalization.cpp +++ b/modules/features/test/test_lightglue_normalization.cpp @@ -51,9 +51,9 @@ static void detectLightGluePair(int type, Mat images[2], std::vector k detector = ALIKED::create(cvtest::findDataFile("dnn/onnx/models/aliked-n16rot-top1k-640.onnx", false)); else { - Ptr disk = DISK::create(cvtest::findDataFile("dnn/disk.onnx", false)); - disk->setMaxKeypoints(1024); - detector = disk; + // The normalization paths under test do not depend on the detector resolution; 512x384 + // still yields 1024 keypoints per image, 5x cheaper than the default 1024x1024 input. + detector = DISK::create(cvtest::findDataFile("dnn/disk.onnx", false), 1024, 0.0f, Size(512, 384)); } images[0] = imread(cvtest::findDataFile("shared/box.png")); images[1] = imread(cvtest::findDataFile("shared/box_in_scene.png")); diff --git a/modules/flann/test/test_kmeans_index.cpp b/modules/flann/test/test_kmeans_index.cpp index dae404c56a..6eaf4b49e3 100644 --- a/modules/flann/test/test_kmeans_index.cpp +++ b/modules/flann/test/test_kmeans_index.cpp @@ -100,9 +100,9 @@ TEST(Flann_KMeansIndex, destroy_after_truncated_load) const std::vector saved = saveKMeansIndex(data, filename); ASSERT_GT(saved.size(), kmeans_trees_ofs + sizeof(int)); - // every cut after trees_ stops inside the indices, a node, a pivot or a leaf offset, - // and the destructor then frees whatever part of the tree was loaded - for (size_t len = kmeans_trees_ofs + sizeof(int); len < saved.size(); ++len) + // every field after trees_ is a whole number of 4-byte words, so cutting at each word + // boundary reaches every failing read; cuts inside a word fail the same fread() + for (size_t len = kmeans_trees_ofs + sizeof(int); len < saved.size(); len += sizeof(int)) { SCOPED_TRACE(cv::format("File length: %d", (int)len)); writeFile(filename, std::vector(saved.begin(), saved.begin() + len)); diff --git a/modules/geometry/test/test_homography.cpp b/modules/geometry/test/test_homography.cpp index 95a2e2fd93..46159b7f9a 100644 --- a/modules/geometry/test/test_homography.cpp +++ b/modules/geometry/test/test_homography.cpp @@ -221,7 +221,8 @@ static void print_information_8(int _method, int j, int N, int k, int l, double TEST(Calib3d_Homography, accuracy) { using namespace HomographyTestUtils; - for (int N = MIN_COUNT_OF_POINTS; N <= MAX_COUNT_OF_POINTS; ++N) + // every count up to 63 (minimal case and all small-count tails), then a sparse sample of larger sets + for (int N = MIN_COUNT_OF_POINTS; N <= MAX_COUNT_OF_POINTS; N += (N < 64 ? 1 : 13)) { RNG& rng = cv::theRNG(); diff --git a/modules/highgui/test/test_gui.cpp b/modules/highgui/test/test_gui.cpp index b8093e07ec..2b93c1947d 100644 --- a/modules/highgui/test/test_gui.cpp +++ b/modules/highgui/test/test_gui.cpp @@ -47,7 +47,7 @@ namespace opencv_test { namespace { inline void verify_size(const std::string &nm, const cv::Mat &img) { EXPECT_NO_THROW(imshow(nm, img)); - EXPECT_EQ(-1, waitKey(200)); + EXPECT_EQ(-1, waitKey(1)); // see https://github.com/opencv/opencv/issues/25550 // Wayland backend is not supported getWindowImageRect(). @@ -58,8 +58,15 @@ inline void verify_size(const std::string &nm, const cv::Mat &img) return; } + // Poll instead of a fixed delay: up to ~2 s, which also covers window managers that apply the resize late. Rect rc; - EXPECT_NO_THROW(rc = getWindowImageRect(nm)); + for (int attempt = 0; attempt < 200; ++attempt) + { + EXPECT_NO_THROW(rc = getWindowImageRect(nm)); + if (rc.size() == img.size()) + break; + EXPECT_EQ(-1, waitKey(10)); + } EXPECT_EQ(rc.size(), img.size()); } diff --git a/modules/imgcodecs/perf/perf_decode_encode.cpp b/modules/imgcodecs/perf/perf_decode_encode.cpp index bdef7882ee..401f0a3a47 100644 --- a/modules/imgcodecs/perf/perf_decode_encode.cpp +++ b/modules/imgcodecs/perf/perf_decode_encode.cpp @@ -235,7 +235,10 @@ PERF_TEST_P(Encode, animation, testing::ValuesIn(exts_anim)) SANITY_CHECK_NOTHING(); } -PERF_TEST_P(Encode, multi_page, testing::ValuesIn(exts_multi)) +#ifdef HAVE_TIFF +// Only TIFF has its own writemulti(); for the other formats multi-page I/O goes through +// writeanimation() and the same reader, which Encode.animation / Decode.animation measure. +PERF_TEST_P(Encode, multi_page, testing::Values(".tiff")) { Animation animation = makeCirclesAnimation(); @@ -247,6 +250,7 @@ PERF_TEST_P(Encode, multi_page, testing::ValuesIn(exts_multi)) SANITY_CHECK_NOTHING(); } +#endif // HAVE_TIFF PERF_TEST_P(Decode, animation, testing::ValuesIn(exts_anim)) { @@ -263,7 +267,8 @@ PERF_TEST_P(Decode, animation, testing::ValuesIn(exts_anim)) SANITY_CHECK_NOTHING(); } -PERF_TEST_P(Decode, multi_page, testing::ValuesIn(exts_multi)) +#ifdef HAVE_TIFF +PERF_TEST_P(Decode, multi_page, testing::Values(".tiff")) { Animation animation = makeCirclesAnimation(); vector buf; @@ -277,5 +282,6 @@ PERF_TEST_P(Decode, multi_page, testing::ValuesIn(exts_multi)) SANITY_CHECK_NOTHING(); } +#endif // HAVE_TIFF } // namespace diff --git a/modules/imgcodecs/perf/perf_png.cpp b/modules/imgcodecs/perf/perf_png.cpp index d0ac677810..4487d3fd29 100644 --- a/modules/imgcodecs/perf/perf_png.cpp +++ b/modules/imgcodecs/perf/perf_png.cpp @@ -153,11 +153,24 @@ PERF_TEST(PNG, encode) SANITY_CHECK_NOTHING(); } -PERF_TEST_P(PNG, params, - testing::Combine( - testing::Values(IMWRITE_PNG_STRATEGY_DEFAULT, IMWRITE_PNG_STRATEGY_FILTERED, IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, IMWRITE_PNG_STRATEGY_RLE, IMWRITE_PNG_STRATEGY_FIXED), - testing::Values(IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, IMWRITE_PNG_FILTER_UP, IMWRITE_PNG_FILTER_AVG, IMWRITE_PNG_FILTER_PAETH, IMWRITE_PNG_FAST_FILTERS, IMWRITE_PNG_ALL_FILTERS), - testing::Values(1, 6))) +// zlib ignores the level for HUFFMAN_ONLY/RLE and ignores FILTERED below level 4, +// so those combinations would encode byte-identical output to another instance. +static std::vector > pngParamsGrid() +{ + std::vector > grid; + for (int strategy : { IMWRITE_PNG_STRATEGY_DEFAULT, IMWRITE_PNG_STRATEGY_FILTERED, IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, IMWRITE_PNG_STRATEGY_RLE, IMWRITE_PNG_STRATEGY_FIXED }) + for (int filter : { IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, IMWRITE_PNG_FILTER_UP, IMWRITE_PNG_FILTER_AVG, IMWRITE_PNG_FILTER_PAETH, IMWRITE_PNG_FAST_FILTERS, IMWRITE_PNG_ALL_FILTERS }) + for (int level : { 1, 6 }) + { + const bool levelIgnored = strategy == IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY || strategy == IMWRITE_PNG_STRATEGY_RLE; + if ((levelIgnored && level != 1) || (strategy == IMWRITE_PNG_STRATEGY_FILTERED && level < 4)) + continue; + grid.push_back(testing::make_tuple(PNGStrategy(strategy), PNGFilters(filter), level)); + } + return grid; +} + +PERF_TEST_P(PNG, params, testing::ValuesIn(pngParamsGrid())) { String filename = getDataPath("perf/1920x1080.png"); const int strategy = get<0>(GetParam()); diff --git a/modules/imgcodecs/test/test_grfmt.cpp b/modules/imgcodecs/test/test_grfmt.cpp index 9ee490bc81..9b074e72f5 100644 --- a/modules/imgcodecs/test/test_grfmt.cpp +++ b/modules/imgcodecs/test/test_grfmt.cpp @@ -267,7 +267,8 @@ const string all_exts[] = vector all_sizes() { vector res; - for (int k = 1; k <= 5; ++k) + // Up to 1920x1440: every codec's size-dependent branch (e.g. TIFF 1-row strips) is reached by k <= 3. + for (int k = 1; k <= 3; ++k) res.push_back(Size(640 * k, 480 * k)); return res; } diff --git a/modules/imgproc/test/test_lsd.cpp b/modules/imgproc/test/test_lsd.cpp index 951019997e..25445c549b 100644 --- a/modules/imgproc/test/test_lsd.cpp +++ b/modules/imgproc/test/test_lsd.cpp @@ -128,15 +128,17 @@ TEST_F(Imgproc_LSD_ADV, whiteNoise) TEST_F(Imgproc_LSD_ADV, constColor) { - for (int i = 0; i < EPOCHS; ++i) + // the gradient of a constant image is zero whatever the value, so a few values cover the code path + const int values[] = {0, 128, 255}; + for (int value : values) { - GenerateConstColor(test_image); + test_image = Mat(img_size, CV_8UC1, Scalar::all(value)); Ptr detector = createLineSegmentDetector(LSD_REFINE_ADV); detector->detect(test_image, lines); if(0u == lines.size()) ++passedtests; } - ASSERT_EQ(EPOCHS, passedtests); + ASSERT_EQ((int)(sizeof(values) / sizeof(values[0])), passedtests); } TEST_F(Imgproc_LSD_ADV, lines) @@ -181,15 +183,17 @@ TEST_F(Imgproc_LSD_STD, whiteNoise) TEST_F(Imgproc_LSD_STD, constColor) { - for (int i = 0; i < EPOCHS; ++i) + // the gradient of a constant image is zero whatever the value, so a few values cover the code path + const int values[] = {0, 128, 255}; + for (int value : values) { - GenerateConstColor(test_image); + test_image = Mat(img_size, CV_8UC1, Scalar::all(value)); Ptr detector = createLineSegmentDetector(LSD_REFINE_STD); detector->detect(test_image, lines); if(0u == lines.size()) ++passedtests; } - ASSERT_EQ(EPOCHS, passedtests); + ASSERT_EQ((int)(sizeof(values) / sizeof(values[0])), passedtests); } TEST_F(Imgproc_LSD_STD, lines) @@ -234,15 +238,17 @@ TEST_F(Imgproc_LSD_NONE, whiteNoise) TEST_F(Imgproc_LSD_NONE, constColor) { - for (int i = 0; i < EPOCHS; ++i) + // the gradient of a constant image is zero whatever the value, so a few values cover the code path + const int values[] = {0, 128, 255}; + for (int value : values) { - GenerateConstColor(test_image); + test_image = Mat(img_size, CV_8UC1, Scalar::all(value)); Ptr detector = createLineSegmentDetector(LSD_REFINE_NONE); detector->detect(test_image, lines); if(0u == lines.size()) ++passedtests; } - ASSERT_EQ(EPOCHS, passedtests); + ASSERT_EQ((int)(sizeof(values) / sizeof(values[0])), passedtests); } TEST_F(Imgproc_LSD_NONE, lines) diff --git a/modules/photo/test/ocl/test_denoising.cpp b/modules/photo/test/ocl/test_denoising.cpp index 974a8f81a8..8257e3e5f6 100644 --- a/modules/photo/test/ocl/test_denoising.cpp +++ b/modules/photo/test/ocl/test_denoising.cpp @@ -46,6 +46,8 @@ PARAM_TEST_CASE(FastNlMeansDenoisingTestBase, Channels, int, bool, bool) image = readImage("denoising/lena_noised_gaussian_sigma=10.png", cn == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR); ASSERT_FALSE(image.empty()); + // 8x5 OpenCL blocks of 32x32 (incl. partial ones) and several CPU row stripes + image = image(Rect(130, 180, 250, 150)).clone(); } Size roiSize = use_image ? image.size() : randomSize(1, MAX_VALUE); diff --git a/modules/photo/test/test_denoising.cpp b/modules/photo/test/test_denoising.cpp index 2c3159cf2d..bf041fd633 100644 --- a/modules/photo/test/test_denoising.cpp +++ b/modules/photo/test/test_denoising.cpp @@ -52,6 +52,11 @@ namespace opencv_test { namespace { # define DUMP(image, path) #endif +// NL-means output depends only on input within searchWindowSize/2 + templateWindowSize/2 = 13 px, so a crop +// anchored at the origin reproduces the full-image reference except in a 13 px band along the cut edges +static const Rect kDenoiseCrop(0, 0, 256, 256); +static const Rect kDenoiseCheck(0, 0, 256 - 13, 256 - 13); + TEST(Photo_DenoisingGrayscale, regression) { @@ -66,11 +71,11 @@ TEST(Photo_DenoisingGrayscale, regression) ASSERT_FALSE(expected.empty()) << "Could not load reference image " << expected_path; Mat result; - fastNlMeansDenoising(original, result, 10); + fastNlMeansDenoising(original(kDenoiseCrop).clone(), result, 10); DUMP(result, expected_path + ".res.png"); - ASSERT_EQ(0, cvtest::norm(result, expected, NORM_L2)); + ASSERT_EQ(0, cvtest::norm(result(kDenoiseCheck), expected(kDenoiseCheck), NORM_L2)); } TEST(Photo_DenoisingColored, regression) @@ -86,11 +91,11 @@ TEST(Photo_DenoisingColored, regression) ASSERT_FALSE(expected.empty()) << "Could not load reference image " << expected_path; Mat result; - fastNlMeansDenoisingColored(original, result, 10, 10); + fastNlMeansDenoisingColored(original(kDenoiseCrop).clone(), result, 10, 10); DUMP(result, expected_path + ".res.png"); - ASSERT_EQ(0, cvtest::norm(result, expected, NORM_L2)); + ASSERT_EQ(0, cvtest::norm(result(kDenoiseCheck), expected(kDenoiseCheck), NORM_L2)); } TEST(Photo_DenoisingGrayscaleMulti, regression) @@ -108,6 +113,7 @@ TEST(Photo_DenoisingGrayscaleMulti, regression) string original_path = format("%slena_noised_gaussian_sigma=20_multi_%d.png", folder.c_str(), i); original[i] = imread(original_path, IMREAD_GRAYSCALE); ASSERT_FALSE(original[i].empty()) << "Could not load input image " << original_path; + original[i] = original[i](kDenoiseCrop).clone(); } Mat result; @@ -115,7 +121,7 @@ TEST(Photo_DenoisingGrayscaleMulti, regression) DUMP(result, expected_path + ".res.png"); - ASSERT_EQ(0, cvtest::norm(result, expected, NORM_L2)); + ASSERT_EQ(0, cvtest::norm(result(kDenoiseCheck), expected(kDenoiseCheck), NORM_L2)); } TEST(Photo_DenoisingColoredMulti, regression) @@ -133,6 +139,7 @@ TEST(Photo_DenoisingColoredMulti, regression) string original_path = format("%slena_noised_gaussian_sigma=20_multi_%d.png", folder.c_str(), i); original[i] = imread(original_path, IMREAD_COLOR); ASSERT_FALSE(original[i].empty()) << "Could not load input image " << original_path; + original[i] = original[i](kDenoiseCrop).clone(); } Mat result; @@ -140,7 +147,7 @@ TEST(Photo_DenoisingColoredMulti, regression) DUMP(result, expected_path + ".res.png"); - ASSERT_EQ(0, cvtest::norm(result, expected, NORM_L2)); + ASSERT_EQ(0, cvtest::norm(result(kDenoiseCheck), expected(kDenoiseCheck), NORM_L2)); } TEST(Photo_White, issue_2646) @@ -167,6 +174,7 @@ TEST(Photo_DenoisingGrayscaleMulti16bitL1, regression) string original_path = format("%slena_noised_gaussian_sigma=20_multi_%d.png", folder.c_str(), i); original_8u[i] = imread(original_path, IMREAD_GRAYSCALE); ASSERT_FALSE(original_8u[i].empty()) << "Could not load input image " << original_path; + original_8u[i] = original_8u[i](kDenoiseCrop).clone(); original_8u[i].convertTo(original_16u[i], CV_16U); } diff --git a/modules/stitching/perf/perf_stich.cpp b/modules/stitching/perf/perf_stich.cpp index 4d76236a45..609a3a57ec 100644 --- a/modules/stitching/perf/perf_stich.cpp +++ b/modules/stitching/perf/perf_stich.cpp @@ -22,8 +22,8 @@ typedef TestBaseWithParam> stitchExposureCompMultiFeed; #else #define TEST_DETECTORS testing::Values("orb") #endif -#define TEST_EXP_COMP_BS testing::Values(32, 16, 12, 10, 8) -#define TEST_EXP_COMP_NR_FEED testing::Values(1, 2, 3, 4, 5) +#define TEST_EXP_COMP_BS testing::Values(16, 12, 10, 8) // 32 is the Stitcher default, measured by stitch.a123 +#define TEST_EXP_COMP_NR_FEED testing::Values(1, 2, 5) #define TEST_EXP_COMP_MODE testing::Values("gain", "channels", "blocks_gain", "blocks_channels") #define AFFINE_DATASETS testing::Values("s", "budapest", "newspaper", "prague") diff --git a/modules/stitching/test/test_exposure_compensate.cpp b/modules/stitching/test/test_exposure_compensate.cpp index 3f34742095..08bef9c5df 100644 --- a/modules/stitching/test/test_exposure_compensate.cpp +++ b/modules/stitching/test/test_exposure_compensate.cpp @@ -21,7 +21,11 @@ double minPSNR(UMat src1, UMat src2) TEST(ExposureCompensate, SimilarityThreshold) { UMat source; - imread(cvtest::TS::ptr()->get_data_path() + "stitching/s1.jpg").copyTo(source); + Mat full = imread(cvtest::TS::ptr()->get_data_path() + "stitching/s1.jpg"); + ASSERT_FALSE(full.empty()); + // 13x13 blocks of 32 px: contains the artifact below and keeps the gain system (338 unknowns) on the + // same solver path, without a dense 1716x1716 solve per channel for the full image + full(Rect(0, 0, 416, 416)).copyTo(source); UMat image1 = source.clone(); UMat image2 = source.clone(); diff --git a/modules/stitching/test/test_matchers.cpp b/modules/stitching/test/test_matchers.cpp index c3ea831f74..3068276b57 100644 --- a/modules/stitching/test/test_matchers.cpp +++ b/modules/stitching/test/test_matchers.cpp @@ -93,7 +93,7 @@ TEST(ParallelFeaturesFinder, IsSameWithSerial) detail::ImageFeatures serial_features; detail::computeImageFeatures(serial_finder, img, serial_features); - vector imgs(50, img); + vector imgs(8, img); // the vector path is a serial loop; 8 copies still overlap if it is ever parallelized vector para_features(imgs.size()); detail::computeImageFeatures(para_finder, imgs, para_features); // FIXIT This call doesn't use parallel_for_() diff --git a/modules/video/test/ocl/test_optflow_farneback.cpp b/modules/video/test/ocl/test_optflow_farneback.cpp index d8bf0c59dc..88dd0a3cab 100644 --- a/modules/video/test/ocl/test_optflow_farneback.cpp +++ b/modules/video/test/ocl/test_optflow_farneback.cpp @@ -89,6 +89,11 @@ OCL_TEST_P(FarnebackOpticalFlow, Mat) cv::Mat frame1 = readImage("optflow/RubberWhale2.png", cv::IMREAD_GRAYSCALE); ASSERT_FALSE(frame1.empty()); + // half-size centre crop: pyrScale 0.3 and 0.5 still stop at the 32 px minimum level size, 0.8 still uses 5 levels + const Rect crop(146, 97, 292, 194); + frame0 = frame0(crop).clone(); + frame1 = frame1(crop).clone(); + double polySigma = polyN <= 5 ? 1.1 : 1.5; cv::Mat flow; cv::UMat uflow; diff --git a/modules/video/test/test_ecc.cpp b/modules/video/test/test_ecc.cpp index 30e7d1e3cf..38ca2ede9b 100644 --- a/modules/video/test/test_ecc.cpp +++ b/modules/video/test/test_ecc.cpp @@ -68,7 +68,7 @@ class CV_ECC_Test : public cvtest::BaseTest { double computeRMS(const Mat& mat1, const Mat& mat2); bool isMapCorrect(const Mat& mat); - virtual bool test(const Mat img); + virtual bool test(const Mat img, int count); bool testAllTypes(const Mat img); // run test for all supported data types (U8, U16, F32, F64) bool testAllChNum(const Mat img); // run test for all supported channels count (gray, RGB) @@ -133,15 +133,15 @@ bool CV_ECC_Test::checkMap(const Mat& map, const Mat& ground) { return true; } -bool CV_ECC_Test::test(const Mat img) +bool CV_ECC_Test::test(const Mat img, int count) { cv::RNG rng = ts->get_rng(); int progress = 0; - for (int k = 0; k < ntests; k++) { + for (int k = 0; k < count; k++) { ts->update_context(this, k, true); - progress = update_progress(progress, k, ntests, 0); + progress = update_progress(progress, k, count, 0); Mat groundMap; switch(motionType) @@ -196,7 +196,8 @@ bool CV_ECC_Test::test(const Mat img) if(usePyramids) { ECCParameters params; - params.criteria = criteria; + // converges in < 5 iterations per level here; a fixed count (negative eps) still runs every level + params.criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 10, ECC_epsilon); params.motionType = motionType; findTransformECCMultiScale(warpedImage, img, foundMap, params); } @@ -210,11 +211,14 @@ bool CV_ECC_Test::test(const Mat img) } bool CV_ECC_Test::testAllTypes(const Mat img) { - auto types = {CV_8U, CV_16U, CV_32F, CV_64F}; - for (auto type : types) { + // ECC converts every input depth to CV_32F or CV_8U before iterating and each depth sees the same warps, + // so 16U and 64F get one warp to check that they are accepted and converted + const int types[] = {CV_8U, CV_16U, CV_32F, CV_64F}; + const int counts[] = {ntests, 1, ntests, 1}; + for (int i = 0; i < 4; i++) { Mat timg; - img.convertTo(timg, type); - if (!test(timg)) + img.convertTo(timg, types[i]); + if (!test(timg, counts[i])) return false; } return true; @@ -269,19 +273,19 @@ class CV_ECC_Test_Mask : public CV_ECC_Test { CV_ECC_Test_Mask(); protected: - bool test(const Mat); + bool test(const Mat, int count); }; CV_ECC_Test_Mask::CV_ECC_Test_Mask():CV_ECC_Test(MOTION_TRANSLATION, false) {} -bool CV_ECC_Test_Mask::test(const Mat testImg) { +bool CV_ECC_Test_Mask::test(const Mat testImg, int count) { cv::RNG rng = ts->get_rng(); int progress = 0; - for (int k = 0; k < ntests; k++) { + for (int k = 0; k < count; k++) { ts->update_context(this, k, true); - progress = update_progress(progress, k, ntests, 0); + progress = update_progress(progress, k, count, 0); Mat translationGround = Mat_({2, 3}, {1, 0, (rng.uniform(10.f, 20.f)), 0, 1, (rng.uniform(10.f, 20.f))}); diff --git a/modules/videoio/test/test_ffmpeg.cpp b/modules/videoio/test/test_ffmpeg.cpp index c1fb314536..4aa8db338a 100644 --- a/modules/videoio/test/test_ffmpeg.cpp +++ b/modules/videoio/test/test_ffmpeg.cpp @@ -64,18 +64,17 @@ static const Size bigSize(4096, 4096); const FourCC_Ext_Size entries[] = { make_tuple("", "avi", bigSize), - make_tuple("DX50", "avi", bigSize), + make_tuple("DX50", "avi", Size(1920, 1080)), // same mpeg4 encoder as XVID, which keeps the big frame make_tuple("FLV1", "avi", bigSize), make_tuple("H261", "avi", Size(352, 288)), make_tuple("H263", "avi", Size(704, 576)), - make_tuple("I420", "avi", bigSize), + make_tuple("I420", "avi", Size(1920, 1080)), // same rawvideo path as "" (NONE), which keeps the big frame make_tuple("MJPG", "avi", bigSize), - make_tuple("mp4v", "avi", bigSize), + make_tuple("mp4v", "avi", Size(1920, 1080)), make_tuple("MPEG", "avi", Size(720, 576)), make_tuple("XVID", "avi", bigSize), - make_tuple("H264", "mp4", Size(4096, 2160)), - make_tuple("FFV1", "avi", bigSize), - make_tuple("FFV1", "mkv", bigSize) + make_tuple("H264", "mp4", Size(4096, 2160)) + // FFV1 (avi, mkv) is checked with read-back in videoio_synthetic.write_read_position }; inline static std::string videoio_ffmpeg_name_printer(const testing::TestParamInfo& info) @@ -582,7 +581,7 @@ TEST(videoio_ffmpeg, parallel) const int GRAN = 4; const Range R(0, NUM); const Size sz(1020, 900); - const int frameNum = 300; + const int frameNum = 60; // 5 GOPs per stream; shared FFmpeg state is only touched in open/release const Scalar color(Scalar::all(0)); const Point center(sz.height / 2, sz.width / 2); diff --git a/modules/videoio/test/test_gstreamer.cpp b/modules/videoio/test/test_gstreamer.cpp index e2d1f77128..f9cd20a8fe 100644 --- a/modules/videoio/test/test_gstreamer.cpp +++ b/modules/videoio/test/test_gstreamer.cpp @@ -21,7 +21,8 @@ TEST_P(videoio_gstreamer, read_check) int count_frames = 10; std::ostringstream pipeline; pipeline << "videotestsrc pattern=ball num-buffers=" << count_frames << " ! " << format; - pipeline << ", width=" << frame_size.width << ", height=" << frame_size.height << " ! appsink"; + // sync=false: deliver the 10 buffers without waiting for the 30 fps pipeline clock + pipeline << ", width=" << frame_size.width << ", height=" << frame_size.height << " ! appsink sync=false"; VideoCapture cap; ASSERT_NO_THROW(cap.open(pipeline.str(), CAP_GSTREAMER)); ASSERT_TRUE(cap.isOpened()); diff --git a/modules/videoio/test/test_video_io.cpp b/modules/videoio/test/test_video_io.cpp index 1786d976ca..cbeb3bd79a 100644 --- a/modules/videoio/test/test_video_io.cpp +++ b/modules/videoio/test/test_video_io.cpp @@ -460,7 +460,7 @@ static Ext_Fourcc_PSNR synthetic_params[] = { Size all_sizes[] = { Size(640, 480), - Size(976, 768) + Size(656, 496) // row step 1968 is not a multiple of 32: exercises the aligned-copy path in the FFmpeg writer }; TEST_P(videoio_synthetic, write_read_position) { doTest(); }