Make performance tests for solvePnPRansec more determenistic

This commit is contained in:
Andrey Kamaev 2012-10-09 18:34:55 +04:00
parent d4cf9e22cc
commit 5a5c477be6
3 changed files with 17 additions and 6 deletions

View File

@ -1,4 +1,5 @@
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
#include "opencv2/core/internal.hpp"
using namespace std; using namespace std;
using namespace cv; using namespace cv;
@ -48,7 +49,10 @@ PERF_TEST_P(PointsNum_Algo, solvePnP,
declare.in(points3d, points2d); declare.in(points3d, points2d);
TEST_CYCLE_N(1000) solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, algo); TEST_CYCLE_N(1000)
{
solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, algo);
}
SANITY_CHECK(rvec, 1e-6); SANITY_CHECK(rvec, 1e-6);
SANITY_CHECK(tvec, 1e-6); SANITY_CHECK(tvec, 1e-6);
@ -83,7 +87,10 @@ PERF_TEST(PointsNum_Algo, solveP3P)
declare.in(points3d, points2d); declare.in(points3d, points2d);
TEST_CYCLE_N(1000) solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, CV_P3P); TEST_CYCLE_N(1000)
{
solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, CV_P3P);
}
SANITY_CHECK(rvec, 1e-6); SANITY_CHECK(rvec, 1e-6);
SANITY_CHECK(tvec, 1e-6); SANITY_CHECK(tvec, 1e-6);
@ -117,9 +124,10 @@ PERF_TEST_P(PointsNum, SolvePnPRansac, testing::Values(4, 3*9, 7*13))
Mat rvec; Mat rvec;
Mat tvec; Mat tvec;
solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); #ifdef HAVE_TBB
// limit concurrency to get determenistic result
declare.time(3.0); cv::Ptr<tbb::task_scheduler_init> one_thread = new tbb::task_scheduler_init(1);
#endif
TEST_CYCLE() TEST_CYCLE()
{ {

View File

@ -260,6 +260,8 @@ namespace cv
{ {
rvec.copyTo(initRvec); rvec.copyTo(initRvec);
tvec.copyTo(initTvec); tvec.copyTo(initTvec);
generator.state = theRNG().state; //to control it somehow...
} }
private: private:
PnPSolver& operator=(const PnPSolver&); PnPSolver& operator=(const PnPSolver&);

View File

@ -674,6 +674,8 @@ cv::Size TestBase::getSize(cv::InputArray a)
bool TestBase::next() bool TestBase::next()
{ {
bool has_next = ++currentIter < nIters && totalTime < timeLimit; bool has_next = ++currentIter < nIters && totalTime < timeLimit;
cv::theRNG().state = param_seed; //this rng should generate same numbers for each run
#ifdef ANDROID #ifdef ANDROID
if (log_power_checkpoints) if (log_power_checkpoints)
{ {
@ -948,7 +950,6 @@ void TestBase::SetUp()
currentIter = (unsigned int)-1; currentIter = (unsigned int)-1;
timeLimit = timeLimitDefault; timeLimit = timeLimitDefault;
times.clear(); times.clear();
cv::theRNG().state = param_seed;//this rng should generate same numbers for each run
} }
void TestBase::TearDown() void TestBase::TearDown()