Skip to content

Commit

Permalink
video(test): filter very long debug tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Feb 15, 2024
1 parent 32db3f9 commit 4c7a70c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
27 changes: 21 additions & 6 deletions modules/video/test/test_trackers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,27 @@ const string FOLDER_OMIT_INIT = "initOmit";
#include "test_trackers.impl.hpp"

//[TESTDATA]
PARAM_TEST_CASE(DistanceAndOverlap, string)
PARAM_TEST_CASE(DistanceAndOverlap, string, int)
{
string dataset;
int numFramesLimit;
virtual void SetUp()
{
dataset = GET_PARAM(0);
numFramesLimit = GET_PARAM(1);
}
};

TEST_P(DistanceAndOverlap, MIL)
{
TrackerTest<Tracker, Rect> test(TrackerMIL::create(), dataset, 30, .65f, NoTransform);
test.run();
test.run(numFramesLimit);
}

TEST_P(DistanceAndOverlap, Shifted_Data_MIL)
{
TrackerTest<Tracker, Rect> test(TrackerMIL::create(), dataset, 30, .6f, CenterShiftLeft);
test.run();
test.run(numFramesLimit);
}

/***************************************************************************************/
Expand All @@ -48,7 +50,7 @@ TEST_P(DistanceAndOverlap, Shifted_Data_MIL)
TEST_P(DistanceAndOverlap, Scaled_Data_MIL)
{
TrackerTest<Tracker, Rect> test(TrackerMIL::create(), dataset, 30, .7f, Scale_1_1);
test.run();
test.run(numFramesLimit);
}

TEST_P(DistanceAndOverlap, GOTURN)
Expand All @@ -59,10 +61,23 @@ TEST_P(DistanceAndOverlap, GOTURN)
params.modelTxt = model;
params.modelBin = weights;
TrackerTest<Tracker, Rect> test(TrackerGOTURN::create(params), dataset, 35, .35f, NoTransform);
test.run();
test.run(numFramesLimit);
}

INSTANTIATE_TEST_CASE_P(Tracking, DistanceAndOverlap, TESTSET_NAMES);
INSTANTIATE_TEST_CASE_P(Tracking, DistanceAndOverlap,
testing::Combine(
TESTSET_NAMES,
testing::Values(0)
)
);

INSTANTIATE_TEST_CASE_P(Tracking5Frames, DistanceAndOverlap,
testing::Combine(
TESTSET_NAMES,
testing::Values(5)
)
);


static bool checkIOU(const Rect& r0, const Rect& r1, double threshold)
{
Expand Down
19 changes: 17 additions & 2 deletions modules/video/test/test_trackers.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class TrackerTest
TrackerTest(const Ptr<Tracker>& tracker, const string& video, float distanceThreshold,
float overlapThreshold, int shift = NoTransform, int segmentIdx = 1, int numSegments = 10);
~TrackerTest() {}
void run();
void run(int numFramesLimit = 0);

protected:
void checkDataTest();
Expand Down Expand Up @@ -351,7 +351,7 @@ void TrackerTest<Tracker, ROI_t>::checkDataTest()
}

template <typename Tracker, typename ROI_t>
void TrackerTest<Tracker, ROI_t>::run()
void TrackerTest<Tracker, ROI_t>::run(int numFramesLimit)
{
srand(1); // FIXIT remove that, ensure that there is no "rand()" in implementation

Expand All @@ -363,5 +363,20 @@ void TrackerTest<Tracker, ROI_t>::run()
if (::testing::Test::HasFatalFailure())
return;

int numFrames = endFrame - startFrame;
std::cout << "Number of frames in test data: " << numFrames << std::endl;

if (numFramesLimit > 0)
{
numFrames = std::min(numFrames, numFramesLimit);
endFrame = startFrame + numFramesLimit;
}
else
{
applyTestTag(CV_TEST_TAG_DEBUG_VERYLONG);
}

std::cout << "Number of frames to test: " << numFrames << std::endl;

distanceAndOverlapTest();
}

0 comments on commit 4c7a70c

Please sign in to comment.