diff --git a/modules/calib3d/perf/perf_pnp.cpp b/modules/calib3d/perf/perf_pnp.cpp index 746f548e84..b32b96cae2 100644 --- a/modules/calib3d/perf/perf_pnp.cpp +++ b/modules/calib3d/perf/perf_pnp.cpp @@ -1,4 +1,5 @@ #include "perf_precomp.hpp" +#include "opencv2/core/internal.hpp" using namespace std; using namespace cv; @@ -48,7 +49,10 @@ PERF_TEST_P(PointsNum_Algo, solvePnP, 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(tvec, 1e-6); @@ -83,7 +87,10 @@ PERF_TEST(PointsNum_Algo, solveP3P) 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(tvec, 1e-6); @@ -117,9 +124,10 @@ PERF_TEST_P(PointsNum, SolvePnPRansac, testing::Values(4, 3*9, 7*13)) Mat rvec; Mat tvec; - solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); - - declare.time(3.0); +#ifdef HAVE_TBB + // limit concurrency to get determenistic result + cv::Ptr one_thread = new tbb::task_scheduler_init(1); +#endif TEST_CYCLE() { diff --git a/modules/calib3d/src/solvepnp.cpp b/modules/calib3d/src/solvepnp.cpp index 125d7a9fa6..25988be48a 100644 --- a/modules/calib3d/src/solvepnp.cpp +++ b/modules/calib3d/src/solvepnp.cpp @@ -260,6 +260,8 @@ namespace cv { rvec.copyTo(initRvec); tvec.copyTo(initTvec); + + generator.state = theRNG().state; //to control it somehow... } private: PnPSolver& operator=(const PnPSolver&); diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index 5467d618da..a59880afdc 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -674,6 +674,8 @@ cv::Size TestBase::getSize(cv::InputArray a) bool TestBase::next() { bool has_next = ++currentIter < nIters && totalTime < timeLimit; + cv::theRNG().state = param_seed; //this rng should generate same numbers for each run + #ifdef ANDROID if (log_power_checkpoints) { @@ -948,7 +950,6 @@ void TestBase::SetUp() currentIter = (unsigned int)-1; timeLimit = timeLimitDefault; times.clear(); - cv::theRNG().state = param_seed;//this rng should generate same numbers for each run } void TestBase::TearDown()