1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2023-01-21 18:19:39 +00:00
74 changed files with 249 additions and 228 deletions
+27 -5
View File
@@ -522,13 +522,35 @@ namespace cvtest
int validCount = 0;
for (size_t i = 0; i < gold.size(); ++i)
if (actual.size() == gold.size())
{
const cv::KeyPoint& p1 = gold[i];
const cv::KeyPoint& p2 = actual[i];
for (size_t i = 0; i < gold.size(); ++i)
{
const cv::KeyPoint& p1 = gold[i];
const cv::KeyPoint& p2 = actual[i];
if (keyPointsEquals(p1, p2))
++validCount;
if (keyPointsEquals(p1, p2))
++validCount;
}
}
else
{
std::vector<cv::KeyPoint>& shorter = gold;
std::vector<cv::KeyPoint>& longer = actual;
if (actual.size() < gold.size())
{
shorter = actual;
longer = gold;
}
for (size_t i = 0; i < shorter.size(); ++i)
{
const cv::KeyPoint& p1 = shorter[i];
const cv::KeyPoint& p2 = longer[i];
const cv::KeyPoint& p3 = longer[i+1];
if (keyPointsEquals(p1, p2) || keyPointsEquals(p1, p3))
++validCount;
}
}
return validCount;
+11 -4
View File
@@ -623,20 +623,27 @@ void TS::set_gtest_status()
void TS::update_context( BaseTest* test, int test_case_idx, bool update_ts_context )
{
CV_UNUSED(update_ts_context);
if( current_test_info.test != test )
{
for( int i = 0; i <= CONSOLE_IDX; i++ )
output_buf[i] = string();
rng = RNG(params.rng_seed);
current_test_info.rng_seed0 = current_test_info.rng_seed = rng.state;
}
if (test_case_idx >= 0)
{
current_test_info.rng_seed = param_seed + test_case_idx;
current_test_info.rng_seed0 = current_test_info.rng_seed;
rng = RNG(current_test_info.rng_seed);
cv::theRNG() = rng;
}
current_test_info.test = test;
current_test_info.test_case_idx = test_case_idx;
current_test_info.code = 0;
cvSetErrStatus( CV_StsOk );
if( update_ts_context )
current_test_info.rng_seed = rng.state;
}
+1 -64
View File
@@ -26,7 +26,6 @@ using namespace perf;
int64 TestBase::timeLimitDefault = 0;
unsigned int TestBase::iterationsLimitDefault = UINT_MAX;
int64 TestBase::_timeadjustment = 0;
// Item [0] will be considered the default implementation.
static std::vector<std::string> available_impls;
@@ -1159,7 +1158,6 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
timeLimitDefault = param_time_limit == 0.0 ? 1 : (int64)(param_time_limit * cv::getTickFrequency());
iterationsLimitDefault = param_force_samples == 0 ? UINT_MAX : param_force_samples;
_timeadjustment = _calibrate();
}
void TestBase::RecordRunParameters()
@@ -1193,66 +1191,6 @@ enum PERF_STRATEGY TestBase::getCurrentModulePerformanceStrategy()
return strategyForce == PERF_STRATEGY_DEFAULT ? strategyModule : strategyForce;
}
int64 TestBase::_calibrate()
{
CV_TRACE_FUNCTION();
if (iterationsLimitDefault <= 1)
return 0;
class _helper : public ::perf::TestBase
{
public:
_helper() { testStrategy = PERF_STRATEGY_BASE; }
performance_metrics& getMetrics() { return calcMetrics(); }
virtual void TestBody() {}
virtual void PerfTestBody()
{
//the whole system warmup
SetUp();
cv::Mat a(2048, 2048, CV_32S, cv::Scalar(1));
cv::Mat b(2048, 2048, CV_32S, cv::Scalar(2));
declare.time(30);
double s = 0;
declare.iterations(20);
minIters = nIters = 20;
for(; next() && startTimer(); stopTimer())
s+=a.dot(b);
declare.time(s);
//self calibration
SetUp();
declare.iterations(1000);
minIters = nIters = 1000;
for(int iters = 0; next() && startTimer(); iters++, stopTimer()) { /*std::cout << iters << nIters << std::endl;*/ }
}
};
// Initialize ThreadPool
class _dummyParallel : public ParallelLoopBody
{
public:
void operator()(const cv::Range& range) const
{
// nothing
CV_UNUSED(range);
}
};
parallel_for_(cv::Range(0, 1000), _dummyParallel());
_timeadjustment = 0;
_helper h;
h.PerfTestBody();
double compensation = h.getMetrics().min;
if (getCurrentModulePerformanceStrategy() == PERF_STRATEGY_SIMPLE)
{
CV_Assert(compensation < 0.01 * cv::getTickFrequency());
compensation = 0.0f; // simple strategy doesn't require any compensation
}
LOGD("Time compensation is %.0f", compensation);
return (int64)compensation;
}
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable:4355) // 'this' : used in base member initializer list
@@ -1561,9 +1499,8 @@ void TestBase::stopTimer()
if (lastTime == 0)
ADD_FAILURE() << " stopTimer() is called before startTimer()/next()";
lastTime = time - lastTime;
CV_Assert(lastTime >= 0); // TODO: CV_Check* for int64
totalTime += lastTime;
lastTime -= _timeadjustment;
if (lastTime < 0) lastTime = 0;
times.push_back(lastTime);
lastTime = 0;