Merge remote-tracking branch 'origin/master'

This commit is contained in:
Vadim Pisarevsky 2012-10-10 16:16:05 +04:00
commit 9368aa9f7b
17 changed files with 900 additions and 371 deletions

View File

@ -1,137 +0,0 @@
#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();
}

View File

@ -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.";
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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);
}
}

View 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);
}
}

View File

@ -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);
}
}

View File

@ -78,7 +78,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap, Combine(
generateMap(xmap, ymap, remapMode);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_xmap(xmap);
@ -91,6 +91,8 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap, Combine(
{
cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -130,7 +132,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, Combine(
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -141,6 +143,8 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, Combine(
{
cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -179,7 +183,7 @@ PERF_TEST_P(Sz_Depth_Cn_Scale, ImgProc_ResizeArea, Combine(
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 +194,8 @@ PERF_TEST_P(Sz_Depth_Cn_Scale, ImgProc_ResizeArea, Combine(
{
cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -234,7 +240,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine, Combine(
{std::sin(aplha), std::cos(aplha), 0}};
cv::Mat M(2, 3, CV_64F, (void*) mat);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -245,6 +251,8 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine, Combine(
{
cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -288,7 +296,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, Combine(
{0.0, 0.0, 1.0}};
cv::Mat M(3, 3, CV_64F, (void*) mat);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -299,6 +307,8 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, Combine(
{
cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -334,7 +344,7 @@ PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder, Combine(
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -345,6 +355,8 @@ PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder, Combine(
{
cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -379,7 +391,7 @@ PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold, Combine(
cv::Mat src(size, depth);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -390,6 +402,8 @@ PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold, Combine(
{
cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -414,7 +428,7 @@ PERF_TEST_P(Sz, ImgProc_Integral, GPU_TYPICAL_MAT_SIZES)
cv::Mat src(size, CV_8UC1);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -426,6 +440,8 @@ PERF_TEST_P(Sz, ImgProc_Integral, GPU_TYPICAL_MAT_SIZES)
{
cv::gpu::integralBuffered(d_src, d_dst, d_buf);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -450,7 +466,7 @@ PERF_TEST_P(Sz, ImgProc_IntegralSqr, GPU_TYPICAL_MAT_SIZES)
cv::Mat src(size, CV_8UC1);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -461,10 +477,12 @@ PERF_TEST_P(Sz, ImgProc_IntegralSqr, GPU_TYPICAL_MAT_SIZES)
{
cv::gpu::sqrIntegral(d_src, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -479,7 +497,7 @@ PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC1, Combine(GPU_TYPICAL_MAT_SIZES, Values(
cv::Mat src(size, depth);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_hist;
@ -491,6 +509,8 @@ PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC1, Combine(GPU_TYPICAL_MAT_SIZES, Values(
{
cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180);
}
GPU_SANITY_CHECK(d_hist);
}
else
{
@ -526,11 +546,11 @@ PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC4, Combine(GPU_TYPICAL_MAT_SIZES, Values(
int lowerLevel[] = {0, 0, 0, 0};
int upperLevel[] = {180, 180, 180, 180};
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_hist[4];
cv::gpu::GpuMat d_buf;
cv::gpu::GpuMat d_buf, d_hist0;
cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel);
@ -538,10 +558,12 @@ PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC4, Combine(GPU_TYPICAL_MAT_SIZES, Values(
{
cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel);
}
GPU_SANITY_CHECK(d_hist0);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -555,7 +577,7 @@ PERF_TEST_P(Sz, ImgProc_CalcHist, GPU_TYPICAL_MAT_SIZES)
cv::Mat src(size, CV_8UC1);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_hist;
@ -567,10 +589,12 @@ PERF_TEST_P(Sz, ImgProc_CalcHist, GPU_TYPICAL_MAT_SIZES)
{
cv::gpu::calcHist(d_src, d_hist, d_buf);
}
GPU_SANITY_CHECK(d_hist);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -584,7 +608,7 @@ PERF_TEST_P(Sz, ImgProc_EqualizeHist, GPU_TYPICAL_MAT_SIZES)
cv::Mat src(size, CV_8UC1);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -597,6 +621,8 @@ PERF_TEST_P(Sz, ImgProc_EqualizeHist, GPU_TYPICAL_MAT_SIZES)
{
cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf);
}
GPU_SANITY_CHECK(d_hist);
}
else
{
@ -621,7 +647,7 @@ PERF_TEST_P(Sz, ImgProc_ColumnSum, GPU_TYPICAL_MAT_SIZES)
cv::Mat src(size, CV_32FC1);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -632,10 +658,12 @@ PERF_TEST_P(Sz, ImgProc_ColumnSum, GPU_TYPICAL_MAT_SIZES)
{
cv::gpu::columnSum(d_src, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -656,7 +684,7 @@ PERF_TEST_P(Image_AppertureSz_L2gradient, ImgProc_Canny, Combine(
cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(image.empty());
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_image(image);
cv::gpu::GpuMat d_dst;
@ -668,6 +696,8 @@ PERF_TEST_P(Image_AppertureSz_L2gradient, ImgProc_Canny, Combine(
{
cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -697,7 +727,7 @@ PERF_TEST_P(Image, ImgProc_MeanShiftFiltering, Values<string>("gpu/meanshift/con
cv::Mat rgba;
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(rgba);
cv::gpu::GpuMat d_dst;
@ -708,6 +738,8 @@ PERF_TEST_P(Image, ImgProc_MeanShiftFiltering, Values<string>("gpu/meanshift/con
{
cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -735,7 +767,7 @@ PERF_TEST_P(Image, ImgProc_MeanShiftProc, Values<string>("gpu/meanshift/cones.pn
cv::Mat rgba;
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(rgba);
cv::gpu::GpuMat d_dstr;
@ -747,10 +779,12 @@ PERF_TEST_P(Image, ImgProc_MeanShiftProc, Values<string>("gpu/meanshift/cones.pn
{
cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50);
}
GPU_SANITY_CHECK(d_dstr);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -769,7 +803,7 @@ PERF_TEST_P(Image, ImgProc_MeanShiftSegmentation, Values<string>("gpu/meanshift/
cv::Mat dst;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(rgba);
@ -779,10 +813,12 @@ PERF_TEST_P(Image, ImgProc_MeanShiftSegmentation, Values<string>("gpu/meanshift/
{
cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20);
}
GPU_SANITY_CHECK(dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -803,7 +839,7 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear, Combine(GPU_TYPICAL_MAT_SIZES, Val
cv::Mat img2(size, type);
fillRandom(img2);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_img1(img1);
cv::gpu::GpuMat d_img2(img2);
@ -817,10 +853,12 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear, Combine(GPU_TYPICAL_MAT_SIZES, Val
{
cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -843,7 +881,7 @@ PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, Combine(GPU_TYPICAL_MAT_SIZES,
cv::Mat templ(templ_size, templ_size, CV_32FC1);
templ.setTo(1.0);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_image = cv::gpu::createContinuous(size, CV_32FC1);
d_image.upload(image);
@ -860,6 +898,8 @@ PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, Combine(GPU_TYPICAL_MAT_SIZES,
{
cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -873,6 +913,8 @@ PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, Combine(GPU_TYPICAL_MAT_SIZES,
{
cv::filter2D(image, dst, image.depth(), templ);
}
CPU_SANITY_CHECK(dst);
}
}
@ -901,7 +943,7 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U, Combine(
cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn));
fillRandom(templ);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_image(image);
cv::gpu::GpuMat d_templ(templ);
@ -913,6 +955,8 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U, Combine(
{
cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -924,6 +968,8 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U, Combine(
{
cv::matchTemplate(image, templ, dst, method);
}
CPU_SANITY_CHECK(dst);
}
};
@ -947,7 +993,7 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F, Combine(
cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn));
fillRandom(templ);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_image(image);
cv::gpu::GpuMat d_templ(templ);
@ -959,6 +1005,8 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F, Combine(
{
cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -970,6 +1018,8 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F, Combine(
{
cv::matchTemplate(image, templ, dst, method);
}
CPU_SANITY_CHECK(dst);
}
};
@ -993,7 +1043,7 @@ PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, Combine(
cv::Mat b(size, CV_32FC2);
fillRandom(b, 0, 100);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_a(a);
cv::gpu::GpuMat d_b(b);
@ -1005,6 +1055,8 @@ PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, Combine(
{
cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -1016,6 +1068,8 @@ PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, Combine(
{
cv::mulSpectrums(a, b, dst, flag);
}
CPU_SANITY_CHECK(dst);
}
}
@ -1034,7 +1088,7 @@ PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums, GPU_TYPICAL_MAT_SIZES)
cv::Mat src2(size, CV_32FC2);
fillRandom(src2, 0, 100);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
@ -1046,10 +1100,12 @@ PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums, GPU_TYPICAL_MAT_SIZES)
{
cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -1068,7 +1124,7 @@ PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine(
cv::Mat src(size, CV_32FC2);
fillRandom(src, 0, 100);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -1079,6 +1135,8 @@ PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine(
{
cv::gpu::dft(d_src, d_dst, size, flag);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -1090,6 +1148,8 @@ PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine(
{
cv::dft(src, dst, flag);
}
CPU_SANITY_CHECK(dst);
}
}
@ -1117,7 +1177,7 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine(
double k = 0.5;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_dst;
@ -1131,6 +1191,8 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine(
{
cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -1142,6 +1204,8 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine(
{
cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode);
}
CPU_SANITY_CHECK(dst);
}
}
@ -1166,7 +1230,7 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal, Com
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_dst;
@ -1180,6 +1244,8 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal, Com
{
cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -1191,6 +1257,8 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal, Com
{
cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode);
}
CPU_SANITY_CHECK(dst);
}
}
@ -1205,7 +1273,7 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpPlaneMaps, GPU_TYPICAL_MAT_SIZES)
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
cv::Mat T = cv::Mat::zeros(1, 3, CV_32F);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_map_x;
cv::gpu::GpuMat d_map_y;
@ -1216,10 +1284,13 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpPlaneMaps, GPU_TYPICAL_MAT_SIZES)
{
cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y);
}
GPU_SANITY_CHECK(d_map_x);
GPU_SANITY_CHECK(d_map_y);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -1233,7 +1304,7 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpCylindricalMaps, GPU_TYPICAL_MAT_SIZES)
cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_map_x;
cv::gpu::GpuMat d_map_y;
@ -1244,10 +1315,13 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpCylindricalMaps, GPU_TYPICAL_MAT_SIZES)
{
cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);
}
GPU_SANITY_CHECK(d_map_x);
GPU_SANITY_CHECK(d_map_y);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -1261,7 +1335,7 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpSphericalMaps, GPU_TYPICAL_MAT_SIZES)
cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_map_x;
cv::gpu::GpuMat d_map_y;
@ -1272,10 +1346,14 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpSphericalMaps, GPU_TYPICAL_MAT_SIZES)
{
cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);
}
GPU_SANITY_CHECK(d_map_x);
GPU_SANITY_CHECK(d_map_y);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -1300,7 +1378,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter, ImgProc_Rotate, Combine(
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -1311,10 +1389,12 @@ PERF_TEST_P(Sz_Depth_Cn_Inter, ImgProc_Rotate, Combine(
{
cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -1335,7 +1415,7 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown, Combine(
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -1346,6 +1426,8 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown, Combine(
{
cv::gpu::pyrDown(d_src, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -1357,6 +1439,8 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown, Combine(
{
cv::pyrDown(src, dst);
}
CPU_SANITY_CHECK(dst);
}
}
@ -1377,7 +1461,7 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp, Combine(
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -1388,6 +1472,8 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp, Combine(
{
cv::gpu::pyrUp(d_src, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -1399,6 +1485,8 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp, Combine(
{
cv::pyrUp(src, dst);
}
CPU_SANITY_CHECK(dst);
}
}
@ -1444,7 +1532,7 @@ PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor, Combine(
cv::Mat src(size, CV_MAKETYPE(depth, info.scn));
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -1455,6 +1543,8 @@ PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor, Combine(
{
cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
@ -1466,6 +1556,8 @@ PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor, Combine(
{
cv::cvtColor(src, dst, info.code, info.dcn);
}
CPU_SANITY_CHECK(dst);
}
}
@ -1481,7 +1573,7 @@ PERF_TEST_P(Sz, ImgProc_SwapChannels, GPU_TYPICAL_MAT_SIZES)
const int dstOrder[] = {2, 1, 0, 3};
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
@ -1491,10 +1583,12 @@ PERF_TEST_P(Sz, ImgProc_SwapChannels, GPU_TYPICAL_MAT_SIZES)
{
cv::gpu::swapChannels(d_src, dstOrder);
}
GPU_SANITY_CHECK(d_src);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -1518,7 +1612,7 @@ PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp, Combine(GPU_TYPICAL_MAT_SIZES, Values
cv::Mat img2(size, type);
fillRandom(img2);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_img1(img1);
cv::gpu::GpuMat d_img2(img2);
@ -1530,10 +1624,12 @@ PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp, Combine(GPU_TYPICAL_MAT_SIZES, Values
{
cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -1551,7 +1647,7 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidBuild, Combine(GPU_TYPICAL_MAT_SIZE
cv::Mat src(size, type);
fillRandom(src);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
@ -1563,10 +1659,12 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidBuild, Combine(GPU_TYPICAL_MAT_SIZE
{
d_pyr.build(d_src, 5);
}
GPU_SANITY_CHECK(d_src);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -1586,7 +1684,7 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidGetLayer, Combine(GPU_TYPICAL_MAT_S
cv::Size dstSize(size.width / 2 + 10, size.height / 2 + 10);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
@ -1599,17 +1697,19 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidGetLayer, Combine(GPU_TYPICAL_MAT_S
{
d_pyr.getLayer(d_dst, dstSize);
}
GPU_SANITY_CHECK(d_dst);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
//////////////////////////////////////////////////////////////////////
// HoughLines
PERF_TEST_P(Sz, ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES)
PERF_TEST_P(Sz, DISABLED_ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES)
{
declare.time(30.0);
@ -1631,7 +1731,7 @@ PERF_TEST_P(Sz, ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES)
cv::line(src, p1, p2, cv::Scalar::all(255), 2);
}
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_lines;
@ -1643,6 +1743,8 @@ PERF_TEST_P(Sz, ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES)
{
cv::gpu::HoughLines(d_src, d_lines, d_buf, rho, theta, threshold);
}
GPU_SANITY_CHECK(d_lines);
}
else
{
@ -1653,6 +1755,8 @@ PERF_TEST_P(Sz, ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES)
{
cv::HoughLines(src, lines, rho, theta, threshold);
}
CPU_SANITY_CHECK(lines);
}
}
@ -1687,7 +1791,7 @@ PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles, Combine(GPU_TYPICAL_MAT_SIZES,
cv::circle(src, center, radius, cv::Scalar::all(255), -1);
}
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_circles;
@ -1699,6 +1803,8 @@ PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles, Combine(GPU_TYPICAL_MAT_SIZES,
{
cv::gpu::HoughCircles(d_src, d_circles, d_buf, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
}
GPU_SANITY_CHECK(d_circles);
}
else
{
@ -1710,6 +1816,8 @@ PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles, Combine(GPU_TYPICAL_MAT_SIZES,
{
cv::HoughCircles(src, circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
}
CPU_SANITY_CHECK(circles);
}
}
@ -1762,7 +1870,7 @@ PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough, Combine(
cv::Sobel(image, dx, CV_32F, 1, 0);
cv::Sobel(image, dy, CV_32F, 0, 1);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_edges(edges);
cv::gpu::GpuMat d_dx(dx);
@ -1784,6 +1892,8 @@ PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough, Combine(
{
d_hough->detect(d_edges, d_dx, d_dy, d_position);
}
GPU_SANITY_CHECK(d_position);
}
else
{
@ -1804,6 +1914,9 @@ PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough, Combine(
{
hough->detect(edges, dx, dy, positions);
}
CPU_SANITY_CHECK(dx);
CPU_SANITY_CHECK(dy);
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,74 @@
#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())

View 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);
}
}

View File

@ -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);
}
}

View File

@ -20,7 +20,8 @@ typedef pair<string, string> pair_string;
DEF_PARAM_TEST_1(ImagePair, pair_string);
PERF_TEST_P(ImagePair, Video_BroxOpticalFlow, Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
PERF_TEST_P(ImagePair, Video_BroxOpticalFlow,
Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
{
declare.time(10);
@ -33,7 +34,7 @@ PERF_TEST_P(ImagePair, Video_BroxOpticalFlow, Values<pair_string>(make_pair("gpu
frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
@ -49,17 +50,21 @@ PERF_TEST_P(ImagePair, Video_BroxOpticalFlow, Values<pair_string>(make_pair("gpu
{
d_flow(d_frame0, d_frame1, d_u, d_v);
}
GPU_SANITY_CHECK(d_u);
GPU_SANITY_CHECK(d_v);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
//////////////////////////////////////////////////////
// InterpolateFrames
PERF_TEST_P(ImagePair, Video_InterpolateFrames, Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
PERF_TEST_P(ImagePair, Video_InterpolateFrames,
Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
{
cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0.empty());
@ -70,7 +75,7 @@ PERF_TEST_P(ImagePair, Video_InterpolateFrames, Values<pair_string>(make_pair("g
frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
@ -92,17 +97,23 @@ PERF_TEST_P(ImagePair, Video_InterpolateFrames, Values<pair_string>(make_pair("g
{
cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
}
GPU_SANITY_CHECK(d_fu);
GPU_SANITY_CHECK(d_fv);
GPU_SANITY_CHECK(d_bu);
GPU_SANITY_CHECK(d_bv);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
//////////////////////////////////////////////////////
// CreateOpticalFlowNeedleMap
PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap, Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap,
Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
{
cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0.empty());
@ -113,7 +124,7 @@ PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap, Values<pair_string>(mak
frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
@ -133,10 +144,13 @@ PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap, Values<pair_string>(mak
{
cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
}
GPU_SANITY_CHECK(d_vertex);
GPU_SANITY_CHECK(d_colors)
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -145,7 +159,8 @@ PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap, Values<pair_string>(mak
DEF_PARAM_TEST(Image_MinDistance, string, double);
PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack, Combine(Values<string>("gpu/perf/aloe.png"), Values(0.0, 3.0)))
PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack,
Combine(Values<string>("gpu/perf/aloe.png"), Values(0.0, 3.0)))
{
string fileName = GET_PARAM(0);
double minDistance = GET_PARAM(1);
@ -153,7 +168,7 @@ PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack, Combine(Values<string>
cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(image.empty());
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance);
@ -166,6 +181,8 @@ PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack, Combine(Values<string>
{
d_detector(d_image, d_pts);
}
GPU_SANITY_CHECK(d_pts);
}
else
{
@ -177,6 +194,8 @@ PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack, Combine(Values<string>
{
cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance);
}
CPU_SANITY_CHECK(pts);
}
}
@ -217,7 +236,7 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse
cv::Mat pts;
cv::goodFeaturesToTrack(gray_frame, pts, points, 0.01, 0.0);
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_pts(pts.reshape(2, 1));
@ -237,6 +256,8 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse
{
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
}
GPU_SANITY_CHECK(d_status);
}
else
{
@ -253,6 +274,8 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse
cv::Size(winSize, winSize), levels - 1,
cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01));
}
CPU_SANITY_CHECK(status);
}
}
@ -280,7 +303,7 @@ PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense, Combine(
cv::Mat frame1 = readImage(imagePair.second, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame1.empty());
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
@ -298,17 +321,21 @@ PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense, Combine(
{
d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
}
GPU_SANITY_CHECK(d_u);
GPU_SANITY_CHECK(d_v);
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
//////////////////////////////////////////////////////
// FarnebackOpticalFlow
PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow, Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow,
Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
{
declare.time(10);
@ -326,7 +353,7 @@ PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow, Values<pair_string>(make_pair
double polySigma = 1.1;
int flags = 0;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
@ -348,6 +375,9 @@ PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow, Values<pair_string>(make_pair
{
d_farneback(d_frame0, d_frame1, d_u, d_v);
}
GPU_SANITY_CHECK(d_u);
GPU_SANITY_CHECK(d_v);
}
else
{
@ -359,6 +389,8 @@ PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow, Values<pair_string>(make_pair
{
cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
}
CPU_SANITY_CHECK(flow);
}
}
@ -367,7 +399,7 @@ PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow, Values<pair_string>(make_pair
DEF_PARAM_TEST_1(Video, string);
PERF_TEST_P(Video, Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
PERF_TEST_P(Video, DISABLED_Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
{
declare.time(60);
@ -380,7 +412,7 @@ PERF_TEST_P(Video, Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/vide
cap >> frame;
ASSERT_FALSE(frame.empty());
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame(frame);
@ -423,7 +455,8 @@ PERF_TEST_P(Video, Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/vide
DEF_PARAM_TEST(Video_Cn_LearningRate, string, MatCn, double);
PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4, Values(0.0, 0.01)))
PERF_TEST_P(Video_Cn_LearningRate, DISABLED_Video_MOG,
Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4, Values(0.0, 0.01)))
{
string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
int cn = GET_PARAM(1);
@ -447,7 +480,7 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576.
cv::swap(temp, frame);
}
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame(frame);
cv::gpu::MOG_GPU d_mog;
@ -511,7 +544,8 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576.
DEF_PARAM_TEST(Video_Cn, string, int);
PERF_TEST_P(Video_Cn, Video_MOG2, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
PERF_TEST_P(Video_Cn, DISABLED_Video_MOG2,
Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
{
string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
int cn = GET_PARAM(1);
@ -534,7 +568,7 @@ PERF_TEST_P(Video_Cn, Video_MOG2, Combine(Values("gpu/video/768x576.avi", "gpu/v
cv::swap(temp, frame);
}
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame(frame);
cv::gpu::MOG2_GPU d_mog2;
@ -596,7 +630,8 @@ PERF_TEST_P(Video_Cn, Video_MOG2, Combine(Values("gpu/video/768x576.avi", "gpu/v
//////////////////////////////////////////////////////
// MOG2GetBackgroundImage
PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage,
Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
{
string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
int cn = GET_PARAM(1);
@ -606,7 +641,7 @@ PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage, Combine(Values("gpu/video/76
cv::Mat frame;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame;
cv::gpu::MOG2_GPU d_mog2;
@ -639,6 +674,8 @@ PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage, Combine(Values("gpu/video/76
{
d_mog2.getBackgroundImage(d_background);
}
GPU_SANITY_CHECK(d_background);
}
else
{
@ -670,13 +707,16 @@ PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage, Combine(Values("gpu/video/76
{
mog2.getBackgroundImage(background);
}
CPU_SANITY_CHECK(background);
}
}
//////////////////////////////////////////////////////
// VIBE
PERF_TEST_P(Video_Cn, Video_VIBE, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
PERF_TEST_P(Video_Cn, DISABLED_Video_VIBE,
Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
{
string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
int cn = GET_PARAM(1);
@ -698,7 +738,7 @@ PERF_TEST_P(Video_Cn, Video_VIBE, Combine(Values("gpu/video/768x576.avi", "gpu/v
cv::swap(temp, frame);
}
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame(frame);
cv::gpu::VIBE_GPU d_vibe;
@ -730,7 +770,7 @@ PERF_TEST_P(Video_Cn, Video_VIBE, Combine(Values("gpu/video/768x576.avi", "gpu/v
}
else
{
FAIL();
FAIL() << "No such CPU implementation analogy";
}
}
@ -739,7 +779,8 @@ PERF_TEST_P(Video_Cn, Video_VIBE, Combine(Values("gpu/video/768x576.avi", "gpu/v
DEF_PARAM_TEST(Video_Cn_MaxFeatures, string, MatCn, int);
PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4, Values(20, 40, 60)))
PERF_TEST_P(Video_Cn_MaxFeatures, DISABLED_Video_GMG,
Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4, Values(20, 40, 60)))
{
std::string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
int cn = GET_PARAM(1);
@ -762,7 +803,7 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.a
cv::swap(temp, frame);
}
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame(frame);
cv::gpu::GpuMat d_fgmask;
@ -840,7 +881,7 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.a
//////////////////////////////////////////////////////
// VideoWriter
PERF_TEST_P(Video, Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
PERF_TEST_P(Video, DISABLED_Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
{
declare.time(30);
@ -854,7 +895,7 @@ PERF_TEST_P(Video, Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video
cv::Mat frame;
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::VideoWriter_GPU d_writer;
@ -903,7 +944,7 @@ PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video
string inputFile = perf::TestBase::getDataPath(GetParam());
if (runOnGpu)
if (PERF_RUN_GPU())
{
cv::gpu::VideoReader_GPU d_reader(inputFile);
ASSERT_TRUE( d_reader.isOpened() );
@ -916,6 +957,8 @@ PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video
{
d_reader.read(d_frame);
}
GPU_SANITY_CHECK(d_frame);
}
else
{
@ -930,6 +973,8 @@ PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video
{
reader >> frame;
}
CPU_SANITY_CHECK(frame);
}
}

View File

@ -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];
}
}

View 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__

View File

@ -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);\

View File

@ -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
\*****************************************************************************************/

View File

@ -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_;
}