Commit 9368aa9f authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge remote-tracking branch 'origin/master'

parents e80cbbb1 b28acfc1
#include "perf_precomp.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cvtest;
using namespace testing;
void printOsInfo()
{
#if defined _WIN32
# if defined _WIN64
cout << "OS: Windows x64 \n" << endl;
# else
cout << "OS: Windows x32 \n" << endl;
# endif
#elif defined linux
# if defined _LP64
cout << "OS: Linux x64 \n" << endl;
# else
cout << "OS: Linux x32 \n" << endl;
# endif
#elif defined __APPLE__
# if defined _LP64
cout << "OS: Apple x64 \n" << endl;
# else
cout << "OS: Apple x32 \n" << endl;
# endif
#endif
}
void printCudaInfo()
{
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
cout << "OpenCV was built without CUDA support \n" << endl;
#else
int driver;
cudaDriverGetVersion(&driver);
cout << "CUDA Driver version: " << driver << '\n';
cout << "CUDA Runtime version: " << CUDART_VERSION << '\n';
cout << endl;
cout << "GPU module was compiled for the following GPU archs:" << endl;
cout << " BIN: " << CUDA_ARCH_BIN << '\n';
cout << " PTX: " << CUDA_ARCH_PTX << '\n';
cout << endl;
int deviceCount = getCudaEnabledDeviceCount();
cout << "CUDA device count: " << deviceCount << '\n';
cout << endl;
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
cout << "Device [" << i << "] \n";
cout << "\t Name: " << info.name() << '\n';
cout << "\t Compute capability: " << info.majorVersion() << '.' << info.minorVersion()<< '\n';
cout << "\t Multi Processor Count: " << info.multiProcessorCount() << '\n';
cout << "\t Total memory: " << static_cast<int>(static_cast<int>(info.totalMemory() / 1024.0) / 1024.0) << " Mb \n";
cout << "\t Free memory: " << static_cast<int>(static_cast<int>(info.freeMemory() / 1024.0) / 1024.0) << " Mb \n";
if (!info.isCompatible())
cout << "\t !!! This device is NOT compatible with current GPU module build \n";
cout << endl;
}
#endif
}
int main(int argc, char** argv)
{
const std::string keys =
"{ h help ? | | Print help}"
"{ i info | | Print information about system and exit }"
"{ device | 0 | Device on which tests will be executed }"
"{ cpu | | Run tests on cpu }"
;
CommandLineParser cmd(argc, (const char**) argv, keys);
if (cmd.has("help"))
{
cmd.printMessage();
return 0;
}
printOsInfo();
printCudaInfo();
if (cmd.has("info"))
{
return 0;
}
int device = cmd.get<int>("device");
bool cpu = cmd.has("cpu");
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
cpu = true;
#endif
if (cpu)
{
runOnGpu = false;
cout << "Run tests on CPU \n" << endl;
}
else
{
runOnGpu = true;
if (device < 0 || device >= getCudaEnabledDeviceCount())
{
cerr << "Incorrect device index - " << device << endl;
return -1;
}
DeviceInfo info(device);
if (!info.isCompatible())
{
cerr << "Device " << device << " [" << info.name() << "] is NOT compatible with current GPU module build" << endl;
return -1;
}
setDevice(device);
cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl;
}
InitGoogleTest(&argc, argv);
perf::TestBase::Init(argc, argv);
return RUN_ALL_TESTS();
}
......@@ -24,7 +24,7 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png",
const int preset = 0;
const int ndisp = 256;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::StereoBM_GPU d_bm(preset, ndisp);
......@@ -38,6 +38,8 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png",
{
d_bm(d_imgLeft, d_imgRight, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -51,6 +53,8 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png",
{
bm(imgLeft, imgRight, dst);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -69,7 +73,7 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(pair_string("gpu/
const int ndisp = 64;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::StereoBeliefPropagation d_bp(ndisp);
......@@ -83,10 +87,12 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(pair_string("gpu/
{
d_bp(d_imgLeft, d_imgRight, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy.";
}
}
......@@ -105,7 +111,7 @@ PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP, Values(pair_string("gpu/st
const int ndisp = 128;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::StereoConstantSpaceBP d_csbp(ndisp);
......@@ -119,10 +125,12 @@ PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP, Values(pair_string("gpu/st
{
d_csbp(d_imgLeft, d_imgRight, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy.";
}
}
......@@ -139,7 +147,7 @@ PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(pair_string("gpu
const int ndisp = 128;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::DisparityBilateralFilter d_filter(ndisp);
......@@ -153,10 +161,12 @@ PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(pair_string("gpu
{
d_filter(d_disp, d_img, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy.";
}
}
......@@ -175,7 +185,7 @@ PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000))
const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -186,10 +196,12 @@ PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000))
{
cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy.";
}
}
......@@ -207,7 +219,7 @@ PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
const cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -218,6 +230,8 @@ PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
{
cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -229,6 +243,8 @@ PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
{
cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -265,7 +281,7 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000))
cv::Mat rvec;
cv::Mat tvec;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
......@@ -283,6 +299,9 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000))
cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
}
}
CPU_SANITY_CHECK(rvec);
CPU_SANITY_CHECK(tvec);
}
//////////////////////////////////////////////////////////////////////
......@@ -299,7 +318,7 @@ PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES,
cv::Mat Q(4, 4, CV_32FC1);
fillRandom(Q, 0.1, 1.0);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -310,6 +329,8 @@ PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES,
{
cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -321,6 +342,8 @@ PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES,
{
cv::reprojectImageTo3D(src, dst, Q);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -335,7 +358,7 @@ PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp, Combine(GPU_TYPICAL_MAT_SIZES, Valu
cv::Mat src(size, type);
fillRandom(src, 0, 255);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -346,10 +369,12 @@ PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp, Combine(GPU_TYPICAL_MAT_SIZES, Valu
{
cv::gpu::drawColorDisp(d_src, d_dst, 255);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy.";
}
}
......
This diff is collapsed.
......@@ -11,7 +11,7 @@ using namespace testing;
DEF_PARAM_TEST(Sz_Depth_Cn_KernelSz, cv::Size, MatDepth, MatCn, int);
PERF_TEST_P(Sz_Depth_Cn_KernelSz, Denoising_BilateralFilter,
PERF_TEST_P(Sz_Depth_Cn_KernelSz, Denoising_BilateralFilter,
Combine(GPU_DENOISING_IMAGE_SIZES, Values(CV_8U, CV_32F), GPU_CHANNELS_1_3, Values(3, 5, 9)))
{
declare.time(60.0);
......@@ -30,7 +30,7 @@ PERF_TEST_P(Sz_Depth_Cn_KernelSz, Denoising_BilateralFilter,
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -41,6 +41,8 @@ PERF_TEST_P(Sz_Depth_Cn_KernelSz, Denoising_BilateralFilter,
{
cv::gpu::bilateralFilter(d_src, d_dst, kernel_size, sigma_color, sigma_spatial, borderMode);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -52,6 +54,8 @@ PERF_TEST_P(Sz_Depth_Cn_KernelSz, Denoising_BilateralFilter,
{
cv::bilateralFilter(src, dst, kernel_size, sigma_color, sigma_spatial, borderMode);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -61,27 +65,27 @@ PERF_TEST_P(Sz_Depth_Cn_KernelSz, Denoising_BilateralFilter,
DEF_PARAM_TEST(Sz_Depth_Cn_WinSz_BlockSz, cv::Size, MatDepth, MatCn, int, int);
PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_NonLocalMeans,
PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_NonLocalMeans,
Combine(GPU_DENOISING_IMAGE_SIZES, Values<MatDepth>(CV_8U), GPU_CHANNELS_1_3, Values(21), Values(5, 7)))
{
declare.time(60.0);
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
int search_widow_size = GET_PARAM(3);
int block_size = GET_PARAM(4);
float h = 10;
int borderMode = cv::BORDER_REFLECT101;
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -92,10 +96,12 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_NonLocalMeans,
{
cv::gpu::nonLocalMeans(d_src, d_dst, h, search_widow_size, block_size, borderMode);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
......@@ -105,35 +111,37 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_NonLocalMeans,
DEF_PARAM_TEST(Sz_Depth_Cn_WinSz_BlockSz, cv::Size, MatDepth, MatCn, int, int);
PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_FastNonLocalMeans,
PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_FastNonLocalMeans,
Combine(GPU_DENOISING_IMAGE_SIZES, Values<MatDepth>(CV_8U), GPU_CHANNELS_1_3, Values(21), Values(7)))
{
declare.time(150.0);
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int depth = GET_PARAM(1);
int search_widow_size = GET_PARAM(2);
int block_size = GET_PARAM(3);
float h = 10;
int type = CV_MAKE_TYPE(depth, 1);
float h = 10;
int type = CV_MAKE_TYPE(depth, 1);
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::FastNonLocalMeansDenoising fnlmd;
fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
TEST_CYCLE()
{
fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -144,6 +152,8 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_FastNonLocalMeans,
{
cv::fastNlMeansDenoising(src, dst, h, block_size, search_widow_size);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -152,35 +162,37 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_FastNonLocalMeans,
DEF_PARAM_TEST(Sz_Depth_WinSz_BlockSz, cv::Size, MatDepth, int, int);
PERF_TEST_P(Sz_Depth_WinSz_BlockSz, Denoising_FastNonLocalMeansColored,
PERF_TEST_P(Sz_Depth_WinSz_BlockSz, Denoising_FastNonLocalMeansColored,
Combine(GPU_DENOISING_IMAGE_SIZES, Values<MatDepth>(CV_8U), Values(21), Values(7)))
{
declare.time(350.0);
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int search_widow_size = GET_PARAM(2);
int block_size = GET_PARAM(3);
float h = 10;
float h = 10;
int type = CV_MAKE_TYPE(depth, 3);
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::FastNonLocalMeansDenoising fnlmd;
fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
TEST_CYCLE()
{
fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -191,5 +203,7 @@ PERF_TEST_P(Sz_Depth_WinSz_BlockSz, Denoising_FastNonLocalMeansColored,
{
cv::fastNlMeansDenoisingColored(src, dst, h, h, block_size, search_widow_size);
}
CPU_SANITY_CHECK(dst);
}
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ PERF_TEST_P(Image, Features2D_SURF, Values<string>("gpu/perf/aloe.png"))
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::SURF_GPU d_surf;
......@@ -30,6 +30,9 @@ PERF_TEST_P(Image, Features2D_SURF, Values<string>("gpu/perf/aloe.png"))
{
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
}
GPU_SANITY_CHECK(d_descriptors, 1e-4);
GPU_SANITY_CHECK_KEYPOINTS(SURF, d_keypoints);
}
else
{
......@@ -45,6 +48,9 @@ PERF_TEST_P(Image, Features2D_SURF, Values<string>("gpu/perf/aloe.png"))
keypoints.clear();
surf(img, cv::noArray(), keypoints, descriptors);
}
SANITY_CHECK_KEYPOINTS(keypoints);
SANITY_CHECK(descriptors, 1e-4);
}
}
......@@ -56,7 +62,7 @@ PERF_TEST_P(Image, Features2D_FAST, Values<string>("gpu/perf/aloe.png"))
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::FAST_GPU d_fast(20);
......@@ -69,6 +75,8 @@ PERF_TEST_P(Image, Features2D_FAST, Values<string>("gpu/perf/aloe.png"))
{
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
}
GPU_SANITY_CHECK_RESPONSE(FAST, d_keypoints);
}
else
{
......@@ -81,6 +89,8 @@ PERF_TEST_P(Image, Features2D_FAST, Values<string>("gpu/perf/aloe.png"))
keypoints.clear();
cv::FAST(img, keypoints, 20);
}
SANITY_CHECK_KEYPOINTS(keypoints);
}
}
......@@ -92,7 +102,7 @@ PERF_TEST_P(Image, Features2D_ORB, Values<string>("gpu/perf/aloe.png"))
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::ORB_GPU d_orb(4000);
......@@ -105,6 +115,9 @@ PERF_TEST_P(Image, Features2D_ORB, Values<string>("gpu/perf/aloe.png"))
{
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
}
GPU_SANITY_CHECK_KEYPOINTS(ORB, d_keypoints);
GPU_SANITY_CHECK(d_descriptors);
}
else
{
......@@ -120,6 +133,9 @@ PERF_TEST_P(Image, Features2D_ORB, Values<string>("gpu/perf/aloe.png"))
keypoints.clear();
orb(img, cv::noArray(), keypoints, descriptors);
}
SANITY_CHECK_KEYPOINTS(keypoints);
SANITY_CHECK(descriptors);
}
}
......@@ -143,7 +159,7 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, Combine(Values(64, 128, 256), Val
cv::Mat train(3000, desc_size, type);
fillRandom(train);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::BFMatcher_GPU d_matcher(normType);
......@@ -157,6 +173,9 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, Combine(Values(64, 128, 256), Val
{
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
}
GPU_SANITY_CHECK(d_trainIdx);
GPU_SANITY_CHECK(d_distance);
}
else
{
......@@ -170,6 +189,8 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, Combine(Values(64, 128, 256), Val
{
matcher.match(query, train, matches);
}
SANITY_CHECK(matches);
}
}
......@@ -197,7 +218,7 @@ PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine(
cv::Mat train(3000, desc_size, type);
fillRandom(train);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::BFMatcher_GPU d_matcher(normType);
......@@ -211,6 +232,9 @@ PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine(
{
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
}
GPU_SANITY_CHECK(d_trainIdx);
GPU_SANITY_CHECK(d_distance);
}
else
{
......@@ -224,6 +248,8 @@ PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine(
{
matcher.knnMatch(query, train, matches, k);
}
SANITY_CHECK(matches);
}
}
......@@ -245,7 +271,7 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, Combine(Values(64, 128, 256
cv::Mat train(3000, desc_size, type);
fillRandom(train, 0.0, 1.0);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::BFMatcher_GPU d_matcher(normType);
......@@ -259,6 +285,9 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, Combine(Values(64, 128, 256
{
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
}
GPU_SANITY_CHECK(d_trainIdx);
GPU_SANITY_CHECK(d_distance);
}
else
{
......@@ -272,6 +301,8 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, Combine(Values(64, 128, 256
{
matcher.radiusMatch(query, train, matches, 2.0);
}
SANITY_CHECK(matches);
}
}
......
......@@ -21,7 +21,7 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Value
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -32,6 +32,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Value
{
cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -43,6 +45,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Value
{
cv::blur(src, dst, cv::Size(ksize, ksize));
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -60,7 +64,7 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Valu
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -72,6 +76,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Valu
{
cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -83,6 +89,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Valu
{
cv::Sobel(src, dst, -1, 1, 1, ksize);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -99,7 +107,7 @@ PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -111,6 +119,8 @@ PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
{
cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -122,6 +132,8 @@ PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
{
cv::Scharr(src, dst, -1, 1, 0);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -139,7 +151,7 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZE
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -151,6 +163,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZE
{
cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -162,6 +176,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZE
{
cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -179,7 +195,7 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES,
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -190,6 +206,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES,
{
cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -201,6 +219,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES,
{
cv::Laplacian(src, dst, -1, ksize);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -219,7 +239,7 @@ PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -231,6 +251,8 @@ PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC
{
cv::gpu::erode(d_src, d_dst, ker, d_buf);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -242,6 +264,8 @@ PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC
{
cv::erode(src, dst, ker);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -260,7 +284,7 @@ PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -272,6 +296,8 @@ PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
{
cv::gpu::dilate(d_src, d_dst, ker, d_buf);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -283,6 +309,8 @@ PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
{
cv::dilate(src, dst, ker);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -307,7 +335,7 @@ PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Val
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -320,6 +348,8 @@ PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Val
{
cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -331,6 +361,8 @@ PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Val
{
cv::morphologyEx(src, dst, morphOp, ker);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -351,7 +383,7 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, V
cv::Mat kernel(ksize, ksize, CV_32FC1);
fillRandom(kernel, 0.0, 1.0);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -362,6 +394,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, V
{
cv::gpu::filter2D(d_src, d_dst, -1, kernel);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -373,6 +407,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, V
{
cv::filter2D(src, dst, -1, kernel);
}
CPU_SANITY_CHECK(dst);
}
}
......
This diff is collapsed.
......@@ -106,7 +106,7 @@ PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/al
cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat mask;
mask.create(image.rows, image.cols, CV_8UC1);
......@@ -122,6 +122,8 @@ PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/al
{
cv::gpu::labelComponents(mask, components);
}
GPU_SANITY_CHECK(components);
}
else
{
......@@ -135,6 +137,8 @@ PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/al
{
host(host._labels);
}
CPU_SANITY_CHECK(host._labels);
}
}
......
#include "perf_precomp.hpp"
namespace{
static void printOsInfo()
{
#if defined _WIN32
# if defined _WIN64
printf("[----------]\n[ GPU INFO ] \tRun on OS Windows x64.\n[----------]\n"), fflush(stdout);
# else
printf("[----------]\n[ GPU INFO ] \tRun on OS Windows x32.\n[----------]\n"), fflush(stdout);
# endif
#elif defined linux
# if defined _LP64
printf("[----------]\n[ GPU INFO ] \tRun on OS Linux x64.\n[----------]\n"), fflush(stdout);
# else
printf("[----------]\n[ GPU INFO ] \tRun on OS Linux x32.\n[----------]\n"), fflush(stdout);
# endif
#elif defined __APPLE__
# if defined _LP64
printf("[----------]\n[ GPU INFO ] \tRun on OS Apple x64.\n[----------]\n"), fflush(stdout);
# else
printf("[----------]\n[ GPU INFO ] \tRun on OS Apple x32.\n[----------]\n"), fflush(stdout);
# endif
#endif
}
static void printCudaInfo()
{
printOsInfo();
#ifndef HAVE_CUDA
printf("[----------]\n[ GPU INFO ] \tOpenCV was built without CUDA support.\n[----------]\n"), fflush(stdout);
#else
int driver;
cudaDriverGetVersion(&driver);
printf("[----------]\n"), fflush(stdout);
printf("[ GPU INFO ] \tCUDA Driver version: %d.\n", driver), fflush(stdout);
printf("[ GPU INFO ] \tCUDA Runtime version: %d.\n", CUDART_VERSION), fflush(stdout);
printf("[----------]\n"), fflush(stdout);
printf("[----------]\n"), fflush(stdout);
printf("[ GPU INFO ] \tGPU module was compiled for the following GPU archs.\n"), fflush(stdout);
printf("[ BIN ] \t%s.\n", CUDA_ARCH_BIN), fflush(stdout);
printf("[ PTX ] \t%s.\n", CUDA_ARCH_PTX), fflush(stdout);
printf("[----------]\n"), fflush(stdout);
printf("[----------]\n"), fflush(stdout);
int deviceCount = cv::gpu::getCudaEnabledDeviceCount();
printf("[ GPU INFO ] \tCUDA device count:: %d.\n", deviceCount), fflush(stdout);
printf("[----------]\n"), fflush(stdout);
for (int i = 0; i < deviceCount; ++i)
{
cv::gpu::DeviceInfo info(i);
printf("[----------]\n"), fflush(stdout);
printf("[ DEVICE ] \t# %d %s.\n", i, info.name().c_str()), fflush(stdout);
printf("[ ] \tCompute capability: %d.%d\n", (int)info.majorVersion(), (int)info.minorVersion()), fflush(stdout);
printf("[ ] \tMulti Processor Count: %d\n", info.multiProcessorCount()), fflush(stdout);
printf("[ ] \tTotal memory: %d Mb\n", static_cast<int>(static_cast<int>(info.totalMemory() / 1024.0) / 1024.0)), fflush(stdout);
printf("[ ] \tFree memory: %d Mb\n", static_cast<int>(static_cast<int>(info.freeMemory() / 1024.0) / 1024.0)), fflush(stdout);
if (!info.isCompatible())
printf("[ GPU INFO ] \tThis device is NOT compatible with current GPU module build\n");
printf("[----------]\n"), fflush(stdout);
}
#endif
}
}
CV_PERF_TEST_MAIN(gpu, printCudaInfo())
\ No newline at end of file
......@@ -18,7 +18,7 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8
cv::Scalar val(1, 2, 3, 4);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(size, type);
......@@ -28,6 +28,8 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8
{
d_src.setTo(val);
}
GPU_SANITY_CHECK(d_src);
}
else
{
......@@ -39,6 +41,8 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8
{
src.setTo(val);
}
CPU_SANITY_CHECK(src);
}
}
......@@ -61,7 +65,7 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Value
cv::Scalar val(1, 2, 3, 4);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
......@@ -72,6 +76,8 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Value
{
d_src.setTo(val, d_mask);
}
GPU_SANITY_CHECK(d_src);
}
else
{
......@@ -81,6 +87,8 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Value
{
src.setTo(val, mask);
}
CPU_SANITY_CHECK(src);
}
}
......@@ -101,7 +109,7 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Valu
cv::Mat mask(size, CV_8UC1);
fillRandom(mask, 0, 2);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
......@@ -113,6 +121,8 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Valu
{
d_src.copyTo(d_dst, d_mask);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -124,6 +134,8 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Valu
{
src.copyTo(dst, mask);
}
CPU_SANITY_CHECK(dst);
}
}
......@@ -141,7 +153,7 @@ PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV
cv::Mat src(size, depth1);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
......@@ -152,6 +164,8 @@ PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV
{
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
......@@ -163,6 +177,8 @@ PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV
{
src.convertTo(dst, depth2, 0.5, 1.0);
}
CPU_SANITY_CHECK(dst);
}
}
......
......@@ -17,7 +17,7 @@ PERF_TEST_P(Image, ObjDetect_HOG, Values<string>("gpu/hog/road.png"))
std::vector<cv::Rect> found_locations;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_img(img);
......@@ -43,6 +43,8 @@ PERF_TEST_P(Image, ObjDetect_HOG, Values<string>("gpu/hog/road.png"))
hog.detectMultiScale(img, found_locations);
}
}
SANITY_CHECK(found_locations);
}
//===========test for CalTech data =============//
......@@ -57,7 +59,7 @@ PERF_TEST_P(HOG, CalTech, Values<string>("gpu/caltech/image_00000009_0.png", "gp
std::vector<cv::Rect> found_locations;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_img(img);
......@@ -83,6 +85,8 @@ PERF_TEST_P(HOG, CalTech, Values<string>("gpu/caltech/image_00000009_0.png", "gp
hog.detectMultiScale(img, found_locations);
}
}
SANITY_CHECK(found_locations);
}
......@@ -98,7 +102,7 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier,
cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::CascadeClassifier_GPU d_cascade;
ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second)));
......@@ -112,6 +116,8 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier,
{
d_cascade.detectMultiScale(d_img, d_objects_buffer);
}
GPU_SANITY_CHECK(d_objects_buffer);
}
else
{
......@@ -126,6 +132,8 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier,
{
cascade.detectMultiScale(img, rects);
}
CPU_SANITY_CHECK(rects);
}
}
......@@ -138,7 +146,7 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier,
cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::CascadeClassifier_GPU d_cascade;
ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second)));
......@@ -152,6 +160,8 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier,
{
d_cascade.detectMultiScale(d_img, d_gpu_rects);
}
GPU_SANITY_CHECK(d_gpu_rects);
}
else
{
......@@ -166,6 +176,8 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier,
{
cascade.detectMultiScale(img, rects);
}
CPU_SANITY_CHECK(rects);
}
}
......
This diff is collapsed.
......@@ -4,8 +4,6 @@ using namespace std;
using namespace cv;
using namespace cv::gpu;
bool runOnGpu = true;
void fillRandom(Mat& m, double a, double b)
{
RNG rng(123456789);
......@@ -190,4 +188,4 @@ void PrintTo(const CvtColorInfo& info, ostream* os)
};
*os << str[info.code];
}
}
\ No newline at end of file
......@@ -6,8 +6,6 @@
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/ts/ts_perf.hpp"
extern bool runOnGpu;
void fillRandom(cv::Mat& m, double a = 0.0, double b = 255.0);
cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
......@@ -48,5 +46,37 @@ DEF_PARAM_TEST(Sz_Depth_Cn, cv::Size, MatDepth, MatCn);
#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::sz720p, perf::szSXGA, perf::sz1080p)
#define GPU_SANITY_CHECK(dmat, ...) \
do{ \
cv::Mat d##dmat(dmat); \
SANITY_CHECK(d##dmat, ## __VA_ARGS__); \
} while(0)
#define CPU_SANITY_CHECK(cmat, ...) \
do{ \
SANITY_CHECK(cmat, ## __VA_ARGS__); \
} while(0)
#define GPU_SANITY_CHECK_KEYPOINTS(alg, dmat, ...) \
do{ \
cv::Mat d##dmat(dmat); \
cv::Mat __pt_x = d##dmat.row(cv::gpu::alg##_GPU::X_ROW); \
cv::Mat __pt_y = d##dmat.row(cv::gpu::alg##_GPU::Y_ROW); \
cv::Mat __angle = d##dmat.row(cv::gpu::alg##_GPU::ANGLE_ROW); \
cv::Mat __octave = d##dmat.row(cv::gpu::alg##_GPU::OCTAVE_ROW); \
cv::Mat __size = d##dmat.row(cv::gpu::alg##_GPU::SIZE_ROW); \
::perf::Regression::add(this, std::string(#dmat) + "-pt-x-row", __pt_x, ## __VA_ARGS__); \
::perf::Regression::add(this, std::string(#dmat) + "-pt-y-row", __pt_y, ## __VA_ARGS__); \
::perf::Regression::add(this, std::string(#dmat) + "-angle-row", __angle, ## __VA_ARGS__); \
::perf::Regression::add(this, std::string(#dmat) + "octave-row", __octave, ## __VA_ARGS__); \
::perf::Regression::add(this, std::string(#dmat) + "-pt-size-row", __size, ## __VA_ARGS__); \
} while(0)
#define GPU_SANITY_CHECK_RESPONSE(alg, dmat, ...) \
do{ \
cv::Mat d##dmat(dmat); \
cv::Mat __response = d##dmat.row(cv::gpu::alg##_GPU::RESPONSE_ROW); \
::perf::Regression::add(this, std::string(#dmat) + "-response-row", __response, ## __VA_ARGS__); \
} while(0)
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__
......@@ -205,6 +205,18 @@ private:
#define SANITY_CHECK_KEYPOINTS(array, ...) ::perf::Regression::addKeypoints(this, #array, array , ## __VA_ARGS__)
#define SANITY_CHECK_MATCHES(array, ...) ::perf::Regression::addMatches(this, #array, array , ## __VA_ARGS__)
#ifdef HAVE_CUDA
class CV_EXPORTS GpuPerf
{
public:
static bool targetDevice();
};
# define PERF_RUN_GPU() ::perf::GpuPerf::targetDevice()
#else
# define PERF_RUN_GPU() false
#endif
/*****************************************************************************************\
* Container for performance metrics *
......@@ -465,9 +477,10 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
void fixture##_##name::PerfTestBody()
#define CV_PERF_TEST_MAIN(testsuitname) \
#define CV_PERF_TEST_MAIN(testsuitname, ...) \
int main(int argc, char **argv)\
{\
__VA_ARGS__;\
::perf::Regression::Init(#testsuitname);\
::perf::TestBase::Init(argc, argv);\
::testing::InitGoogleTest(&argc, argv);\
......
......@@ -17,15 +17,20 @@ const std::string command_line_keys =
"{ perf_seed |809564 |seed for random numbers generator}"
"{ perf_tbb_nthreads |-1 |if TBB is enabled, the number of TBB threads}"
"{ perf_write_sanity | |allow to create new records for sanity checks}"
#ifdef ANDROID
#ifdef ANDROID
"{ perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
"{ perf_affinity_mask |0 |set affinity mask for the main thread}"
"{ perf_log_power_checkpoints | |additional xml logging for power measurement}"
#else
#else
"{ perf_time_limit |3.0 |default time limit for a single test (in seconds)}"
#endif
#endif
"{ perf_max_deviation |1.0 |}"
"{ help h | |print help info}"
#ifdef HAVE_CUDA
"{ perf_run_cpu |false |run GPU performance tests for analogical CPU functions}"
"{ perf_cuda_device |0 |run GPU test suite onto specific CUDA capable device}"
"{ perf_cuda_info_only |false |print an information about system and an available CUDA devices and then exit.}"
#endif
;
static double param_max_outliers;
......@@ -36,10 +41,16 @@ static uint64 param_seed;
static double param_time_limit;
static int param_tbb_nthreads;
static bool param_write_sanity;
#ifdef HAVE_CUDA
static bool param_run_cpu;
static int param_cuda_device;
#endif
#ifdef ANDROID
static int param_affinity_mask;
static bool log_power_checkpoints;
#include <sys/syscall.h>
#include <pthread.h>
static void setCurrentThreadAffinityMask(int mask)
......@@ -56,6 +67,10 @@ static void setCurrentThreadAffinityMask(int mask)
#endif
#ifdef HAVE_CUDA
# include <opencv2/core/gpumat.hpp>
#endif
static void randu(cv::Mat& m)
{
const int bigValue = 0x00000FFF;
......@@ -608,6 +623,33 @@ void TestBase::Init(int argc, const char* const argv[])
log_power_checkpoints = args.has("perf_log_power_checkpoints");
#endif
#ifdef HAVE_CUDA
bool printOnly = args.has("perf_cuda_info_only");
if (printOnly)
exit(0);
param_run_cpu = args.has("perf_run_cpu");
param_cuda_device = std::max(0, std::min(cv::gpu::getCudaEnabledDeviceCount(), args.get<int>("perf_cuda_device")));
if (param_run_cpu)
printf("[----------]\n[ GPU INFO ] \tRun test suite on CPU.\n[----------]\n"), fflush(stdout);
else
{
cv::gpu::DeviceInfo info(param_cuda_device);
if (!info.isCompatible())
{
printf("[----------]\n[ FAILURE ] \tDevice %s is NOT compatible with current GPU module build.\n[----------]\n", info.name().c_str()), fflush(stdout);
exit(-1);
}
cv::gpu::setDevice(param_cuda_device);
printf("[----------]\n[ GPU INFO ] \tRun test suite on %s GPU.\n[----------]\n", info.name().c_str()), fflush(stdout);
}
#endif
if (!args.check())
{
args.printErrors();
......@@ -1185,6 +1227,16 @@ TestBase::_declareHelper::_declareHelper(TestBase* t) : test(t)
{
}
/*****************************************************************************************\
* ::perf::GpuPerf
\*****************************************************************************************/
#ifdef HAVE_CUDA
bool perf::GpuPerf::targetDevice()
{
return !param_run_cpu;
}
#endif
/*****************************************************************************************\
* ::perf::PrintTo
\*****************************************************************************************/
......
......@@ -756,7 +756,7 @@ Mat KeypointBasedMotionEstimatorGpu::estimate(const gpu::GpuMat &frame0, const g
grayFrame0 = frame0;
else
{
gpu::cvtColor(frame0_, grayFrame0_, CV_BGR2GRAY);
gpu::cvtColor(frame0, grayFrame0_, CV_BGR2GRAY);
grayFrame0 = grayFrame0_;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment