tests: reduce iterations, input sizes and perf grids of slow tests

Signed-off-by: abhishek-gola <abhishek@opencv.org>
This commit is contained in:
abhishek-gola
2026-11-18 15:49:05 +05:30
committed by Abhishek Gola
parent 8a1083b85a
commit 0cfdeb800f
26 changed files with 142 additions and 73 deletions

View File

@@ -2249,9 +2249,11 @@ TEST(Calib_CalibrateCamera, deterministic_across_threads)
{
cv::Mat K, D, stdIntr, stdExtr, perViewErr, newObj, stdObj;
std::vector<cv::Mat> 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<cv::Mat> parts = { K.reshape(1, 1), D.reshape(1, 1),
stdIntr.reshape(1, 1), stdExtr.reshape(1, 1) };

View File

@@ -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];

View File

@@ -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;

View File

@@ -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);
}
}
}

View File

@@ -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);

View File

@@ -159,7 +159,7 @@ OCL_TEST(SIFT, Batch)
vector<UMat> imgs;
vector<UMat> descriptors;
vector<vector<KeyPoint> > keypoints;
int n = 6;
int n = 2;
Ptr<SIFT> sift = SIFT::create();
for (int i = 0; i < n; i++)

View File

@@ -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<Mat> imgs, descriptors;
vector<vector<KeyPoint> > keypoints;
int i, n = 6;
int i, n = 2;
Ptr<ORB> 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<Mat> imgs, descriptors;
vector<vector<KeyPoint> > keypoints;
int i, n = 6;
int i, n = 2;
Ptr<SIFT> sift = SIFT::create();
for( i = 0; i < n; i++ )

View File

@@ -132,7 +132,8 @@ TEST(Features2d_DISK, MaxKeypointsAndThreshold)
const std::string modelPath = cvtest::findDataFile("dnn/disk.onnx", false);
Ptr<DISK> detector = DISK::create(modelPath);
// The cap and threshold logic is resolution independent; 384x384 still gives >1000 keypoints.
Ptr<DISK> 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<DISK> detector = DISK::create(modelPath);
// 384x384 keeps a non-unit image-to-net scale (512/384) for the coordinate and mask mapping.
Ptr<DISK> detector = DISK::create(modelPath, -1, 0.0f, Size(384, 384));
Mat img = imread(cvtest::findDataFile("shared/lena.png"));
ASSERT_FALSE(img.empty());

View File

@@ -51,9 +51,9 @@ static void detectLightGluePair(int type, Mat images[2], std::vector<KeyPoint> k
detector = ALIKED::create(cvtest::findDataFile("dnn/onnx/models/aliked-n16rot-top1k-640.onnx", false));
else
{
Ptr<DISK> 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"));

View File

@@ -100,9 +100,9 @@ TEST(Flann_KMeansIndex, destroy_after_truncated_load)
const std::vector<char> 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<char>(saved.begin(), saved.begin() + len));

View File

@@ -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();

View File

@@ -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());
}

View File

@@ -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<uchar> buf;
@@ -277,5 +282,6 @@ PERF_TEST_P(Decode, multi_page, testing::ValuesIn(exts_multi))
SANITY_CHECK_NOTHING();
}
#endif // HAVE_TIFF
} // namespace

View File

@@ -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<testing::tuple<PNGStrategy, PNGFilters, int> > pngParamsGrid()
{
std::vector<testing::tuple<PNGStrategy, PNGFilters, int> > 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());

View File

@@ -267,7 +267,8 @@ const string all_exts[] =
vector<Size> all_sizes()
{
vector<Size> 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;
}

View File

@@ -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<LineSegmentDetector> 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<LineSegmentDetector> 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<LineSegmentDetector> 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)

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -22,8 +22,8 @@ typedef TestBaseWithParam<tuple<string, int>> 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")

View File

@@ -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();

View File

@@ -93,7 +93,7 @@ TEST(ParallelFeaturesFinder, IsSameWithSerial)
detail::ImageFeatures serial_features;
detail::computeImageFeatures(serial_finder, img, serial_features);
vector<Mat> imgs(50, img);
vector<Mat> imgs(8, img); // the vector path is a serial loop; 8 copies still overlap if it is ever parallelized
vector<detail::ImageFeatures> para_features(imgs.size());
detail::computeImageFeatures(para_finder, imgs, para_features); // FIXIT This call doesn't use parallel_for_()

View File

@@ -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;

View File

@@ -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_<float>({2, 3}, {1, 0, (rng.uniform(10.f, 20.f)), 0, 1, (rng.uniform(10.f, 20.f))});

View File

@@ -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<videoio_ffmpeg::ParamType>& 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);

View File

@@ -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());

View File

@@ -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(); }