From 62bc647731cc41d216ad2d96e2572a416ccb6588 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Tue, 19 May 2015 17:27:23 +0300 Subject: [PATCH 1/3] use cv::theRNG() instead of ::rand() in gpu::solvePnPRansac --- modules/gpu/src/calib3d.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/gpu/src/calib3d.cpp b/modules/gpu/src/calib3d.cpp index ee0004bcfe..6cab63fb13 100644 --- a/modules/gpu/src/calib3d.cpp +++ b/modules/gpu/src/calib3d.cpp @@ -138,14 +138,16 @@ namespace bool was; do { - subset[i] = rand() % num_points; + subset[i] = cv::theRNG().uniform(0, num_points); was = false; for (int j = 0; j < i; ++j) + { if (subset[j] == subset[i]) { was = true; break; } + } } while (was); } } From 95eed59f2dcc0fc4a3b46892d60deb9e26d22872 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Tue, 19 May 2015 17:27:50 +0300 Subject: [PATCH 2/3] use fixed seed for RNG in gpu SolvePnPRansac test --- modules/gpu/test/test_calib3d.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/gpu/test/test_calib3d.cpp b/modules/gpu/test/test_calib3d.cpp index 0f4c13d8ff..ea4039a0cd 100644 --- a/modules/gpu/test/test_calib3d.cpp +++ b/modules/gpu/test/test_calib3d.cpp @@ -278,18 +278,20 @@ struct SolvePnPRansac : testing::TestWithParam GPU_TEST_P(SolvePnPRansac, Accuracy) { - cv::Mat object = randomMat(cv::Size(5000, 1), CV_32FC3, 0, 100); - cv::Mat camera_mat = randomMat(cv::Size(3, 3), CV_32F, 0.5, 1); + // Use RNG with fixed seed to be reproducable + cv::RNG rng(123456789); + cv::theRNG() = rng; + + cv::Mat object = cvtest::randomMat(rng, cv::Size(5000, 1), CV_32FC3, 0, 100, false); + cv::Mat camera_mat = cvtest::randomMat(rng, cv::Size(3, 3), CV_32FC1, 0.5, 1, false); camera_mat.at(0, 1) = 0.f; camera_mat.at(1, 0) = 0.f; camera_mat.at(2, 0) = 0.f; camera_mat.at(2, 1) = 0.f; std::vector image_vec; - cv::Mat rvec_gold; - cv::Mat tvec_gold; - rvec_gold = randomMat(cv::Size(3, 1), CV_32F, 0, 1); - tvec_gold = randomMat(cv::Size(3, 1), CV_32F, 0, 1); + cv::Mat rvec_gold = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false); + cv::Mat tvec_gold = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false); cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), image_vec); cv::Mat rvec, tvec; From d58d277707ac4750d0986c25de1ef6ca896254aa Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Tue, 19 May 2015 17:28:43 +0300 Subject: [PATCH 3/3] do not loose logs from nvidia tests --- modules/gpu/test/nvidia/main_nvidia.cpp | 30 ++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/modules/gpu/test/nvidia/main_nvidia.cpp b/modules/gpu/test/nvidia/main_nvidia.cpp index 32f83d3d99..897ecece6f 100644 --- a/modules/gpu/test/nvidia/main_nvidia.cpp +++ b/modules/gpu/test/nvidia/main_nvidia.cpp @@ -340,7 +340,8 @@ bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel bool nvidia_NPPST_Squared_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel) { path = test_data_path; - ncvSetDebugOutputHandler(devNullOutput); + if (outputLevel != OutputLevelFull) + ncvSetDebugOutputHandler(devNullOutput); NCVAutoTestLister testListerSII("NPPST Squared Integral Image", outputLevel); @@ -354,7 +355,8 @@ bool nvidia_NPPST_Squared_Integral_Image(const std::string& test_data_path, Outp bool nvidia_NPPST_RectStdDev(const std::string& test_data_path, OutputLevel outputLevel) { path = test_data_path; - ncvSetDebugOutputHandler(devNullOutput); + if (outputLevel != OutputLevelFull) + ncvSetDebugOutputHandler(devNullOutput); NCVAutoTestLister testListerRStdDev("NPPST RectStdDev", outputLevel); @@ -368,7 +370,8 @@ bool nvidia_NPPST_RectStdDev(const std::string& test_data_path, OutputLevel outp bool nvidia_NPPST_Resize(const std::string& test_data_path, OutputLevel outputLevel) { path = test_data_path; - ncvSetDebugOutputHandler(devNullOutput); + if (outputLevel != OutputLevelFull) + ncvSetDebugOutputHandler(devNullOutput); NCVAutoTestLister testListerResize("NPPST Resize", outputLevel); @@ -384,7 +387,8 @@ bool nvidia_NPPST_Resize(const std::string& test_data_path, OutputLevel outputLe bool nvidia_NPPST_Vector_Operations(const std::string& test_data_path, OutputLevel outputLevel) { path = test_data_path; - ncvSetDebugOutputHandler(devNullOutput); + if (outputLevel != OutputLevelFull) + ncvSetDebugOutputHandler(devNullOutput); NCVAutoTestLister testListerNPPSTVectorOperations("NPPST Vector Operations", outputLevel); @@ -398,7 +402,8 @@ bool nvidia_NPPST_Vector_Operations(const std::string& test_data_path, OutputLev bool nvidia_NPPST_Transpose(const std::string& test_data_path, OutputLevel outputLevel) { path = test_data_path; - ncvSetDebugOutputHandler(devNullOutput); + if (outputLevel != OutputLevelFull) + ncvSetDebugOutputHandler(devNullOutput); NCVAutoTestLister testListerTranspose("NPPST Transpose", outputLevel); @@ -414,7 +419,8 @@ bool nvidia_NPPST_Transpose(const std::string& test_data_path, OutputLevel outpu bool nvidia_NCV_Vector_Operations(const std::string& test_data_path, OutputLevel outputLevel) { path = test_data_path; - ncvSetDebugOutputHandler(devNullOutput); + if (outputLevel != OutputLevelFull) + ncvSetDebugOutputHandler(devNullOutput); NCVAutoTestLister testListerVectorOperations("Vector Operations", outputLevel); @@ -429,7 +435,8 @@ bool nvidia_NCV_Vector_Operations(const std::string& test_data_path, OutputLevel bool nvidia_NCV_Haar_Cascade_Loader(const std::string& test_data_path, OutputLevel outputLevel) { path = test_data_path; - ncvSetDebugOutputHandler(devNullOutput); + if (outputLevel != OutputLevelFull) + ncvSetDebugOutputHandler(devNullOutput); NCVAutoTestLister testListerHaarLoader("Haar Cascade Loader", outputLevel); @@ -441,7 +448,8 @@ bool nvidia_NCV_Haar_Cascade_Loader(const std::string& test_data_path, OutputLev bool nvidia_NCV_Haar_Cascade_Application(const std::string& test_data_path, OutputLevel outputLevel) { path = test_data_path; - ncvSetDebugOutputHandler(devNullOutput); + if (outputLevel != OutputLevelFull) + ncvSetDebugOutputHandler(devNullOutput); NCVAutoTestLister testListerHaarAppl("Haar Cascade Application", outputLevel); @@ -455,7 +463,8 @@ bool nvidia_NCV_Haar_Cascade_Application(const std::string& test_data_path, Outp bool nvidia_NCV_Hypotheses_Filtration(const std::string& test_data_path, OutputLevel outputLevel) { path = test_data_path; - ncvSetDebugOutputHandler(devNullOutput); + if (outputLevel != OutputLevelFull) + ncvSetDebugOutputHandler(devNullOutput); NCVAutoTestLister testListerHypFiltration("Hypotheses Filtration", outputLevel); @@ -469,7 +478,8 @@ bool nvidia_NCV_Hypotheses_Filtration(const std::string& test_data_path, OutputL bool nvidia_NCV_Visualization(const std::string& test_data_path, OutputLevel outputLevel) { path = test_data_path; - ncvSetDebugOutputHandler(devNullOutput); + if (outputLevel != OutputLevelFull) + ncvSetDebugOutputHandler(devNullOutput); NCVAutoTestLister testListerVisualize("Visualization", outputLevel);