Commit ba451350 authored by Andrey Pavlenko's avatar Andrey Pavlenko Committed by OpenCV Buildbot

Merge pull request #2429 from ilya-lavrenov:master_compatible_tests

parents b5248dbf 767b28f2
This diff is collapsed.
...@@ -165,11 +165,11 @@ PERF_TEST_P(VideoMOGFixture, MOG, ...@@ -165,11 +165,11 @@ PERF_TEST_P(VideoMOGFixture, MOG,
///////////// MOG2 //////////////////////// ///////////// MOG2 ////////////////////////
typedef tuple<string, int> VideoMOG2ParamType; typedef tuple<string, int> VideoMOG2ParamType;
typedef TestBaseWithParam<VideoMOG2ParamType> VideoMOG2Fixture; typedef TestBaseWithParam<VideoMOG2ParamType> MOG2_Apply;
PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on buildslave OCL_PERF_TEST_P(MOG2_Apply, Mog2,
::testing::Combine(::testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), testing::Combine(testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
::testing::Values(1, 3))) testing::Values(1, 3)))
{ {
VideoMOG2ParamType params = GetParam(); VideoMOG2ParamType params = GetParam();
...@@ -195,10 +195,8 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b ...@@ -195,10 +195,8 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b
foreground.release(); foreground.release();
for (int i = 0; i < nFrame; i++) for (int i = 0; i < nFrame; i++)
{
mog2(frame_buffer[i], foreground); mog2(frame_buffer[i], foreground);
} }
}
SANITY_CHECK(foreground); SANITY_CHECK(foreground);
} }
else if(RUN_OCL_IMPL) else if(RUN_OCL_IMPL)
...@@ -210,10 +208,8 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b ...@@ -210,10 +208,8 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b
cv::ocl::MOG2 d_mog2; cv::ocl::MOG2 d_mog2;
foreground_d.release(); foreground_d.release();
for (int i = 0; i < nFrame; i++) for (int i = 0; i < nFrame; i++)
{
d_mog2(frame_buffer_ocl[i], foreground_d); d_mog2(frame_buffer_ocl[i], foreground_d);
} }
}
foreground_d.download(foreground); foreground_d.download(foreground);
SANITY_CHECK(foreground); SANITY_CHECK(foreground);
} }
...@@ -223,11 +219,11 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b ...@@ -223,11 +219,11 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b
///////////// MOG2_GetBackgroundImage ////////////////// ///////////// MOG2_GetBackgroundImage //////////////////
typedef TestBaseWithParam<VideoMOG2ParamType> Video_MOG2GetBackgroundImage; typedef TestBaseWithParam<VideoMOG2ParamType> MOG2_GetBackgroundImage;
PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2, OCL_PERF_TEST_P(MOG2_GetBackgroundImage, Mog2,
::testing::Combine(::testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), testing::Combine(testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
::testing::Values(3))) testing::Values(3)))
{ {
VideoMOG2ParamType params = GetParam(); VideoMOG2ParamType params = GetParam();
...@@ -248,7 +244,7 @@ PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2, ...@@ -248,7 +244,7 @@ PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2,
cv::ocl::oclMat foreground_d; cv::ocl::oclMat foreground_d;
cv::ocl::oclMat background_d; cv::ocl::oclMat background_d;
if(RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
TEST_CYCLE() TEST_CYCLE()
{ {
...@@ -264,7 +260,7 @@ PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2, ...@@ -264,7 +260,7 @@ PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2,
} }
SANITY_CHECK(background); SANITY_CHECK(background);
} }
else if(RUN_OCL_IMPL) else if (RUN_OCL_IMPL)
{ {
prepareData(frame_buffer, frame_buffer_ocl); prepareData(frame_buffer, frame_buffer_ocl);
CV_Assert((int)(frame_buffer_ocl.size()) == nFrame); CV_Assert((int)(frame_buffer_ocl.size()) == nFrame);
......
...@@ -88,10 +88,10 @@ typedef void (*blendFunction)(const Mat &img1, const Mat &img2, ...@@ -88,10 +88,10 @@ typedef void (*blendFunction)(const Mat &img1, const Mat &img2,
const Mat &weights1, const Mat &weights2, const Mat &weights1, const Mat &weights2,
Mat &result_gold); Mat &result_gold);
typedef Size_MatType blendLinearFixture; typedef Size_MatType BlendLinearFixture;
PERF_TEST_P(blendLinearFixture, blendLinear, ::testing::Combine( OCL_PERF_TEST_P(BlendLinearFixture, BlendLinear,
OCL_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_32FC1))) ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
{ {
Size_MatType_t params = GetParam(); Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
......
...@@ -46,21 +46,23 @@ ...@@ -46,21 +46,23 @@
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
using namespace perf; using namespace perf;
using std::tr1::get;
#define OCL_BFMATCHER_TYPICAL_MAT_SIZES ::testing::Values(cv::Size(128, 500), cv::Size(128, 1000), cv::Size(128, 2000))
//////////////////// BruteForceMatch ///////////////// //////////////////// BruteForceMatch /////////////////
typedef TestBaseWithParam<Size> BruteForceMatcherFixture; typedef Size_MatType BruteForceMatcherFixture;
PERF_TEST_P(BruteForceMatcherFixture, match, OCL_PERF_TEST_P(BruteForceMatcherFixture, Match,
OCL_BFMATCHER_TYPICAL_MAT_SIZES) ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_PERF_ENUM(MatType(CV_32FC1))))
{ {
const Size srcSize = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
vector<DMatch> matches; vector<DMatch> matches;
Mat query(srcSize, CV_32F), train(srcSize, CV_32F); Mat query(srcSize, type), train(srcSize, type);
declare.in(query, train).time(srcSize.height == 2000 ? 9 : 4 ); declare.in(query, train);
randu(query, 0.0f, 1.0f); randu(query, 0.0f, 1.0f);
randu(train, 0.0f, 1.0f); randu(train, 0.0f, 1.0f);
...@@ -75,12 +77,9 @@ PERF_TEST_P(BruteForceMatcherFixture, match, ...@@ -75,12 +77,9 @@ PERF_TEST_P(BruteForceMatcherFixture, match,
{ {
ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist); ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
ocl::oclMat oclQuery(query), oclTrain(train); ocl::oclMat oclQuery(query), oclTrain(train);
ocl::oclMat oclTrainIdx, oclDistance;
OCL_TEST_CYCLE() OCL_TEST_CYCLE()
oclMatcher.matchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance); oclMatcher.match(oclQuery, oclTrain, matches);
oclMatcher.matchDownload(oclTrainIdx, oclDistance, matches);
SANITY_CHECK_MATCHES(matches, 1e-5); SANITY_CHECK_MATCHES(matches, 1e-5);
} }
...@@ -88,19 +87,20 @@ PERF_TEST_P(BruteForceMatcherFixture, match, ...@@ -88,19 +87,20 @@ PERF_TEST_P(BruteForceMatcherFixture, match,
OCL_PERF_ELSE OCL_PERF_ELSE
} }
PERF_TEST_P(BruteForceMatcherFixture, knnMatch, OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch,
OCL_BFMATCHER_TYPICAL_MAT_SIZES) ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_PERF_ENUM(MatType(CV_32FC1))))
{ {
const Size srcSize = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
vector<vector<DMatch> > matches(2); vector<vector<DMatch> > matches(2);
Mat query(srcSize, CV_32F), train(srcSize, CV_32F); Mat query(srcSize, type), train(srcSize, type);
randu(query, 0.0f, 1.0f); randu(query, 0.0f, 1.0f);
randu(train, 0.0f, 1.0f); randu(train, 0.0f, 1.0f);
declare.in(query, train); declare.in(query, train);
if (srcSize.height == 2000)
declare.time(9);
if (RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
...@@ -115,10 +115,10 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch, ...@@ -115,10 +115,10 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch,
{ {
ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist); ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
ocl::oclMat oclQuery(query), oclTrain(train); ocl::oclMat oclQuery(query), oclTrain(train);
ocl::oclMat oclTrainIdx, oclDistance, oclAllDist; ocl::oclMat oclTrainIdx, oclDistance;
OCL_TEST_CYCLE() OCL_TEST_CYCLE()
oclMatcher.knnMatchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance, oclAllDist, 2); oclMatcher.knnMatch(oclQuery, oclTrain, matches, 2);
oclMatcher.knnMatchDownload(oclTrainIdx, oclDistance, matches); oclMatcher.knnMatchDownload(oclTrainIdx, oclDistance, matches);
...@@ -130,22 +130,22 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch, ...@@ -130,22 +130,22 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch,
OCL_PERF_ELSE OCL_PERF_ELSE
} }
PERF_TEST_P(BruteForceMatcherFixture, radiusMatch, OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch,
OCL_BFMATCHER_TYPICAL_MAT_SIZES) ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_PERF_ENUM(MatType(CV_32FC1))))
{ {
const Size srcSize = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
const float max_distance = 2.0f; const float max_distance = 2.0f;
vector<vector<DMatch> > matches(2); vector<vector<DMatch> > matches(2);
Mat query(srcSize, CV_32F), train(srcSize, CV_32F); Mat query(srcSize, type), train(srcSize, type);
declare.in(query, train); declare.in(query, train);
randu(query, 0.0f, 1.0f); randu(query, 0.0f, 1.0f);
randu(train, 0.0f, 1.0f); randu(train, 0.0f, 1.0f);
if (srcSize.height == 2000)
declare.time(9.15);
if (RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
cv::BFMatcher matcher(NORM_L2); cv::BFMatcher matcher(NORM_L2);
...@@ -162,7 +162,7 @@ PERF_TEST_P(BruteForceMatcherFixture, radiusMatch, ...@@ -162,7 +162,7 @@ PERF_TEST_P(BruteForceMatcherFixture, radiusMatch,
ocl::oclMat oclTrainIdx, oclDistance, oclNMatches; ocl::oclMat oclTrainIdx, oclDistance, oclNMatches;
OCL_TEST_CYCLE() OCL_TEST_CYCLE()
oclMatcher.radiusMatchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance, oclNMatches, max_distance); oclMatcher.radiusMatch(oclQuery, oclTrain, matches, max_distance);
oclMatcher.radiusMatchDownload(oclTrainIdx, oclDistance, oclNMatches, matches); oclMatcher.radiusMatchDownload(oclTrainIdx, oclDistance, oclNMatches, matches);
...@@ -173,5 +173,3 @@ PERF_TEST_P(BruteForceMatcherFixture, radiusMatch, ...@@ -173,5 +173,3 @@ PERF_TEST_P(BruteForceMatcherFixture, radiusMatch,
else else
OCL_PERF_ELSE OCL_PERF_ELSE
} }
#undef OCL_BFMATCHER_TYPICAL_MAT_SIZES
...@@ -46,11 +46,21 @@ ...@@ -46,11 +46,21 @@
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
using namespace perf; using namespace perf;
using std::tr1::tuple;
using std::tr1::get;
///////////// Canny //////////////////////// ///////////// Canny ////////////////////////
PERF_TEST(CannyFixture, Canny) typedef tuple<int, bool> CannyParams;
typedef TestBaseWithParam<CannyParams> CannyFixture;
OCL_PERF_TEST_P(CannyFixture, Canny,
::testing::Combine(OCL_PERF_ENUM(3, 5), testing::Bool()))
{ {
const CannyParams params = GetParam();
int apertureSize = get<0>(params);
bool L2Grad = get<1>(params);
Mat img = imread(getDataPath("gpu/stereobm/aloe-L.png"), cv::IMREAD_GRAYSCALE), Mat img = imread(getDataPath("gpu/stereobm/aloe-L.png"), cv::IMREAD_GRAYSCALE),
edges(img.size(), CV_8UC1); edges(img.size(), CV_8UC1);
ASSERT_TRUE(!img.empty()) << "can't open aloe-L.png"; ASSERT_TRUE(!img.empty()) << "can't open aloe-L.png";
...@@ -61,16 +71,15 @@ PERF_TEST(CannyFixture, Canny) ...@@ -61,16 +71,15 @@ PERF_TEST(CannyFixture, Canny)
{ {
ocl::oclMat oclImg(img), oclEdges(img.size(), CV_8UC1); ocl::oclMat oclImg(img), oclEdges(img.size(), CV_8UC1);
OCL_TEST_CYCLE() ocl::Canny(oclImg, oclEdges, 50.0, 100.0); OCL_TEST_CYCLE() ocl::Canny(oclImg, oclEdges, 50.0, 100.0, apertureSize, L2Grad);
oclEdges.download(edges); oclEdges.download(edges);
} }
else if (RUN_PLAIN_IMPL) else if (RUN_PLAIN_IMPL)
{ {
TEST_CYCLE() Canny(img, edges, 50.0, 100.0); TEST_CYCLE() Canny(img, edges, 50.0, 100.0, apertureSize, L2Grad);
} }
else else
OCL_PERF_ELSE OCL_PERF_ELSE
int value = 0; SANITY_CHECK_NOTHING();
SANITY_CHECK(value);
} }
...@@ -52,36 +52,36 @@ using std::tr1::make_tuple; ...@@ -52,36 +52,36 @@ using std::tr1::make_tuple;
///////////// cvtColor//////////////////////// ///////////// cvtColor////////////////////////
CV_ENUM(ConversionTypes, CV_RGB2GRAY, CV_RGB2BGR, CV_RGB2YUV, CV_YUV2RGB, CV_RGB2YCrCb, CV_ENUM(ConversionTypes, COLOR_RGB2GRAY, COLOR_RGB2BGR, COLOR_RGB2YUV, COLOR_YUV2RGB, COLOR_RGB2YCrCb,
CV_YCrCb2RGB, CV_RGB2XYZ, CV_XYZ2RGB, CV_RGB2HSV, CV_HSV2RGB, CV_RGB2HLS, COLOR_YCrCb2RGB, COLOR_RGB2XYZ, COLOR_XYZ2RGB, COLOR_RGB2HSV, COLOR_HSV2RGB, COLOR_RGB2HLS,
CV_HLS2RGB, CV_BGR5652BGR, CV_BGR2BGR565, CV_RGBA2mRGBA, CV_mRGBA2RGBA, CV_YUV2RGB_NV12) COLOR_HLS2RGB, COLOR_BGR5652BGR, COLOR_BGR2BGR565, COLOR_RGBA2mRGBA, COLOR_mRGBA2RGBA, COLOR_YUV2RGB_NV12)
typedef tuple<Size, tuple<ConversionTypes, int, int> > cvtColorParams; typedef tuple<Size, tuple<ConversionTypes, int, int> > CvtColorParams;
typedef TestBaseWithParam<cvtColorParams> cvtColorFixture; typedef TestBaseWithParam<CvtColorParams> CvtColorFixture;
PERF_TEST_P(cvtColorFixture, cvtColor, testing::Combine( OCL_PERF_TEST_P(CvtColorFixture, CvtColor, testing::Combine(
testing::Values(Size(1000, 1002), Size(2000, 2004), Size(4000, 4008)), OCL_TEST_SIZES,
testing::Values( testing::Values(
make_tuple(ConversionTypes(CV_RGB2GRAY), 3, 1), make_tuple(ConversionTypes(COLOR_RGB2GRAY), 3, 1),
make_tuple(ConversionTypes(CV_RGB2BGR), 3, 3), make_tuple(ConversionTypes(COLOR_RGB2BGR), 3, 3),
make_tuple(ConversionTypes(CV_RGB2YUV), 3, 3), make_tuple(ConversionTypes(COLOR_RGB2YUV), 3, 3),
make_tuple(ConversionTypes(CV_YUV2RGB), 3, 3), make_tuple(ConversionTypes(COLOR_YUV2RGB), 3, 3),
make_tuple(ConversionTypes(CV_RGB2YCrCb), 3, 3), make_tuple(ConversionTypes(COLOR_RGB2YCrCb), 3, 3),
make_tuple(ConversionTypes(CV_YCrCb2RGB), 3, 3), make_tuple(ConversionTypes(COLOR_YCrCb2RGB), 3, 3),
make_tuple(ConversionTypes(CV_RGB2XYZ), 3, 3), make_tuple(ConversionTypes(COLOR_RGB2XYZ), 3, 3),
make_tuple(ConversionTypes(CV_XYZ2RGB), 3, 3), make_tuple(ConversionTypes(COLOR_XYZ2RGB), 3, 3),
make_tuple(ConversionTypes(CV_RGB2HSV), 3, 3), make_tuple(ConversionTypes(COLOR_RGB2HSV), 3, 3),
make_tuple(ConversionTypes(CV_HSV2RGB), 3, 3), make_tuple(ConversionTypes(COLOR_HSV2RGB), 3, 3),
make_tuple(ConversionTypes(CV_RGB2HLS), 3, 3), make_tuple(ConversionTypes(COLOR_RGB2HLS), 3, 3),
make_tuple(ConversionTypes(CV_HLS2RGB), 3, 3), make_tuple(ConversionTypes(COLOR_HLS2RGB), 3, 3),
make_tuple(ConversionTypes(CV_BGR5652BGR), 2, 3), make_tuple(ConversionTypes(COLOR_BGR5652BGR), 2, 3),
make_tuple(ConversionTypes(CV_BGR2BGR565), 3, 2), make_tuple(ConversionTypes(COLOR_BGR2BGR565), 3, 2),
make_tuple(ConversionTypes(CV_RGBA2mRGBA), 4, 4), make_tuple(ConversionTypes(COLOR_RGBA2mRGBA), 4, 4),
make_tuple(ConversionTypes(CV_mRGBA2RGBA), 4, 4), make_tuple(ConversionTypes(COLOR_mRGBA2RGBA), 4, 4),
make_tuple(ConversionTypes(CV_YUV2RGB_NV12), 1, 3) make_tuple(ConversionTypes(COLOR_YUV2RGB_NV12), 1, 3)
))) )))
{ {
cvtColorParams params = GetParam(); CvtColorParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const tuple<int, int, int> conversionParams = get<1>(params); const tuple<int, int, int> conversionParams = get<1>(params);
const int code = get<0>(conversionParams), scn = get<1>(conversionParams), const int code = get<0>(conversionParams), scn = get<1>(conversionParams),
......
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
using namespace perf; using namespace perf;
using std::tr1::tuple;
using std::tr1::get;
///////////// dft //////////////////////// ///////////// dft ////////////////////////
...@@ -54,22 +56,26 @@ typedef TestBaseWithParam<Size> dftFixture; ...@@ -54,22 +56,26 @@ typedef TestBaseWithParam<Size> dftFixture;
#ifdef HAVE_CLAMDFFT #ifdef HAVE_CLAMDFFT
PERF_TEST_P(dftFixture, dft, OCL_TYPICAL_MAT_SIZES) typedef tuple<Size, int> DftParams;
typedef TestBaseWithParam<DftParams> DftFixture;
OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(testing::Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
::testing::Values((int)DFT_ROWS, (int)DFT_SCALE, (int)DFT_INVERSE,
(int)DFT_INVERSE | DFT_SCALE, (int)DFT_ROWS | DFT_INVERSE)))
{ {
const Size srcSize = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int flags = get<1>(params);
Mat src(srcSize, CV_32FC2), dst; Mat src(srcSize, CV_32FC2), dst;
randu(src, 0.0f, 1.0f); randu(src, 0.0f, 1.0f);
declare.in(src); declare.in(src);
if (srcSize == OCL_SIZE_4000)
declare.time(7.4);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
ocl::oclMat oclSrc(src), oclDst; ocl::oclMat oclSrc(src), oclDst;
OCL_TEST_CYCLE() cv::ocl::dft(oclSrc, oclDst); OCL_TEST_CYCLE() cv::ocl::dft(oclSrc, oclDst, Size(), flags | DFT_COMPLEX_OUTPUT);
oclDst.download(dst); oclDst.download(dst);
...@@ -77,7 +83,7 @@ PERF_TEST_P(dftFixture, dft, OCL_TYPICAL_MAT_SIZES) ...@@ -77,7 +83,7 @@ PERF_TEST_P(dftFixture, dft, OCL_TYPICAL_MAT_SIZES)
} }
else if (RUN_PLAIN_IMPL) else if (RUN_PLAIN_IMPL)
{ {
TEST_CYCLE() cv::dft(src, dst); TEST_CYCLE() cv::dft(src, dst, flags | DFT_COMPLEX_OUTPUT);
SANITY_CHECK(dst); SANITY_CHECK(dst);
} }
......
This diff is collapsed.
...@@ -46,30 +46,39 @@ ...@@ -46,30 +46,39 @@
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
using namespace perf; using namespace perf;
using std::tr1::get;
using std::tr1::tuple;
///////////// gemm //////////////////////// ///////////// gemm ////////////////////////
typedef TestBaseWithParam<Size> gemmFixture;
#ifdef HAVE_CLAMDBLAS #ifdef HAVE_CLAMDBLAS
PERF_TEST_P(gemmFixture, gemm, ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000)) typedef tuple<Size, int> GemmParams;
typedef TestBaseWithParam<GemmParams> GemmFixture;
OCL_PERF_TEST_P(GemmFixture, Gemm, ::testing::Combine(
::testing::Values(Size(1000, 1000), Size(1500, 1500)),
::testing::Values((int)cv::GEMM_1_T, (int)cv::GEMM_1_T | (int)cv::GEMM_2_T)))
{ {
const Size srcSize = GetParam(); const GemmParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1), Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1),
src3(srcSize, CV_32FC1), dst(srcSize, CV_32FC1); src3(srcSize, CV_32FC1), dst(srcSize, CV_32FC1);
declare.in(src1, src2, src3).out(dst).time(srcSize == OCL_SIZE_2000 ? 65 : 8);
randu(src1, -10.0f, 10.0f); randu(src1, -10.0f, 10.0f);
randu(src2, -10.0f, 10.0f); randu(src2, -10.0f, 10.0f);
randu(src3, -10.0f, 10.0f); randu(src3, -10.0f, 10.0f);
declare.in(src1, src2, src3).out(dst);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
ocl::oclMat oclSrc1(src1), oclSrc2(src2), ocl::oclMat oclSrc1(src1), oclSrc2(src2),
oclSrc3(src3), oclDst(srcSize, CV_32FC1); oclSrc3(src3), oclDst(srcSize, CV_32FC1);
OCL_TEST_CYCLE() cv::ocl::gemm(oclSrc1, oclSrc2, 1.0, oclSrc3, 1.0, oclDst); OCL_TEST_CYCLE() cv::ocl::gemm(oclSrc1, oclSrc2, 1.0, oclSrc3, 1.0, oclDst, type);
oclDst.download(dst); oclDst.download(dst);
...@@ -77,7 +86,7 @@ PERF_TEST_P(gemmFixture, gemm, ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000)) ...@@ -77,7 +86,7 @@ PERF_TEST_P(gemmFixture, gemm, ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000))
} }
else if (RUN_PLAIN_IMPL) else if (RUN_PLAIN_IMPL)
{ {
TEST_CYCLE() cv::gemm(src1, src2, 1.0, src3, 1.0, dst); TEST_CYCLE() cv::gemm(src1, src2, 1.0, src3, 1.0, dst, type);
SANITY_CHECK(dst, 0.01); SANITY_CHECK(dst, 0.01);
} }
......
...@@ -52,22 +52,21 @@ using std::tr1::get; ...@@ -52,22 +52,21 @@ using std::tr1::get;
///////////// GoodFeaturesToTrack //////////////////////// ///////////// GoodFeaturesToTrack ////////////////////////
typedef tuple<string, double> GoodFeaturesToTrackParams; typedef tuple<String, double, bool> GoodFeaturesToTrackParams;
typedef TestBaseWithParam<GoodFeaturesToTrackParams> GoodFeaturesToTrackFixture; typedef TestBaseWithParam<GoodFeaturesToTrackParams> GoodFeaturesToTrackFixture;
PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack, OCL_PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack,
::testing::Combine(::testing::Values(string("gpu/opticalflow/rubberwhale1.png"), ::testing::Combine(OCL_PERF_ENUM(String("gpu/opticalflow/rubberwhale1.png")),
string("gpu/stereobm/aloe-L.png")), OCL_PERF_ENUM(0.0, 3.0), testing::Bool()))
::testing::Range(0.0, 4.0, 3.0)))
{ {
const GoodFeaturesToTrackParams params = GetParam();
const String fileName = get<0>(params);
const double minDistance = get<1>(params), qualityLevel = 0.01;
const bool harrisDetector = get<2>(params);
const int maxCorners = 1000;
const GoodFeaturesToTrackParams param = GetParam(); Mat frame = imread(getDataPath(fileName), IMREAD_GRAYSCALE);
const string fileName = getDataPath(get<0>(param)); ASSERT_FALSE(frame.empty()) << "no input image";
const int maxCorners = 2000;
const double qualityLevel = 0.01, minDistance = get<1>(param);
Mat frame = imread(fileName, IMREAD_GRAYSCALE);
ASSERT_TRUE(!frame.empty()) << "no input image";
vector<Point2f> pts_gold; vector<Point2f> pts_gold;
declare.in(frame); declare.in(frame);
...@@ -75,7 +74,8 @@ PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack, ...@@ -75,7 +74,8 @@ PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack,
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
ocl::oclMat oclFrame(frame), pts_oclmat; ocl::oclMat oclFrame(frame), pts_oclmat;
ocl::GoodFeaturesToTrackDetector_OCL detector(maxCorners, qualityLevel, minDistance); ocl::GoodFeaturesToTrackDetector_OCL detector(maxCorners, qualityLevel, minDistance, 3,
harrisDetector);
OCL_TEST_CYCLE() detector(oclFrame, pts_oclmat); OCL_TEST_CYCLE() detector(oclFrame, pts_oclmat);
...@@ -86,7 +86,7 @@ PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack, ...@@ -86,7 +86,7 @@ PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack,
else if (RUN_PLAIN_IMPL) else if (RUN_PLAIN_IMPL)
{ {
TEST_CYCLE() cv::goodFeaturesToTrack(frame, pts_gold, TEST_CYCLE() cv::goodFeaturesToTrack(frame, pts_gold,
maxCorners, qualityLevel, minDistance); maxCorners, qualityLevel, minDistance, noArray(), 3, harrisDetector);
SANITY_CHECK(pts_gold); SANITY_CHECK(pts_gold);
} }
......
...@@ -46,8 +46,13 @@ ...@@ -46,8 +46,13 @@
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
using namespace perf; using namespace perf;
using namespace std;
using namespace cv;
using std::tr1::make_tuple;
using std::tr1::get;
///////////// Haar //////////////////////// ///////////// Haar ////////////////////////
PERF_TEST(HaarFixture, Haar) PERF_TEST(HaarFixture, Haar)
{ {
vector<Rect> faces; vector<Rect> faces;
...@@ -84,23 +89,16 @@ PERF_TEST(HaarFixture, Haar) ...@@ -84,23 +89,16 @@ PERF_TEST(HaarFixture, Haar)
OCL_PERF_ELSE OCL_PERF_ELSE
} }
using namespace std; typedef std::tr1::tuple<std::string, std::string, int> Cascade_Image_MinSize_t;
using namespace cv; typedef perf::TestBaseWithParam<Cascade_Image_MinSize_t> Cascade_Image_MinSize;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
typedef std::tr1::tuple<std::string, std::string, int> OCL_Cascade_Image_MinSize_t;
typedef perf::TestBaseWithParam<OCL_Cascade_Image_MinSize_t> OCL_Cascade_Image_MinSize;
PERF_TEST_P( OCL_Cascade_Image_MinSize, CascadeClassifier, OCL_PERF_TEST_P(Cascade_Image_MinSize, DISABLED_CascadeClassifier,
testing::Combine( testing::Combine(testing::Values( string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt.xml"),
testing::Values( string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt.xml"),
string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt2.xml") ), string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt2.xml") ),
testing::Values( string("cv/shared/lena.png"), testing::Values(string("cv/shared/lena.png"),
string("cv/cascadeandhog/images/bttf301.png")/*, string("cv/cascadeandhog/images/bttf301.png")/*,
string("cv/cascadeandhog/images/class57.png")*/ ), string("cv/cascadeandhog/images/class57.png")*/ ),
testing::Values(30, 64, 90) ) ) testing::Values(30, 64, 90)))
{ {
const string cascasePath = get<0>(GetParam()); const string cascasePath = get<0>(GetParam());
const string imagePath = get<1>(GetParam()); const string imagePath = get<1>(GetParam());
...@@ -109,7 +107,7 @@ PERF_TEST_P( OCL_Cascade_Image_MinSize, CascadeClassifier, ...@@ -109,7 +107,7 @@ PERF_TEST_P( OCL_Cascade_Image_MinSize, CascadeClassifier,
vector<Rect> faces; vector<Rect> faces;
Mat img = imread(getDataPath(imagePath), IMREAD_GRAYSCALE); Mat img = imread(getDataPath(imagePath), IMREAD_GRAYSCALE);
ASSERT_TRUE(!img.empty()) << "Can't load source image: " << getDataPath(imagePath); ASSERT_FALSE(img.empty()) << "Can't load source image: " << getDataPath(imagePath);
equalizeHist(img, img); equalizeHist(img, img);
declare.in(img); declare.in(img);
......
...@@ -43,7 +43,9 @@ ...@@ -43,7 +43,9 @@
// the use of this software, even if advised of the possibility of such damage. // the use of this software, even if advised of the possibility of such damage.
// //
//M*/ //M*/
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
#include <functional>
using namespace perf; using namespace perf;
...@@ -66,13 +68,13 @@ struct RectLess : ...@@ -66,13 +68,13 @@ struct RectLess :
} }
}; };
PERF_TEST(HOGFixture, HOG) OCL_PERF_TEST(HOGFixture, HOG)
{ {
Mat src = imread(getDataPath("gpu/hog/road.png"), cv::IMREAD_GRAYSCALE); Mat src = imread(getDataPath("gpu/hog/road.png"), cv::IMREAD_GRAYSCALE);
ASSERT_TRUE(!src.empty()) << "can't open input image road.png"; ASSERT_TRUE(!src.empty()) << "can't open input image road.png";
vector<cv::Rect> found_locations; vector<cv::Rect> found_locations;
declare.in(src).time(5); declare.in(src);
if (RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
......
...@@ -51,9 +51,9 @@ using std::tr1::get; ...@@ -51,9 +51,9 @@ using std::tr1::get;
///////////// equalizeHist //////////////////////// ///////////// equalizeHist ////////////////////////
typedef TestBaseWithParam<Size> equalizeHistFixture; typedef TestBaseWithParam<Size> EqualizeHistFixture;
PERF_TEST_P(equalizeHistFixture, equalizeHist, OCL_TYPICAL_MAT_SIZES) OCL_PERF_TEST_P(EqualizeHistFixture, EqualizeHist, OCL_TEST_SIZES)
{ {
const Size srcSize = GetParam(); const Size srcSize = GetParam();
const double eps = 1 + DBL_EPSILON; const double eps = 1 + DBL_EPSILON;
...@@ -83,16 +83,13 @@ PERF_TEST_P(equalizeHistFixture, equalizeHist, OCL_TYPICAL_MAT_SIZES) ...@@ -83,16 +83,13 @@ PERF_TEST_P(equalizeHistFixture, equalizeHist, OCL_TYPICAL_MAT_SIZES)
/////////// CopyMakeBorder ////////////////////// /////////// CopyMakeBorder //////////////////////
CV_ENUM(Border, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, CV_ENUM(Border, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_WRAP, BORDER_REFLECT_101)
BORDER_WRAP, BORDER_REFLECT_101)
typedef tuple<Size, MatType, Border> CopyMakeBorderParamType; typedef tuple<Size, MatType, Border> CopyMakeBorderParamType;
typedef TestBaseWithParam<CopyMakeBorderParamType> CopyMakeBorderFixture; typedef TestBaseWithParam<CopyMakeBorderParamType> CopyMakeBorderFixture;
PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder, OCL_PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder,
::testing::Combine(OCL_TYPICAL_MAT_SIZES, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, Border::all()))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4),
Border::all()))
{ {
const CopyMakeBorderParamType params = GetParam(); const CopyMakeBorderParamType params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
...@@ -125,11 +122,10 @@ PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder, ...@@ -125,11 +122,10 @@ PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder,
///////////// cornerMinEigenVal //////////////////////// ///////////// cornerMinEigenVal ////////////////////////
typedef Size_MatType cornerMinEigenValFixture; typedef Size_MatType CornerMinEigenValFixture;
PERF_TEST_P(cornerMinEigenValFixture, cornerMinEigenVal, OCL_PERF_TEST_P(CornerMinEigenValFixture, CornerMinEigenVal,
::testing::Combine(OCL_TYPICAL_MAT_SIZES, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{ {
const Size_MatType_t params = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
...@@ -137,8 +133,7 @@ PERF_TEST_P(cornerMinEigenValFixture, cornerMinEigenVal, ...@@ -137,8 +133,7 @@ PERF_TEST_P(cornerMinEigenValFixture, cornerMinEigenVal,
const int blockSize = 7, apertureSize = 1 + 2 * 3; const int blockSize = 7, apertureSize = 1 + 2 * 3;
Mat src(srcSize, type), dst(srcSize, CV_32FC1); Mat src(srcSize, type), dst(srcSize, CV_32FC1);
declare.in(src, WARMUP_RNG).out(dst) declare.in(src, WARMUP_RNG).out(dst);
.time(srcSize == OCL_SIZE_4000 ? 20 : srcSize == OCL_SIZE_2000 ? 5 : 3);
const int depth = CV_MAT_DEPTH(type); const int depth = CV_MAT_DEPTH(type);
const ERROR_TYPE errorType = depth == CV_8U ? ERROR_ABSOLUTE : ERROR_RELATIVE; const ERROR_TYPE errorType = depth == CV_8U ? ERROR_ABSOLUTE : ERROR_RELATIVE;
...@@ -165,11 +160,10 @@ PERF_TEST_P(cornerMinEigenValFixture, cornerMinEigenVal, ...@@ -165,11 +160,10 @@ PERF_TEST_P(cornerMinEigenValFixture, cornerMinEigenVal,
///////////// cornerHarris //////////////////////// ///////////// cornerHarris ////////////////////////
typedef Size_MatType cornerHarrisFixture; typedef Size_MatType CornerHarrisFixture;
PERF_TEST_P(cornerHarrisFixture, cornerHarris, OCL_PERF_TEST_P(CornerHarrisFixture, CornerHarris,
::testing::Combine(OCL_TYPICAL_MAT_SIZES, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{ {
const Size_MatType_t params = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
...@@ -177,8 +171,7 @@ PERF_TEST_P(cornerHarrisFixture, cornerHarris, ...@@ -177,8 +171,7 @@ PERF_TEST_P(cornerHarrisFixture, cornerHarris,
Mat src(srcSize, type), dst(srcSize, CV_32FC1); Mat src(srcSize, type), dst(srcSize, CV_32FC1);
randu(src, 0, 1); randu(src, 0, 1);
declare.in(src).out(dst) declare.in(src).out(dst);
.time(srcSize == OCL_SIZE_4000 ? 20 : srcSize == OCL_SIZE_2000 ? 5 : 3);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
...@@ -202,11 +195,14 @@ PERF_TEST_P(cornerHarrisFixture, cornerHarris, ...@@ -202,11 +195,14 @@ PERF_TEST_P(cornerHarrisFixture, cornerHarris,
///////////// integral //////////////////////// ///////////// integral ////////////////////////
typedef TestBaseWithParam<Size> integralFixture; typedef tuple<Size, MatDepth> IntegralParams;
typedef TestBaseWithParam<IntegralParams> IntegralFixture;
PERF_TEST_P(integralFixture, integral, OCL_TYPICAL_MAT_SIZES) OCL_PERF_TEST_P(IntegralFixture, Integral1, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32S, CV_32F)))
{ {
const Size srcSize = GetParam(); const IntegralParams params = GetParam();
const Size srcSize = get<0>(params);
const int sdepth = get<1>(params);
Mat src(srcSize, CV_8UC1), dst; Mat src(srcSize, CV_8UC1), dst;
declare.in(src, WARMUP_RNG); declare.in(src, WARMUP_RNG);
...@@ -215,17 +211,17 @@ PERF_TEST_P(integralFixture, integral, OCL_TYPICAL_MAT_SIZES) ...@@ -215,17 +211,17 @@ PERF_TEST_P(integralFixture, integral, OCL_TYPICAL_MAT_SIZES)
{ {
ocl::oclMat oclSrc(src), oclDst; ocl::oclMat oclSrc(src), oclDst;
OCL_TEST_CYCLE() cv::ocl::integral(oclSrc, oclDst); OCL_TEST_CYCLE() cv::ocl::integral(oclSrc, oclDst, sdepth);
oclDst.download(dst); oclDst.download(dst);
SANITY_CHECK(dst); SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
} }
else if (RUN_PLAIN_IMPL) else if (RUN_PLAIN_IMPL)
{ {
TEST_CYCLE() cv::integral(src, dst); TEST_CYCLE() cv::integral(src, dst, sdepth);
SANITY_CHECK(dst); SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
} }
else else
OCL_PERF_ELSE OCL_PERF_ELSE
...@@ -233,15 +229,13 @@ PERF_TEST_P(integralFixture, integral, OCL_TYPICAL_MAT_SIZES) ...@@ -233,15 +229,13 @@ PERF_TEST_P(integralFixture, integral, OCL_TYPICAL_MAT_SIZES)
///////////// threshold//////////////////////// ///////////// threshold////////////////////////
CV_ENUM(ThreshType, THRESH_BINARY, THRESH_TOZERO_INV) CV_ENUM(ThreshType, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO_INV)
typedef tuple<Size, MatType, ThreshType> ThreshParams; typedef tuple<Size, MatType, ThreshType> ThreshParams;
typedef TestBaseWithParam<ThreshParams> ThreshFixture; typedef TestBaseWithParam<ThreshParams> ThreshFixture;
PERF_TEST_P(ThreshFixture, threshold, OCL_PERF_TEST_P(ThreshFixture, Threshold,
::testing::Combine(OCL_TYPICAL_MAT_SIZES, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, ThreshType::all()))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC4, CV_32FC1),
ThreshType::all()))
{ {
const ThreshParams params = GetParam(); const ThreshParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
...@@ -463,9 +457,9 @@ static void meanShiftFiltering_(const Mat &src_roi, Mat &dst_roi, int sp, int sr ...@@ -463,9 +457,9 @@ static void meanShiftFiltering_(const Mat &src_roi, Mat &dst_roi, int sp, int sr
} }
} }
typedef TestBaseWithParam<Size> meanShiftFilteringFixture; typedef TestBaseWithParam<Size> MeanShiftFilteringFixture;
PERF_TEST_P(meanShiftFilteringFixture, meanShiftFiltering, PERF_TEST_P(MeanShiftFilteringFixture, MeanShiftFiltering,
OCL_TYPICAL_MAT_SIZES) OCL_TYPICAL_MAT_SIZES)
{ {
const Size srcSize = GetParam(); const Size srcSize = GetParam();
...@@ -473,9 +467,7 @@ PERF_TEST_P(meanShiftFilteringFixture, meanShiftFiltering, ...@@ -473,9 +467,7 @@ PERF_TEST_P(meanShiftFilteringFixture, meanShiftFiltering,
cv::TermCriteria crit(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 5, 1); cv::TermCriteria crit(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 5, 1);
Mat src(srcSize, CV_8UC4), dst(srcSize, CV_8UC4); Mat src(srcSize, CV_8UC4), dst(srcSize, CV_8UC4);
declare.in(src, WARMUP_RNG).out(dst) declare.in(src, WARMUP_RNG).out(dst);
.time(srcSize == OCL_SIZE_4000 ?
56 : srcSize == OCL_SIZE_2000 ? 15 : 3.8);
if (RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
...@@ -556,9 +548,9 @@ static void meanShiftProc_(const Mat &src_roi, Mat &dst_roi, Mat &dstCoor_roi, i ...@@ -556,9 +548,9 @@ static void meanShiftProc_(const Mat &src_roi, Mat &dst_roi, Mat &dstCoor_roi, i
} }
typedef TestBaseWithParam<Size> meanShiftProcFixture; typedef TestBaseWithParam<Size> MeanShiftProcFixture;
PERF_TEST_P(meanShiftProcFixture, meanShiftProc, PERF_TEST_P(MeanShiftProcFixture, MeanShiftProc,
OCL_TYPICAL_MAT_SIZES) OCL_TYPICAL_MAT_SIZES)
{ {
const Size srcSize = GetParam(); const Size srcSize = GetParam();
...@@ -566,9 +558,7 @@ PERF_TEST_P(meanShiftProcFixture, meanShiftProc, ...@@ -566,9 +558,7 @@ PERF_TEST_P(meanShiftProcFixture, meanShiftProc,
Mat src(srcSize, CV_8UC4), dst1(srcSize, CV_8UC4), Mat src(srcSize, CV_8UC4), dst1(srcSize, CV_8UC4),
dst2(srcSize, CV_16SC2); dst2(srcSize, CV_16SC2);
declare.in(src, WARMUP_RNG).out(dst1, dst2) declare.in(src, WARMUP_RNG).out(dst1, dst2);
.time(srcSize == OCL_SIZE_4000 ?
56 : srcSize == OCL_SIZE_2000 ? 15 : 3.8);;
if (RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
...@@ -598,7 +588,7 @@ PERF_TEST_P(meanShiftProcFixture, meanShiftProc, ...@@ -598,7 +588,7 @@ PERF_TEST_P(meanShiftProcFixture, meanShiftProc,
typedef TestBaseWithParam<Size> CLAHEFixture; typedef TestBaseWithParam<Size> CLAHEFixture;
PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TYPICAL_MAT_SIZES) OCL_PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TEST_SIZES)
{ {
const Size srcSize = GetParam(); const Size srcSize = GetParam();
const string impl = getSelectedImpl(); const string impl = getSelectedImpl();
...@@ -607,9 +597,6 @@ PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TYPICAL_MAT_SIZES) ...@@ -607,9 +597,6 @@ PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TYPICAL_MAT_SIZES)
const double clipLimit = 40.0; const double clipLimit = 40.0;
declare.in(src, WARMUP_RNG); declare.in(src, WARMUP_RNG);
if (srcSize == OCL_SIZE_4000)
declare.time(11);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
ocl::oclMat oclSrc(src), oclDst; ocl::oclMat oclSrc(src), oclDst;
...@@ -632,9 +619,9 @@ PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TYPICAL_MAT_SIZES) ...@@ -632,9 +619,9 @@ PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TYPICAL_MAT_SIZES)
OCL_PERF_ELSE OCL_PERF_ELSE
} }
///////////// columnSum//////////////////////// ///////////// ColumnSum////////////////////////
typedef TestBaseWithParam<Size> columnSumFixture; typedef TestBaseWithParam<Size> ColumnSumFixture;
static void columnSumPerfTest(const Mat & src, Mat & dst) static void columnSumPerfTest(const Mat & src, Mat & dst)
{ {
...@@ -646,16 +633,13 @@ static void columnSumPerfTest(const Mat & src, Mat & dst) ...@@ -646,16 +633,13 @@ static void columnSumPerfTest(const Mat & src, Mat & dst)
dst.at<float>(i, j) = dst.at<float>(i - 1 , j) + src.at<float>(i , j); dst.at<float>(i, j) = dst.at<float>(i - 1 , j) + src.at<float>(i , j);
} }
PERF_TEST_P(columnSumFixture, columnSum, OCL_TYPICAL_MAT_SIZES) PERF_TEST_P(ColumnSumFixture, ColumnSum, OCL_TYPICAL_MAT_SIZES)
{ {
const Size srcSize = GetParam(); const Size srcSize = GetParam();
Mat src(srcSize, CV_32FC1), dst(srcSize, CV_32FC1); Mat src(srcSize, CV_32FC1), dst(srcSize, CV_32FC1);
declare.in(src, WARMUP_RNG).out(dst); declare.in(src, WARMUP_RNG).out(dst);
if (srcSize == OCL_SIZE_4000)
declare.time(5);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
ocl::oclMat oclSrc(src), oclDst(srcSize, CV_32FC1); ocl::oclMat oclSrc(src), oclDst(srcSize, CV_32FC1);
...@@ -680,8 +664,8 @@ PERF_TEST_P(columnSumFixture, columnSum, OCL_TYPICAL_MAT_SIZES) ...@@ -680,8 +664,8 @@ PERF_TEST_P(columnSumFixture, columnSum, OCL_TYPICAL_MAT_SIZES)
CV_ENUM(DistType, NORM_L1, NORM_L2SQR) CV_ENUM(DistType, NORM_L1, NORM_L2SQR)
typedef tuple<Size, DistType> distanceToCentersParameters; typedef tuple<Size, DistType> DistanceToCentersParams;
typedef TestBaseWithParam<distanceToCentersParameters> distanceToCentersFixture; typedef TestBaseWithParam<DistanceToCentersParams> DistanceToCentersFixture;
static void distanceToCentersPerfTest(Mat& src, Mat& centers, Mat& dists, Mat& labels, int distType) static void distanceToCentersPerfTest(Mat& src, Mat& centers, Mat& dists, Mat& labels, int distType)
{ {
...@@ -706,10 +690,11 @@ static void distanceToCentersPerfTest(Mat& src, Mat& centers, Mat& dists, Mat& l ...@@ -706,10 +690,11 @@ static void distanceToCentersPerfTest(Mat& src, Mat& centers, Mat& dists, Mat& l
Mat(labels_v).copyTo(labels); Mat(labels_v).copyTo(labels);
} }
PERF_TEST_P(distanceToCentersFixture, distanceToCenters, ::testing::Combine(::testing::Values(cv::Size(256,256), cv::Size(512,512)), DistType::all()) ) PERF_TEST_P(DistanceToCentersFixture, DistanceToCenters, ::testing::Combine(::testing::Values(cv::Size(256,256), cv::Size(512,512)), DistType::all()) )
{ {
Size size = get<0>(GetParam()); const DistanceToCentersParams params = GetParam();
int distType = get<1>(GetParam()); Size size = get<0>(params);
int distType = get<1>(params);
Mat src(size, CV_32FC1), centers(size, CV_32FC1); Mat src(size, CV_32FC1), centers(size, CV_32FC1);
Mat dists(src.rows, 1, CV_32FC1), labels(src.rows, 1, CV_32SC1); Mat dists(src.rows, 1, CV_32FC1), labels(src.rows, 1, CV_32SC1);
......
...@@ -51,11 +51,13 @@ using std::tr1::get; ...@@ -51,11 +51,13 @@ using std::tr1::get;
///////////// WarpAffine //////////////////////// ///////////// WarpAffine ////////////////////////
typedef Size_MatType WarpAffineFixture; CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR)
PERF_TEST_P(WarpAffineFixture, WarpAffine, typedef tuple<Size, MatType, InterType> WarpAffineParams;
::testing::Combine(OCL_TYPICAL_MAT_SIZES, typedef TestBaseWithParam<WarpAffineParams> WarpAffineFixture;
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
OCL_PERF_TEST_P(WarpAffineFixture, WarpAffine,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134, InterType::all()))
{ {
static const double coeffs[2][3] = static const double coeffs[2][3] =
{ {
...@@ -63,11 +65,12 @@ PERF_TEST_P(WarpAffineFixture, WarpAffine, ...@@ -63,11 +65,12 @@ PERF_TEST_P(WarpAffineFixture, WarpAffine,
{ sin(CV_PI / 6), cos(CV_PI / 6), -100.0 } { sin(CV_PI / 6), cos(CV_PI / 6), -100.0 }
}; };
Mat M(2, 3, CV_64F, (void *)coeffs); Mat M(2, 3, CV_64F, (void *)coeffs);
const int interpolation = INTER_NEAREST;
const Size_MatType_t params = GetParam(); const WarpAffineParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int type = get<1>(params); const int type = get<1>(params), interpolation = get<2>(params);
checkDeviceMaxMemoryAllocSize(srcSize, type);
Mat src(srcSize, type), dst(srcSize, type); Mat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst); declare.in(src, WARMUP_RNG).out(dst);
...@@ -80,13 +83,13 @@ PERF_TEST_P(WarpAffineFixture, WarpAffine, ...@@ -80,13 +83,13 @@ PERF_TEST_P(WarpAffineFixture, WarpAffine,
oclDst.download(dst); oclDst.download(dst);
SANITY_CHECK(dst); SANITY_CHECK(dst, 5e-4);
} }
else if (RUN_PLAIN_IMPL) else if (RUN_PLAIN_IMPL)
{ {
TEST_CYCLE() cv::warpAffine(src, dst, M, srcSize, interpolation); TEST_CYCLE() cv::warpAffine(src, dst, M, srcSize, interpolation);
SANITY_CHECK(dst); SANITY_CHECK(dst, 5e-4);
} }
else else
OCL_PERF_ELSE OCL_PERF_ELSE
...@@ -94,11 +97,11 @@ PERF_TEST_P(WarpAffineFixture, WarpAffine, ...@@ -94,11 +97,11 @@ PERF_TEST_P(WarpAffineFixture, WarpAffine,
///////////// WarpPerspective //////////////////////// ///////////// WarpPerspective ////////////////////////
typedef Size_MatType WarpPerspectiveFixture; typedef WarpAffineParams WarpPerspectiveParams;
typedef TestBaseWithParam<WarpPerspectiveParams> WarpPerspectiveFixture;
PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective, OCL_PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective,
::testing::Combine(OCL_TYPICAL_MAT_SIZES, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134, InterType::all()))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
{ {
static const double coeffs[3][3] = static const double coeffs[3][3] =
{ {
...@@ -107,15 +110,15 @@ PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective, ...@@ -107,15 +110,15 @@ PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective,
{0.0, 0.0, 1.0} {0.0, 0.0, 1.0}
}; };
Mat M(3, 3, CV_64F, (void *)coeffs); Mat M(3, 3, CV_64F, (void *)coeffs);
const int interpolation = INTER_LINEAR;
const Size_MatType_t params = GetParam(); const WarpPerspectiveParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int type = get<1>(params); const int type = get<1>(params), interpolation = get<2>(params);
checkDeviceMaxMemoryAllocSize(srcSize, type);
Mat src(srcSize, type), dst(srcSize, type); Mat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst) declare.in(src, WARMUP_RNG).out(dst);
.time(srcSize == OCL_SIZE_4000 ? 18 : srcSize == OCL_SIZE_2000 ? 5 : 2);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
...@@ -125,32 +128,28 @@ PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective, ...@@ -125,32 +128,28 @@ PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective,
oclDst.download(dst); oclDst.download(dst);
SANITY_CHECK(dst); SANITY_CHECK(dst, 5e-4);
} }
else if (RUN_PLAIN_IMPL) else if (RUN_PLAIN_IMPL)
{ {
TEST_CYCLE() cv::warpPerspective(src, dst, M, srcSize, interpolation); TEST_CYCLE() cv::warpPerspective(src, dst, M, srcSize, interpolation);
SANITY_CHECK(dst); SANITY_CHECK(dst, 5e-4);
} }
else else
OCL_PERF_ELSE OCL_PERF_ELSE
} }
///////////// resize //////////////////////// ///////////// Resize ////////////////////////
CV_ENUM(resizeInterType, INTER_NEAREST, INTER_LINEAR) typedef tuple<Size, MatType, InterType, double> ResizeParams;
typedef TestBaseWithParam<ResizeParams> ResizeFixture;
typedef tuple<Size, MatType, resizeInterType, double> resizeParams; OCL_PERF_TEST_P(ResizeFixture, Resize,
typedef TestBaseWithParam<resizeParams> resizeFixture; ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134,
InterType::all(), ::testing::Values(0.5, 2.0)))
PERF_TEST_P(resizeFixture, resize,
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_8UC4),
resizeInterType::all(),
::testing::Values(0.5, 2.0)))
{ {
const resizeParams params = GetParam(); const ResizeParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int type = get<1>(params), interType = get<2>(params); const int type = get<1>(params), interType = get<2>(params);
double scale = get<3>(params); double scale = get<3>(params);
...@@ -162,8 +161,6 @@ PERF_TEST_P(resizeFixture, resize, ...@@ -162,8 +161,6 @@ PERF_TEST_P(resizeFixture, resize,
Mat src(srcSize, type), dst; Mat src(srcSize, type), dst;
dst.create(dstSize, type); dst.create(dstSize, type);
declare.in(src, WARMUP_RNG).out(dst); declare.in(src, WARMUP_RNG).out(dst);
if (interType == INTER_LINEAR && type == CV_8UC4 && OCL_SIZE_4000 == srcSize)
declare.time(11);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
...@@ -185,15 +182,13 @@ PERF_TEST_P(resizeFixture, resize, ...@@ -185,15 +182,13 @@ PERF_TEST_P(resizeFixture, resize,
OCL_PERF_ELSE OCL_PERF_ELSE
} }
typedef tuple<Size, MatType, double> resizeAreaParams; typedef tuple<Size, MatType, double> ResizeAreaParams;
typedef TestBaseWithParam<resizeAreaParams> resizeAreaFixture; typedef TestBaseWithParam<ResizeAreaParams> ResizeAreaFixture;
PERF_TEST_P(resizeAreaFixture, resize, OCL_PERF_TEST_P(ResizeAreaFixture, Resize,
::testing::Combine(OCL_TYPICAL_MAT_SIZES, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134, ::testing::Values(0.3, 0.5, 0.6)))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4),
::testing::Values(0.3, 0.5, 0.6)))
{ {
const resizeAreaParams params = GetParam(); const ResizeAreaParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int type = get<1>(params); const int type = get<1>(params);
double scale = get<2>(params); double scale = get<2>(params);
...@@ -225,28 +220,21 @@ PERF_TEST_P(resizeAreaFixture, resize, ...@@ -225,28 +220,21 @@ PERF_TEST_P(resizeAreaFixture, resize,
OCL_PERF_ELSE OCL_PERF_ELSE
} }
///////////// remap//////////////////////// ///////////// Remap ////////////////////////
CV_ENUM(RemapInterType, INTER_NEAREST, INTER_LINEAR)
typedef tuple<Size, MatType, RemapInterType> remapParams; typedef tuple<Size, MatType, InterType> RemapParams;
typedef TestBaseWithParam<remapParams> remapFixture; typedef TestBaseWithParam<RemapParams> RemapFixture;
PERF_TEST_P(remapFixture, remap, OCL_PERF_TEST_P(RemapFixture, Remap,
::testing::Combine(OCL_TYPICAL_MAT_SIZES, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, InterType::all()))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4),
RemapInterType::all()))
{ {
const remapParams params = GetParam(); const RemapParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int type = get<1>(params), interpolation = get<2>(params); const int type = get<1>(params), interpolation = get<2>(params);
Mat src(srcSize, type), dst(srcSize, type); Mat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst); declare.in(src, WARMUP_RNG).out(dst);
if (srcSize == OCL_SIZE_4000 && interpolation == INTER_LINEAR)
declare.time(9);
Mat xmap, ymap; Mat xmap, ymap;
xmap.create(srcSize, CV_32FC1); xmap.create(srcSize, CV_32FC1);
ymap.create(srcSize, CV_32FC1); ymap.create(srcSize, CV_32FC1);
...@@ -287,7 +275,7 @@ PERF_TEST_P(remapFixture, remap, ...@@ -287,7 +275,7 @@ PERF_TEST_P(remapFixture, remap,
} }
///////////// buildWarpPerspectiveMaps //////////////////////// ///////////// BuildWarpPerspectiveMaps ////////////////////////
static void buildWarpPerspectiveMaps(const Mat &M, bool inverse, Size dsize, Mat &xmap, Mat &ymap) static void buildWarpPerspectiveMaps(const Mat &M, bool inverse, Size dsize, Mat &xmap, Mat &ymap)
{ {
...@@ -323,9 +311,9 @@ static void buildWarpPerspectiveMaps(const Mat &M, bool inverse, Size dsize, Mat ...@@ -323,9 +311,9 @@ static void buildWarpPerspectiveMaps(const Mat &M, bool inverse, Size dsize, Mat
} }
} }
typedef TestBaseWithParam<Size> buildWarpPerspectiveMapsFixture; typedef TestBaseWithParam<Size> BuildWarpPerspectiveMapsFixture;
PERF_TEST_P(buildWarpPerspectiveMapsFixture, Inverse, OCL_TYPICAL_MAT_SIZES) PERF_TEST_P(BuildWarpPerspectiveMapsFixture, Inverse, OCL_TYPICAL_MAT_SIZES)
{ {
static const double coeffs[3][3] = static const double coeffs[3][3] =
{ {
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
#ifdef HAVE_CLAMDBLAS //#ifdef HAVE_CLAMDBLAS
using namespace perf; using namespace perf;
using namespace std; using namespace std;
...@@ -100,4 +100,4 @@ PERF_TEST_P(KalmanFilterFixture, KalmanFilter, ...@@ -100,4 +100,4 @@ PERF_TEST_P(KalmanFilterFixture, KalmanFilter,
SANITY_CHECK(statePre_); SANITY_CHECK(statePre_);
} }
#endif // HAVE_CLAMDBLAS //#endif // HAVE_CLAMDBLAS
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
// the use of this software, even if advised of the possibility of such damage. // the use of this software, even if advised of the possibility of such damage.
// //
//M*/ //M*/
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
using namespace perf; using namespace perf;
...@@ -53,8 +54,8 @@ using std::tr1::get; ...@@ -53,8 +54,8 @@ using std::tr1::get;
typedef Size_MatType CV_TM_CCORRFixture; typedef Size_MatType CV_TM_CCORRFixture;
PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate, OCL_PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate,
::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000), ::testing::Combine(::testing::Values(Size(1000, 1000), Size(2000, 2000)),
OCL_PERF_ENUM(CV_32FC1, CV_32FC4))) OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
{ {
const Size_MatType_t params = GetParam(); const Size_MatType_t params = GetParam();
...@@ -66,7 +67,7 @@ PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate, ...@@ -66,7 +67,7 @@ PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate,
Mat dst(dstSize, CV_32F); Mat dst(dstSize, CV_32F);
randu(src, 0.0f, 1.0f); randu(src, 0.0f, 1.0f);
randu(templ, 0.0f, 1.0f); randu(templ, 0.0f, 1.0f);
declare.time(srcSize == OCL_SIZE_2000 ? 20 : 6).in(src, templ).out(dst); declare.in(src, templ).out(dst);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
...@@ -90,15 +91,15 @@ PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate, ...@@ -90,15 +91,15 @@ PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate,
typedef TestBaseWithParam<Size> CV_TM_CCORR_NORMEDFixture; typedef TestBaseWithParam<Size> CV_TM_CCORR_NORMEDFixture;
PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate, OCL_TYPICAL_MAT_SIZES) OCL_PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate,
::testing::Values(Size(1000, 1000), Size(2000, 2000), Size(4000, 4000)))
{ {
const Size srcSize = GetParam(), templSize(5, 5); const Size srcSize = GetParam(), templSize(5, 5);
Mat src(srcSize, CV_8UC1), templ(templSize, CV_8UC1), dst; Mat src(srcSize, CV_8UC1), templ(templSize, CV_8UC1), dst;
const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1); const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1);
dst.create(dstSize, CV_8UC1); dst.create(dstSize, CV_8UC1);
declare.in(src, templ, WARMUP_RNG).out(dst) declare.in(src, templ, WARMUP_RNG).out(dst);
.time(srcSize == OCL_SIZE_2000 ? 10 : srcSize == OCL_SIZE_4000 ? 23 : 2);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
...@@ -125,7 +126,7 @@ CV_ENUM(MethodType, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_C ...@@ -125,7 +126,7 @@ CV_ENUM(MethodType, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_C
typedef std::tr1::tuple<Size, Size, MethodType> ImgSize_TmplSize_Method_t; typedef std::tr1::tuple<Size, Size, MethodType> ImgSize_TmplSize_Method_t;
typedef TestBaseWithParam<ImgSize_TmplSize_Method_t> ImgSize_TmplSize_Method; typedef TestBaseWithParam<ImgSize_TmplSize_Method_t> ImgSize_TmplSize_Method;
PERF_TEST_P(ImgSize_TmplSize_Method, MatchTemplate, OCL_PERF_TEST_P(ImgSize_TmplSize_Method, MatchTemplate,
::testing::Combine( ::testing::Combine(
testing::Values(szSmall128, cv::Size(320, 240), testing::Values(szSmall128, cv::Size(320, 240),
cv::Size(640, 480), cv::Size(800, 600), cv::Size(640, 480), cv::Size(800, 600),
......
...@@ -53,9 +53,7 @@ using std::tr1::get; ...@@ -53,9 +53,7 @@ using std::tr1::get;
typedef Size_MatType ConvertToFixture; typedef Size_MatType ConvertToFixture;
PERF_TEST_P(ConvertToFixture, ConvertTo, OCL_PERF_TEST_P(ConvertToFixture, ConvertTo, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
{ {
const Size_MatType_t params = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
...@@ -92,11 +90,9 @@ PERF_TEST_P(ConvertToFixture, ConvertTo, ...@@ -92,11 +90,9 @@ PERF_TEST_P(ConvertToFixture, ConvertTo,
///////////// copyTo//////////////////////// ///////////// copyTo////////////////////////
typedef Size_MatType copyToFixture; typedef Size_MatType CopyToFixture;
PERF_TEST_P(copyToFixture, copyTo, OCL_PERF_TEST_P(CopyToFixture, CopyTo, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
{ {
const Size_MatType_t params = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
...@@ -127,11 +123,9 @@ PERF_TEST_P(copyToFixture, copyTo, ...@@ -127,11 +123,9 @@ PERF_TEST_P(copyToFixture, copyTo,
///////////// setTo//////////////////////// ///////////// setTo////////////////////////
typedef Size_MatType setToFixture; typedef Size_MatType SetToFixture;
PERF_TEST_P(setToFixture, setTo, OCL_PERF_TEST_P(SetToFixture, SetTo, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
{ {
const Size_MatType_t params = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
...@@ -164,16 +158,16 @@ PERF_TEST_P(setToFixture, setTo, ...@@ -164,16 +158,16 @@ PERF_TEST_P(setToFixture, setTo,
/////////////////// upload /////////////////////////// /////////////////// upload ///////////////////////////
typedef tuple<Size, MatDepth, int> uploadParams; typedef tuple<Size, MatDepth, int> UploadParams;
typedef TestBaseWithParam<uploadParams> uploadFixture; typedef TestBaseWithParam<uploadParams> UploadFixture;
PERF_TEST_P(uploadFixture, upload, PERF_TEST_P(UploadFixture, Upload,
testing::Combine( testing::Combine(
OCL_TYPICAL_MAT_SIZES, OCL_TYPICAL_MAT_SIZES,
testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F), testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F),
testing::Range(1, 5))) testing::Range(1, 5)))
{ {
const uploadParams params = GetParam(); const UploadParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int depth = get<1>(params), cn = get<2>(params); const int depth = get<1>(params), cn = get<2>(params);
const int type = CV_MAKE_TYPE(depth, cn); const int type = CV_MAKE_TYPE(depth, cn);
...@@ -201,15 +195,15 @@ PERF_TEST_P(uploadFixture, upload, ...@@ -201,15 +195,15 @@ PERF_TEST_P(uploadFixture, upload,
/////////////////// download /////////////////////////// /////////////////// download ///////////////////////////
typedef TestBaseWithParam<uploadParams> downloadFixture; typedef TestBaseWithParam<uploadParams> DownloadFixture;
PERF_TEST_P(downloadFixture, download, PERF_TEST_P(DownloadFixture, Download,
testing::Combine( testing::Combine(
OCL_TYPICAL_MAT_SIZES, OCL_TYPICAL_MAT_SIZES,
testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F), testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F),
testing::Range(1, 5))) testing::Range(1, 5)))
{ {
const uploadParams params = GetParam(); const UploadParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int depth = get<1>(params), cn = get<2>(params); const int depth = get<1>(params), cn = get<2>(params);
const int type = CV_MAKE_TYPE(depth, cn); const int type = CV_MAKE_TYPE(depth, cn);
......
...@@ -55,7 +55,7 @@ static void genData(Mat& trainData, Size size, Mat& trainLabel = Mat().setTo(Sca ...@@ -55,7 +55,7 @@ static void genData(Mat& trainData, Size size, Mat& trainLabel = Mat().setTo(Sca
trainData.create(size, CV_32FC1); trainData.create(size, CV_32FC1);
randu(trainData, 1.0, 100.0); randu(trainData, 1.0, 100.0);
if(nClasses != 0) if (nClasses != 0)
{ {
trainLabel.create(size.height, 1, CV_8UC1); trainLabel.create(size.height, 1, CV_8UC1);
randu(trainLabel, 0, nClasses - 1); randu(trainLabel, 0, nClasses - 1);
...@@ -82,7 +82,7 @@ PERF_TEST_P(KNNFixture, KNN, ...@@ -82,7 +82,7 @@ PERF_TEST_P(KNNFixture, KNN,
genData(testData, size); genData(testData, size);
Mat best_label; Mat best_label;
if(RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
TEST_CYCLE() TEST_CYCLE()
{ {
...@@ -90,7 +90,8 @@ PERF_TEST_P(KNNFixture, KNN, ...@@ -90,7 +90,8 @@ PERF_TEST_P(KNNFixture, KNN,
knn_cpu.train(trainData, trainLabels); knn_cpu.train(trainData, trainLabels);
knn_cpu.find_nearest(testData, k, &best_label); knn_cpu.find_nearest(testData, k, &best_label);
} }
}else if(RUN_OCL_IMPL) }
else if (RUN_OCL_IMPL)
{ {
cv::ocl::oclMat best_label_ocl; cv::ocl::oclMat best_label_ocl;
cv::ocl::oclMat testdata; cv::ocl::oclMat testdata;
...@@ -103,7 +104,8 @@ PERF_TEST_P(KNNFixture, KNN, ...@@ -103,7 +104,8 @@ PERF_TEST_P(KNNFixture, KNN,
knn_ocl.find_nearest(testdata, k, best_label_ocl); knn_ocl.find_nearest(testdata, k, best_label_ocl);
} }
best_label_ocl.download(best_label); best_label_ocl.download(best_label);
}else }
else
OCL_PERF_ELSE OCL_PERF_ELSE
SANITY_CHECK(best_label); SANITY_CHECK(best_label);
} }
...@@ -188,7 +190,7 @@ PERF_TEST_P(SVMFixture, DISABLED_SVM, ...@@ -188,7 +190,7 @@ PERF_TEST_P(SVMFixture, DISABLED_SVM,
CvMat samples_ = samples; CvMat samples_ = samples;
CvMat results_ = results; CvMat results_ = results;
if(RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
CvSVM svm; CvSVM svm;
svm.train(trainData, labels, Mat(), Mat(), params); svm.train(trainData, labels, Mat(), Mat(), params);
...@@ -197,7 +199,7 @@ PERF_TEST_P(SVMFixture, DISABLED_SVM, ...@@ -197,7 +199,7 @@ PERF_TEST_P(SVMFixture, DISABLED_SVM,
svm.predict(&samples_, &results_); svm.predict(&samples_, &results_);
} }
} }
else if(RUN_OCL_IMPL) else if (RUN_OCL_IMPL)
{ {
CvSVM_OCL svm; CvSVM_OCL svm;
svm.train(trainData, labels, Mat(), Mat(), params); svm.train(trainData, labels, Mat(), Mat(), params);
......
...@@ -55,22 +55,19 @@ using namespace cvtest; ...@@ -55,22 +55,19 @@ using namespace cvtest;
using namespace testing; using namespace testing;
using namespace std; using namespace std;
///////////// Moments //////////////////////// ///////////// Moments ////////////////////////
//*! performance of image
typedef tuple<Size, MatType, bool> MomentsParamType;
typedef TestBaseWithParam<MomentsParamType> MomentsFixture;
PERF_TEST_P(MomentsFixture, Moments, typedef tuple<Size, bool> MomentsParams;
::testing::Combine(OCL_TYPICAL_MAT_SIZES, typedef TestBaseWithParam<MomentsParams> MomentsFixture;
OCL_PERF_ENUM(CV_8UC1, CV_16SC1, CV_16UC1, CV_32FC1), ::testing::Bool()))
OCL_PERF_TEST_P(MomentsFixture, Moments,
::testing::Combine(OCL_TEST_SIZES, ::testing::Bool()))
{ {
const MomentsParamType params = GetParam(); const MomentsParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int type = get<1>(params); const bool binaryImage = get<1>(params);
const bool binaryImage = get<2>(params);
Mat src(srcSize, type), dst(7, 1, CV_64F); Mat src(srcSize, CV_8UC1), dst(7, 1, CV_64F);
randu(src, 0, 255); randu(src, 0, 255);
cv::Moments mom; cv::Moments mom;
...@@ -85,6 +82,7 @@ PERF_TEST_P(MomentsFixture, Moments, ...@@ -85,6 +82,7 @@ PERF_TEST_P(MomentsFixture, Moments,
} }
else else
OCL_PERF_ELSE OCL_PERF_ELSE
cv::HuMoments(mom, dst); cv::HuMoments(mom, dst);
SANITY_CHECK(dst, 2e-1); SANITY_CHECK(dst, 2e-1);
} }
...@@ -52,55 +52,27 @@ using std::tr1::get; ...@@ -52,55 +52,27 @@ using std::tr1::get;
using std::tr1::tuple; using std::tr1::tuple;
using std::tr1::make_tuple; using std::tr1::make_tuple;
CV_ENUM(LoadMode, IMREAD_GRAYSCALE, IMREAD_COLOR) typedef TestBaseWithParam<tuple<int> > PyrLKOpticalFlowFixture;
typedef tuple<int, tuple<string, string, LoadMode> > PyrLKOpticalFlowParamType; OCL_PERF_TEST_P(PyrLKOpticalFlowFixture,
typedef TestBaseWithParam<PyrLKOpticalFlowParamType> PyrLKOpticalFlowFixture; PyrLKOpticalFlow, ::testing::Values(1000, 2000, 4000))
PERF_TEST_P(PyrLKOpticalFlowFixture,
PyrLKOpticalFlow,
::testing::Combine(
::testing::Values(1000, 2000, 4000),
::testing::Values(
make_tuple<string, string, LoadMode>
(
string("gpu/opticalflow/rubberwhale1.png"),
string("gpu/opticalflow/rubberwhale2.png"),
LoadMode(IMREAD_COLOR)
),
make_tuple<string, string, LoadMode>
(
string("gpu/stereobm/aloe-L.png"),
string("gpu/stereobm/aloe-R.png"),
LoadMode(IMREAD_GRAYSCALE)
)
)
)
)
{ {
PyrLKOpticalFlowParamType params = GetParam(); const int pointsCount = get<0>(GetParam());
tuple<string, string, LoadMode> fileParam = get<1>(params);
const int pointsCount = get<0>(params); const string fileName0 = "gpu/opticalflow/rubberwhale1.png",
const int openMode = static_cast<int>(get<2>(fileParam)); fileName1 = "gpu/opticalflow/rubberwhale2.png";
const string fileName0 = get<0>(fileParam), fileName1 = get<1>(fileParam); Mat frame0 = imread(getDataPath(fileName0), cv::IMREAD_GRAYSCALE);
Mat frame0 = imread(getDataPath(fileName0), openMode); Mat frame1 = imread(getDataPath(fileName1), cv::IMREAD_GRAYSCALE);
Mat frame1 = imread(getDataPath(fileName1), openMode);
declare.in(frame0, frame1); declare.in(frame0, frame1);
ASSERT_FALSE(frame0.empty()) << "can't load " << fileName0; ASSERT_FALSE(frame0.empty()) << "can't load " << fileName0;
ASSERT_FALSE(frame1.empty()) << "can't load " << fileName1; ASSERT_FALSE(frame1.empty()) << "can't load " << fileName1;
Mat grayFrame;
if (openMode == IMREAD_COLOR)
cvtColor(frame0, grayFrame, COLOR_BGR2GRAY);
else
grayFrame = frame0;
vector<Point2f> pts, nextPts; vector<Point2f> pts, nextPts;
vector<unsigned char> status; vector<unsigned char> status;
vector<float> err; vector<float> err;
goodFeaturesToTrack(grayFrame, pts, pointsCount, 0.01, 0.0); goodFeaturesToTrack(frame0, pts, pointsCount, 0.01, 0.0);
Mat ptsMat(1, static_cast<int>(pts.size()), CV_32FC2, (void *)&pts[0]); Mat ptsMat(1, static_cast<int>(pts.size()), CV_32FC2, (void *)&pts[0]);
if (RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
...@@ -136,7 +108,7 @@ PERF_TEST(tvl1flowFixture, tvl1flow) ...@@ -136,7 +108,7 @@ PERF_TEST(tvl1flowFixture, tvl1flow)
const Size srcSize = frame0.size(); const Size srcSize = frame0.size();
const double eps = 1.2; const double eps = 1.2;
Mat flow(srcSize, CV_32FC2), flow1(srcSize, CV_32FC1), flow2(srcSize, CV_32FC1); Mat flow(srcSize, CV_32FC2), flow1(srcSize, CV_32FC1), flow2(srcSize, CV_32FC1);
declare.in(frame0, frame1).out(flow1, flow2).time(159); declare.in(frame0, frame1).out(flow1, flow2);
if (RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
...@@ -178,12 +150,11 @@ CV_ENUM(farneFlagType, 0, OPTFLOW_FARNEBACK_GAUSSIAN) ...@@ -178,12 +150,11 @@ CV_ENUM(farneFlagType, 0, OPTFLOW_FARNEBACK_GAUSSIAN)
typedef tuple<tuple<int, double>, farneFlagType, bool> FarnebackOpticalFlowParams; typedef tuple<tuple<int, double>, farneFlagType, bool> FarnebackOpticalFlowParams;
typedef TestBaseWithParam<FarnebackOpticalFlowParams> FarnebackOpticalFlowFixture; typedef TestBaseWithParam<FarnebackOpticalFlowParams> FarnebackOpticalFlowFixture;
PERF_TEST_P(FarnebackOpticalFlowFixture, FarnebackOpticalFlow, OCL_PERF_TEST_P(FarnebackOpticalFlowFixture, FarnebackOpticalFlow,
::testing::Combine( ::testing::Combine(
::testing::Values(make_tuple<int, double>(5, 1.1), ::testing::Values(make_tuple<int, double>(5, 1.1),
make_tuple<int, double>(7, 1.5)), make_tuple<int, double>(7, 1.5)),
farneFlagType::all(), farneFlagType::all(), ::testing::Bool()))
::testing::Bool()))
{ {
Mat frame0 = imread(getDataPath("gpu/opticalflow/rubberwhale1.png"), cv::IMREAD_GRAYSCALE); Mat frame0 = imread(getDataPath("gpu/opticalflow/rubberwhale1.png"), cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0.empty()) << "can't load rubberwhale1.png"; ASSERT_FALSE(frame0.empty()) << "can't load rubberwhale1.png";
......
...@@ -70,8 +70,7 @@ ...@@ -70,8 +70,7 @@
#include "opencv2/ocl/ocl.hpp" #include "opencv2/ocl/ocl.hpp"
#include "opencv2/ts/ts.hpp" #include "opencv2/ts/ts.hpp"
using namespace std; // TODO remove it
using namespace cv;
#define OCL_SIZE_1000 Size(1000, 1000) #define OCL_SIZE_1000 Size(1000, 1000)
#define OCL_SIZE_2000 Size(2000, 2000) #define OCL_SIZE_2000 Size(2000, 2000)
...@@ -79,6 +78,19 @@ using namespace cv; ...@@ -79,6 +78,19 @@ using namespace cv;
#define OCL_TYPICAL_MAT_SIZES ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000, OCL_SIZE_4000) #define OCL_TYPICAL_MAT_SIZES ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000, OCL_SIZE_4000)
using namespace std;
using namespace cv;
#define OCL_SIZE_1 szVGA
#define OCL_SIZE_2 sz720p
#define OCL_SIZE_3 sz1080p
#define OCL_SIZE_4 sz2160p
#define OCL_TEST_SIZES ::testing::Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3, OCL_SIZE_4)
#define OCL_TEST_TYPES ::testing::Values(CV_8UC1, CV_32FC1, CV_8UC4, CV_32FC4)
#define OCL_TEST_TYPES_14 OCL_TEST_TYPES
#define OCL_TEST_TYPES_134 ::testing::Values(CV_8UC1, CV_32FC1, CV_8UC3, CV_32FC3, CV_8UC4, CV_32FC4)
#define OCL_PERF_ENUM(type, ...) ::testing::Values(type, ## __VA_ARGS__ ) #define OCL_PERF_ENUM(type, ...) ::testing::Values(type, ## __VA_ARGS__ )
#define IMPL_OCL "ocl" #define IMPL_OCL "ocl"
...@@ -103,6 +115,31 @@ using namespace cv; ...@@ -103,6 +115,31 @@ using namespace cv;
CV_TEST_FAIL_NO_IMPL(); CV_TEST_FAIL_NO_IMPL();
#endif #endif
#define OCL_PERF_TEST(fixture, name) \
class OCL##_##fixture##_##name : \
public ::perf::TestBase \
{ \
public: \
OCL##_##fixture##_##name() { } \
protected: \
virtual void PerfTestBody(); \
}; \
TEST_F(OCL##_##fixture##_##name, name) { RunPerfTestBody(); } \
void OCL##_##fixture##_##name::PerfTestBody()
#define OCL_PERF_TEST_P(fixture, name, params) \
class OCL##_##fixture##_##name : \
public fixture \
{ \
public: \
OCL##_##fixture##_##name() { } \
protected: \
virtual void PerfTestBody(); \
}; \
TEST_P(OCL##_##fixture##_##name, name) { RunPerfTestBody(); } \
INSTANTIATE_TEST_CASE_P(/*none*/, OCL##_##fixture##_##name, params); \
void OCL##_##fixture##_##name::PerfTestBody()
#define OCL_TEST_CYCLE_N(n) for(declare.iterations(n); startTimer(), next(); cv::ocl::finish(), stopTimer()) #define OCL_TEST_CYCLE_N(n) for(declare.iterations(n); startTimer(), next(); cv::ocl::finish(), stopTimer())
#define OCL_TEST_CYCLE() for(; startTimer(), next(); cv::ocl::finish(), stopTimer()) #define OCL_TEST_CYCLE() for(; startTimer(), next(); cv::ocl::finish(), stopTimer())
#define OCL_TEST_CYCLE_MULTIRUN(runsNum) for(declare.runs(runsNum); startTimer(), next(); stopTimer()) for(int r = 0; r < runsNum; cv::ocl::finish(), ++r) #define OCL_TEST_CYCLE_MULTIRUN(runsNum) for(declare.runs(runsNum); startTimer(), next(); stopTimer()) for(int r = 0; r < runsNum; cv::ocl::finish(), ++r)
......
...@@ -51,11 +51,10 @@ using std::tr1::get; ...@@ -51,11 +51,10 @@ using std::tr1::get;
///////////// pyrDown ////////////////////// ///////////// pyrDown //////////////////////
typedef Size_MatType pyrDownFixture; typedef Size_MatType PyrDownFixture;
PERF_TEST_P(pyrDownFixture, pyrDown, OCL_PERF_TEST_P(PyrDownFixture, PyrDown,
::testing::Combine(OCL_TYPICAL_MAT_SIZES, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
{ {
const Size_MatType_t params = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
...@@ -77,7 +76,7 @@ PERF_TEST_P(pyrDownFixture, pyrDown, ...@@ -77,7 +76,7 @@ PERF_TEST_P(pyrDownFixture, pyrDown,
oclDst.download(dst); oclDst.download(dst);
SANITY_CHECK(dst); SANITY_CHECK(dst, 5e-4);
} }
else if (RUN_PLAIN_IMPL) else if (RUN_PLAIN_IMPL)
{ {
...@@ -91,11 +90,10 @@ PERF_TEST_P(pyrDownFixture, pyrDown, ...@@ -91,11 +90,10 @@ PERF_TEST_P(pyrDownFixture, pyrDown,
///////////// pyrUp //////////////////////// ///////////// pyrUp ////////////////////////
typedef Size_MatType pyrUpFixture; typedef Size_MatType PyrUpFixture;
PERF_TEST_P(pyrUpFixture, pyrUp, OCL_PERF_TEST_P(PyrUpFixture, PyrUp,
::testing::Combine(OCL_TYPICAL_MAT_SIZES, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
{ {
const Size_MatType_t params = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
...@@ -117,7 +115,7 @@ PERF_TEST_P(pyrUpFixture, pyrUp, ...@@ -117,7 +115,7 @@ PERF_TEST_P(pyrUpFixture, pyrUp,
oclDst.download(dst); oclDst.download(dst);
SANITY_CHECK(dst); SANITY_CHECK(dst, 5e-4);
} }
else if (RUN_PLAIN_IMPL) else if (RUN_PLAIN_IMPL)
{ {
......
...@@ -51,21 +51,22 @@ using std::tr1::get; ...@@ -51,21 +51,22 @@ using std::tr1::get;
///////////// Merge//////////////////////// ///////////// Merge////////////////////////
typedef Size_MatType MergeFixture; typedef tuple<Size, MatDepth, int> MergeParams;
typedef TestBaseWithParam<MergeParams> MergeFixture;
PERF_TEST_P(MergeFixture, Merge, OCL_PERF_TEST_P(MergeFixture, Merge,
::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000), ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8U, CV_32F),
OCL_PERF_ENUM(CV_8U, CV_32F))) OCL_PERF_ENUM(2, 3)))
{ {
const Size_MatType_t params = GetParam(); const MergeParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int depth = get<1>(params), channels = 3; const int depth = get<1>(params), cn = get<2>(params),
const int dstType = CV_MAKE_TYPE(depth, channels); dtype = CV_MAKE_TYPE(depth, cn);
checkDeviceMaxMemoryAllocSize(srcSize, dstType); checkDeviceMaxMemoryAllocSize(srcSize, dtype);
Mat dst(srcSize, dstType); Mat dst(srcSize, dtype);
vector<Mat> src(channels); vector<Mat> src(cn);
for (vector<Mat>::iterator i = src.begin(), end = src.end(); i != end; ++i) for (vector<Mat>::iterator i = src.begin(), end = src.end(); i != end; ++i)
{ {
i->create(srcSize, CV_MAKE_TYPE(depth, 1)); i->create(srcSize, CV_MAKE_TYPE(depth, 1));
...@@ -75,7 +76,7 @@ PERF_TEST_P(MergeFixture, Merge, ...@@ -75,7 +76,7 @@ PERF_TEST_P(MergeFixture, Merge,
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
ocl::oclMat oclDst(srcSize, dstType); ocl::oclMat oclDst(srcSize, dtype);
vector<ocl::oclMat> oclSrc(src.size()); vector<ocl::oclMat> oclSrc(src.size());
for (vector<ocl::oclMat>::size_type i = 0, end = src.size(); i < end; ++i) for (vector<ocl::oclMat>::size_type i = 0, end = src.size(); i < end; ++i)
oclSrc[i] = src[i]; oclSrc[i] = src[i];
...@@ -98,49 +99,69 @@ PERF_TEST_P(MergeFixture, Merge, ...@@ -98,49 +99,69 @@ PERF_TEST_P(MergeFixture, Merge,
///////////// Split//////////////////////// ///////////// Split////////////////////////
typedef Size_MatType SplitFixture; typedef MergeParams SplitParams;
typedef TestBaseWithParam<SplitParams> SplitFixture;
PERF_TEST_P(SplitFixture, Split, OCL_PERF_TEST_P(SplitFixture, Split,
::testing::Combine(OCL_TYPICAL_MAT_SIZES, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8U, CV_32F),
OCL_PERF_ENUM(CV_8U, CV_32F))) OCL_PERF_ENUM(2, 3)))
{ {
const Size_MatType_t params = GetParam(); const SplitParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int depth = get<1>(params), channels = 3; const int depth = get<1>(params), cn = get<2>(params);
const int type = CV_MAKE_TYPE(depth, channels); const int type = CV_MAKE_TYPE(depth, cn);
checkDeviceMaxMemoryAllocSize(srcSize, type); checkDeviceMaxMemoryAllocSize(srcSize, type);
Mat src(srcSize, type); Mat src(srcSize, type);
Mat dst0, dst1, dst2;
declare.in(src, WARMUP_RNG); declare.in(src, WARMUP_RNG);
ASSERT_TRUE(cn == 3 || cn == 2);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
ocl::oclMat oclSrc(src); ocl::oclMat oclSrc(src);
vector<ocl::oclMat> oclDst(channels, ocl::oclMat(srcSize, CV_MAKE_TYPE(depth, 1))); vector<ocl::oclMat> oclDst(cn);
oclDst[0] = ocl::oclMat(srcSize, depth);
oclDst[1] = ocl::oclMat(srcSize, depth);
if (cn == 3)
oclDst[2] = ocl::oclMat(srcSize, depth);
OCL_TEST_CYCLE() cv::ocl::split(oclSrc, oclDst); OCL_TEST_CYCLE() cv::ocl::split(oclSrc, oclDst);
ASSERT_EQ(3, channels);
Mat dst0, dst1, dst2;
oclDst[0].download(dst0); oclDst[0].download(dst0);
oclDst[1].download(dst1); oclDst[1].download(dst1);
if (cn == 3)
oclDst[2].download(dst2); oclDst[2].download(dst2);
SANITY_CHECK(dst0);
SANITY_CHECK(dst1);
SANITY_CHECK(dst2);
} }
else if (RUN_PLAIN_IMPL) else if (RUN_PLAIN_IMPL)
{ {
vector<Mat> dst(channels, Mat(srcSize, CV_MAKE_TYPE(depth, 1))); vector<Mat> dst(cn);
dst[0] = Mat(srcSize, depth);
dst[1] = Mat(srcSize, depth);
if (cn == 3)
dst[2] = Mat(srcSize, depth);
TEST_CYCLE() cv::split(src, dst); TEST_CYCLE() cv::split(src, dst);
ASSERT_EQ(3, channels); dst0 = dst[0];
Mat & dst0 = dst[0], & dst1 = dst[1], & dst2 = dst[2]; dst1 = dst[1];
if (cn == 3)
dst2 = dst[2];
}
else
OCL_PERF_ELSE
if (cn == 2)
{
SANITY_CHECK(dst0);
SANITY_CHECK(dst1);
}
else if (cn == 3)
{
SANITY_CHECK(dst0); SANITY_CHECK(dst0);
SANITY_CHECK(dst1); SANITY_CHECK(dst1);
SANITY_CHECK(dst2); SANITY_CHECK(dst2);
} }
else
OCL_PERF_ELSE
} }
...@@ -49,20 +49,210 @@ using namespace perf; ...@@ -49,20 +49,210 @@ using namespace perf;
using std::tr1::tuple; using std::tr1::tuple;
using std::tr1::get; using std::tr1::get;
///////////// norm////////////////////////
typedef tuple<Size, MatType> normParams; ///////////// MinMax ////////////////////////
typedef TestBaseWithParam<normParams> normFixture;
typedef Size_MatType MinMaxFixture;
PERF_TEST_P(normFixture, norm, testing::Combine( PERF_TEST_P(MinMaxFixture, MinMax,
OCL_TYPICAL_MAT_SIZES, ::testing::Combine(OCL_TYPICAL_MAT_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{ {
const normParams params = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
declare.in(src, WARMUP_RNG);
double min_val = std::numeric_limits<double>::max(),
max_val = std::numeric_limits<double>::min();
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() cv::ocl::minMax(oclSrc, &min_val, &max_val);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else if (RUN_PLAIN_IMPL)
{
Point min_loc, max_loc;
TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else
OCL_PERF_ELSE
}
///////////// MinMaxLoc ////////////////////////
typedef Size_MatType MinMaxLocFixture;
OCL_PERF_TEST_P(MinMaxLocFixture, MinMaxLoc,
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
randu(src, 0, 1);
declare.in(src);
double min_val = 0.0, max_val = 0.0;
Point min_loc, max_loc;
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() cv::ocl::minMaxLoc(oclSrc, &min_val, &max_val, &min_loc, &max_loc);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else
OCL_PERF_ELSE
}
///////////// Sum ////////////////////////
typedef Size_MatType SumFixture;
OCL_PERF_TEST_P(SumFixture, Sum,
::testing::Combine(OCL_TEST_SIZES,
OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
Scalar result;
randu(src, 0, 60);
declare.in(src);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() result = cv::ocl::sum(oclSrc);
SANITY_CHECK(result, 1e-6, ERROR_RELATIVE);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() result = cv::sum(src);
SANITY_CHECK(result, 1e-6, ERROR_RELATIVE);
}
else
OCL_PERF_ELSE
}
///////////// countNonZero ////////////////////////
typedef Size_MatType CountNonZeroFixture;
OCL_PERF_TEST_P(CountNonZeroFixture, CountNonZero,
::testing::Combine(OCL_TEST_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
int result = 0;
randu(src, 0, 256);
declare.in(src);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() result = cv::ocl::countNonZero(oclSrc);
SANITY_CHECK(result);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() result = cv::countNonZero(src);
SANITY_CHECK(result);
}
else
OCL_PERF_ELSE
}
///////////// meanStdDev ////////////////////////
typedef Size_MatType MeanStdDevFixture;
OCL_PERF_TEST_P(MeanStdDevFixture, MeanStdDev,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
Scalar mean, stddev;
randu(src, 0, 256);
declare.in(src);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() cv::ocl::meanStdDev(oclSrc, mean, stddev);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::meanStdDev(src, mean, stddev);
}
else
OCL_PERF_ELSE
SANITY_CHECK_NOTHING();
// SANITY_CHECK(mean, 1e-6, ERROR_RELATIVE);
// SANITY_CHECK(stddev, 1e-6, ERROR_RELATIVE);
}
///////////// norm////////////////////////
CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2)
typedef std::tr1::tuple<Size, MatType, NormType> NormParams;
typedef TestBaseWithParam<NormParams> NormFixture;
OCL_PERF_TEST_P(NormFixture, Norm,
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_TEST_TYPES, NormType::all()))
{
const NormParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int type = get<1>(params); const int type = get<1>(params);
double value = 0.0; const int normType = get<2>(params);
const double eps = CV_MAT_DEPTH(type) == CV_8U ? DBL_EPSILON : 1e-3; perf::ERROR_TYPE errorType = type != NORM_INF ? ERROR_RELATIVE : ERROR_ABSOLUTE;
double eps = 1e-5, value;
Mat src1(srcSize, type), src2(srcSize, type); Mat src1(srcSize, type), src2(srcSize, type);
declare.in(src1, src2, WARMUP_RNG); declare.in(src1, src2, WARMUP_RNG);
...@@ -71,15 +261,15 @@ PERF_TEST_P(normFixture, norm, testing::Combine( ...@@ -71,15 +261,15 @@ PERF_TEST_P(normFixture, norm, testing::Combine(
{ {
ocl::oclMat oclSrc1(src1), oclSrc2(src2); ocl::oclMat oclSrc1(src1), oclSrc2(src2);
OCL_TEST_CYCLE() value = cv::ocl::norm(oclSrc1, oclSrc2, NORM_INF); OCL_TEST_CYCLE() value = cv::ocl::norm(oclSrc1, oclSrc2, normType);
SANITY_CHECK(value, eps); SANITY_CHECK(value, eps, errorType);
} }
else if (RUN_PLAIN_IMPL) else if (RUN_PLAIN_IMPL)
{ {
TEST_CYCLE() value = cv::norm(src1, src2, NORM_INF); TEST_CYCLE() value = cv::norm(src1, src2, normType);
SANITY_CHECK(value); SANITY_CHECK(value, eps, errorType);
} }
else else
OCL_PERF_ELSE OCL_PERF_ELSE
......
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