Commit d02ccc95 authored by ilya-lavrenov's avatar ilya-lavrenov

the code was refactored and old test system code was removed

parent 4c28a6f0
......@@ -42,153 +42,54 @@
#include "perf_precomp.hpp"
static int old_main(int argc, const char *argv[])
const char * impls[] =
{
IMPL_OCL,
IMPL_PLAIN,
#ifdef HAVE_OPENCV_GPU
IMPL_GPU
#endif
};
int main(int argc, char ** argv)
{
const char *keys =
"{ h | help | false | print help message }"
"{ f | filter | | filter for test }"
"{ w | workdir | | set working directory }"
"{ l | list | false | show all tests }"
"{ d | device | 0 | device id }"
"{ c | cpu_ocl | false | use cpu as ocl device}"
"{ i | iters | 10 | iteration count }"
"{ m | warmup | 1 | gpu warm up iteration count}"
"{ t | xtop | 1.1 | xfactor top boundary}"
"{ b | xbottom | 0.9 | xfactor bottom boundary}"
"{ v | verify | false | only run gpu once to verify if problems occur}";
const char * keys =
"{ h | help | false | print help message }"
"{ t | type | gpu | set device type:cpu or gpu}"
"{ p | platform | 0 | set platform id }"
"{ d | device | 0 | set device id }";
redirectError(cvErrorCallback);
CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help"))
{
cout << "Avaible options:" << endl;
cout << "Available options besides google test option:" << endl;
cmd.printParams();
return 0;
}
// get ocl devices
bool use_cpu = cmd.get<bool>("c");
vector<ocl::Info> oclinfo;
int num_devices = 0;
if(use_cpu)
num_devices = getDevice(oclinfo, ocl::CVCL_DEVICE_TYPE_CPU);
else
num_devices = getDevice(oclinfo);
if (num_devices < 1)
{
cerr << "no device found\n";
return -1;
}
// show device info
int devidx = 0;
for (size_t i = 0; i < oclinfo.size(); i++)
{
for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++)
{
cout << "device " << devidx++ << ": " << oclinfo[i].DeviceName[j] << endl;
}
}
string type = cmd.get<string>("type");
unsigned int pid = cmd.get<unsigned int>("platform");
int device = cmd.get<int>("device");
if (device < 0 || device >= num_devices)
{
cerr << "Invalid device ID" << endl;
return -1;
}
// set this to overwrite binary cache every time the test starts
ocl::setBinaryDiskCache(ocl::CACHE_UPDATE);
if (cmd.get<bool>("verify"))
{
TestSystem::instance().setNumIters(1);
TestSystem::instance().setGPUWarmupIters(0);
TestSystem::instance().setCPUIters(0);
}
devidx = 0;
for (size_t i = 0; i < oclinfo.size(); i++)
{
for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++, devidx++)
{
if (device == devidx)
{
ocl::setDevice(oclinfo[i], (int)j);
TestSystem::instance().setRecordName(oclinfo[i].DeviceName[j]);
cout << "use " << devidx << ": " <<oclinfo[i].DeviceName[j] << endl;
goto END_DEV;
}
}
}
END_DEV:
string filter = cmd.get<string>("filter");
string workdir = cmd.get<string>("workdir");
bool list = cmd.get<bool>("list");
int iters = cmd.get<int>("iters");
int wu_iters = cmd.get<int>("warmup");
double x_top = cmd.get<double>("xtop");
double x_bottom = cmd.get<double>("xbottom");
int flag = type == "cpu" ? cv::ocl::CVCL_DEVICE_TYPE_CPU :
cv::ocl::CVCL_DEVICE_TYPE_GPU;
TestSystem::instance().setTopThreshold(x_top);
TestSystem::instance().setBottomThreshold(x_bottom);
if (!filter.empty())
{
TestSystem::instance().setTestFilter(filter);
}
if (!workdir.empty())
std::vector<cv::ocl::Info> oclinfo;
int devnums = cv::ocl::getDevice(oclinfo, flag);
if (devnums <= device || device < 0)
{
if (workdir[workdir.size() - 1] != '/' && workdir[workdir.size() - 1] != '\\')
{
workdir += '/';
}
TestSystem::instance().setWorkingDir(workdir);
std::cout << "device invalid\n";
return -1;
}
if (list)
if (pid >= oclinfo.size())
{
TestSystem::instance().setListMode(true);
}
TestSystem::instance().setNumIters(iters);
TestSystem::instance().setGPUWarmupIters(wu_iters);
TestSystem::instance().run();
return 0;
}
const char * impls[] =
{
"ocl",
"plain",
#ifdef HAVE_OPENCV_GPU
"gpu"
#endif
};
int main(int argc, char **argv)
{
// temp solution: if no '--gtest_' and '--perf_' args switch to old behavior
bool useGTest = false;
for(int i=1; i<argc; i++)
{
std::string arg( argv[i] );
if( arg.find("--gtest_")==0 || arg.find("--perf_")==0 )
useGTest = true;
// if (arg == "--perf_verify_sanity")
// argv[i] = (char*)"--perf_no_verify_sanity";
std::cout << "platform invalid\n";
return -1;
}
if( !useGTest )
return old_main(argc, (const char**)argv);
cv::ocl::setDevice(oclinfo[pid], device);
cv::ocl::setBinaryDiskCache(cv::ocl::CACHE_UPDATE);
CV_PERF_TEST_MAIN_INTERNALS(ocl, impls)
}
This diff is collapsed.
......@@ -82,12 +82,9 @@ typedef TestBaseWithParam<Size> blendLinearFixture;
PERF_TEST_P(blendLinearFixture, blendLinear, OCL_TYPICAL_MAT_SIZES)
{
// getting params
const Size srcSize = GetParam();
const int type = CV_8UC1;
const std::string impl = getSelectedImpl();
// creating src data
Mat src1(srcSize, type), src2(srcSize, CV_8UC1), dst;
Mat weights1(srcSize, CV_32FC1), weights2(srcSize, CV_32FC1);
......@@ -95,8 +92,7 @@ PERF_TEST_P(blendLinearFixture, blendLinear, OCL_TYPICAL_MAT_SIZES)
randu(weights1, 0.0f, 1.0f);
randu(weights2, 0.0f, 1.0f);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst;
ocl::oclMat oclWeights1(weights1), oclWeights2(weights2);
......@@ -107,16 +103,12 @@ PERF_TEST_P(blendLinearFixture, blendLinear, OCL_TYPICAL_MAT_SIZES)
SANITY_CHECK(dst);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() blendLinearGold<uchar>(src1, src2, weights1, weights2, dst);
SANITY_CHECK(dst);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
......@@ -53,11 +53,10 @@ using namespace perf;
typedef TestBaseWithParam<Size> BruteForceMatcherFixture;
PERF_TEST_P(BruteForceMatcherFixture, match,
OCL_BFMATCHER_TYPICAL_MAT_SIZES)
PERF_TEST_P(BruteForceMatcherFixture, DISABLED_match,
OCL_BFMATCHER_TYPICAL_MAT_SIZES) // TODO too big difference between implementations
{
const Size srcSize = GetParam();
const string impl = getSelectedImpl();
vector<DMatch> matches;
Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
......@@ -65,16 +64,15 @@ PERF_TEST_P(BruteForceMatcherFixture, match,
randu(query, 0.0f, 1.0f);
randu(train, 0.0f, 1.0f);
if (impl == "plain")
if (RUN_PLAIN_IMPL)
{
BFMatcher matcher(NORM_L2);
TEST_CYCLE() matcher.match(query, train, matches);
SANITY_CHECK_MATCHES(matches);
}
else if (impl == "ocl")
else if (RUN_OCL_IMPL)
{
// Init GPU matcher
ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
ocl::oclMat oclQuery(query), oclTrain(train);
......@@ -82,53 +80,14 @@ PERF_TEST_P(BruteForceMatcherFixture, match,
SANITY_CHECK_MATCHES(matches);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
//PERF_TEST_P(BruteForceMatcherFixture, matchSingle,
// OCL_BFMATCHER_TYPICAL_MAT_SIZES)
//{
// const Size srcSize = GetParam();
// const string impl = getSelectedImpl();
// Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
// Mat trainIdx, distance;
// randu(query, 0.0f, 1.0f);
// randu(train, 0.0f, 1.0f);
// if (impl == "plain")
// CV_TEST_FAIL_NO_IMPL();
// else if (impl == "ocl")
// {
// ocl::oclMat oclQuery(query), oclTrain(train), oclTrainIdx, oclDistance;
// TEST_CYCLE() oclMatcher->matchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance);
// oclTrainIdx.download(trainIdx);
// oclDistance.download(distance);
// SANITY_CHECK(trainIdx);
// SANITY_CHECK(distance);
// }
//#ifdef HAVE_OPENCV_GPU
// else if (impl == "gpu")
// CV_TEST_FAIL_NO_IMPL();
//#endif
// else
// CV_TEST_FAIL_NO_IMPL();
//}
PERF_TEST_P(BruteForceMatcherFixture, knnMatch,
OCL_BFMATCHER_TYPICAL_MAT_SIZES)
PERF_TEST_P(BruteForceMatcherFixture, DISABLED_knnMatch,
OCL_BFMATCHER_TYPICAL_MAT_SIZES) // TODO too many outliers
{
const Size srcSize = GetParam();
const string impl = getSelectedImpl();
vector<vector<DMatch> > matches(2);
Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
......@@ -139,7 +98,7 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch,
if (srcSize.height == 2000)
declare.time(8);
if (impl == "plain")
if (RUN_PLAIN_IMPL)
{
BFMatcher matcher (NORM_L2);
TEST_CYCLE() matcher.knnMatch(query, train, matches, 2);
......@@ -148,7 +107,7 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch,
SANITY_CHECK_MATCHES(matches0);
SANITY_CHECK_MATCHES(matches1);
}
else if (impl == "ocl")
else if (RUN_OCL_IMPL)
{
ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
ocl::oclMat oclQuery(query), oclTrain(train);
......@@ -159,55 +118,14 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch,
SANITY_CHECK_MATCHES(matches0);
SANITY_CHECK_MATCHES(matches1);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
//PERF_TEST_P(BruteForceMatcherFixture, knnMatchSingle,
// OCL_BFMATCHER_TYPICAL_MAT_SIZES)
//{
// const Size srcSize = GetParam();
// const string impl = getSelectedImpl();
// Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
// Mat trainIdx, distance, allDist;
// randu(query, 0.0f, 1.0f);
// randu(train, 0.0f, 1.0f);
// if (impl == "plain")
// CV_TEST_FAIL_NO_IMPL();
// else if (impl == "ocl")
// {
// ocl::oclMat oclQuery(query), oclTrain(train), oclTrainIdx, oclDistance, oclAllDist;
// TEST_CYCLE() oclMatcher->knnMatchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance, oclAllDist, 2);
// oclTrainIdx.download(trainIdx);
// oclDistance.download(distance);
// oclAllDist.download(allDist);
// SANITY_CHECK(trainIdx);
// SANITY_CHECK(distance);
// SANITY_CHECK(allDist);
// }
//#ifdef HAVE_OPENCV_GPU
// else if (impl == "gpu")
// CV_TEST_FAIL_NO_IMPL();
//#endif
// else
// CV_TEST_FAIL_NO_IMPL();
//}
PERF_TEST_P(BruteForceMatcherFixture, DISABLED_radiusMatch,
OCL_BFMATCHER_TYPICAL_MAT_SIZES)
OCL_BFMATCHER_TYPICAL_MAT_SIZES) // TODO too many outliers
{
const Size srcSize = GetParam();
const string impl = getSelectedImpl();
const float max_distance = 2.0f;
vector<vector<DMatch> > matches(2);
......@@ -218,7 +136,7 @@ PERF_TEST_P(BruteForceMatcherFixture, DISABLED_radiusMatch,
randu(query, 0.0f, 1.0f);
randu(train, 0.0f, 1.0f);
if (impl == "plain")
if (RUN_PLAIN_IMPL)
{
BFMatcher matcher (NORM_L2);
TEST_CYCLE() matcher.radiusMatch(query, matches, max_distance);
......@@ -227,7 +145,7 @@ PERF_TEST_P(BruteForceMatcherFixture, DISABLED_radiusMatch,
SANITY_CHECK_MATCHES(matches0);
SANITY_CHECK_MATCHES(matches1);
}
else if (impl == "ocl")
else if (RUN_OCL_IMPL)
{
ocl::oclMat oclQuery(query), oclTrain(train);
ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
......@@ -238,49 +156,8 @@ PERF_TEST_P(BruteForceMatcherFixture, DISABLED_radiusMatch,
SANITY_CHECK_MATCHES(matches0);
SANITY_CHECK_MATCHES(matches1);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
//PERF_TEST_P(BruteForceMatcherFixture, radiusMatchSingle,
// OCL_BFMATCHER_TYPICAL_MAT_SIZES)
//{
// const Size srcSize = GetParam();
// const string impl = getSelectedImpl();
// const float max_distance = 2.0f;
// Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
// Mat trainIdx, distance, nMatches;
// randu(query, 0.0f, 1.0f);
// randu(train, 0.0f, 1.0f);
// if (impl == "plain")
// CV_TEST_FAIL_NO_IMPL();
// else if (impl == "ocl")
// {
// ocl::oclMat oclQuery(query), oclTrain(train), oclTrainIdx, oclDistance, oclNMatches;
// TEST_CYCLE() oclMatcher->radiusMatchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance, oclNMatches, max_distance);
// oclTrainIdx.download(trainIdx);
// oclDistance.download(distance);
// oclNMatches.download(nMatches);
// SANITY_CHECK(trainIdx);
// SANITY_CHECK(distance);
// SANITY_CHECK(nMatches);
// }
//#ifdef HAVE_OPENCV_GPU
// else if (impl == "gpu")
// CV_TEST_FAIL_NO_IMPL();
//#endif
// else
// CV_TEST_FAIL_NO_IMPL();
//}
#undef OCL_BFMATCHER_TYPICAL_MAT_SIZES
......@@ -48,7 +48,7 @@
///////////// StereoMatchBM ////////////////////////
PERF_TEST(StereoMatchBMFixture, DISABLED_StereoMatchBM)
PERF_TEST(StereoMatchBMFixture, DISABLED_StereoMatchBM) // TODO doesn't work properly
{
Mat left_image = imread(getDataPath("gpu/stereobm/aloe-L.png"), cv::IMREAD_GRAYSCALE);
Mat right_image = imread(getDataPath("gpu/stereobm/aloe-R.png"), cv::IMREAD_GRAYSCALE);
......@@ -58,13 +58,12 @@ PERF_TEST(StereoMatchBMFixture, DISABLED_StereoMatchBM)
ASSERT_TRUE(right_image.size() == left_image.size());
ASSERT_TRUE(right_image.size() == left_image.size());
const std::string impl = getSelectedImpl();
const int n_disp = 128, winSize = 19;
Mat disp(left_image.size(), CV_16SC1);
declare.in(left_image, right_image).out(disp);
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclLeft(left_image), oclRight(right_image),
oclDisp(left_image.size(), CV_16SC1);
......@@ -76,7 +75,7 @@ PERF_TEST(StereoMatchBMFixture, DISABLED_StereoMatchBM)
SANITY_CHECK(disp);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
StereoBM bm(0, n_disp, winSize);
......@@ -84,10 +83,6 @@ PERF_TEST(StereoMatchBMFixture, DISABLED_StereoMatchBM)
SANITY_CHECK(disp);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
else
OCL_PERF_ELSE
}
......@@ -49,34 +49,29 @@ using namespace perf;
///////////// Canny ////////////////////////
PERF_TEST(CannyFixture, Canny)
PERF_TEST(CannyFixture, DISABLED_Canny) // TODO difference between implmentations
{
Mat img = imread(getDataPath("gpu/stereobm/aloe-L.png"), cv::IMREAD_GRAYSCALE),
edges(img.size(), CV_8UC1);
ASSERT_TRUE(!img.empty()) << "can't open aloeL.jpg";
ASSERT_TRUE(!img.empty()) << "can't open aloe-L.png";
const std::string impl = getSelectedImpl();
declare.in(img).out(edges);
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclImg(img), oclEdges(img.size(), CV_8UC1);
TEST_CYCLE() Canny(oclImg, oclEdges, 50.0, 100.0);
TEST_CYCLE() ocl::Canny(oclImg, oclEdges, 50.0, 100.0);
oclEdges.download(edges);
SANITY_CHECK(edges);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() Canny(img, edges, 50.0, 100.0);
SANITY_CHECK(edges);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
......@@ -54,12 +54,11 @@ typedef TestBaseWithParam<Size> cvtColorFixture;
PERF_TEST_P(cvtColorFixture, cvtColor, OCL_TYPICAL_MAT_SIZES)
{
const Size srcSize = GetParam();
const std::string impl = getSelectedImpl();
Mat src(srcSize, CV_8UC4), dst(srcSize, CV_8UC4);
declare.in(src).out(dst);
declare.in(src, WARMUP_RNG).out(dst);
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src), oclDst(src.size(), CV_8UC4);
......@@ -68,16 +67,12 @@ PERF_TEST_P(cvtColorFixture, cvtColor, OCL_TYPICAL_MAT_SIZES)
SANITY_CHECK(dst);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::cvtColor(src, dst, CV_RGBA2GRAY, 4);
SANITY_CHECK(dst);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
......@@ -51,37 +51,33 @@ using namespace perf;
typedef TestBaseWithParam<Size> dftFixture;
PERF_TEST_P(dftFixture, DISABLED_dft, OCL_TYPICAL_MAT_SIZES)
PERF_TEST_P(dftFixture, DISABLED_dft, OCL_TYPICAL_MAT_SIZES) // TODO not implemented
{
const std::string impl = getSelectedImpl();
Size srcSize = GetParam();
const Size srcSize = GetParam();
Mat src(srcSize, CV_32FC2), dst;
randu(src, 0.0f, 1.0f);
declare.in(src);
if (impl == "ocl")
if (srcSize == OCL_SIZE_4000)
declare.time(7.4);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src), oclDst;
EXPECT_NO_THROW({
TEST_CYCLE() cv::ocl::dft(oclSrc, oclDst);
});
TEST_CYCLE() cv::ocl::dft(oclSrc, oclDst);
oclDst.download(dst);
SANITY_CHECK(dst);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::dft(src, dst);
SANITY_CHECK(dst);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
This diff is collapsed.
......@@ -51,11 +51,9 @@ using namespace perf;
typedef TestBaseWithParam<Size> gemmFixture;
PERF_TEST_P(gemmFixture, DISABLED_gemm, OCL_TYPICAL_MAT_SIZES)
PERF_TEST_P(gemmFixture, DISABLED_gemm, OCL_TYPICAL_MAT_SIZES) // TODO not implemented
{
// getting params
const Size srcSize = GetParam();
const std::string impl = getSelectedImpl();
Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1),
src3(srcSize, CV_32FC1), dst(srcSize, CV_32FC1);
......@@ -64,7 +62,7 @@ PERF_TEST_P(gemmFixture, DISABLED_gemm, OCL_TYPICAL_MAT_SIZES)
randu(src2, -10.0f, 10.0f);
randu(src3, -10.0f, 10.0f);
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc1(src1), oclSrc2(src2),
oclSrc3(src3), oclDst(srcSize, CV_32FC1);
......@@ -75,16 +73,12 @@ PERF_TEST_P(gemmFixture, DISABLED_gemm, OCL_TYPICAL_MAT_SIZES)
SANITY_CHECK(dst);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::gemm(src1, src2, 1.0, src3, 1.0, dst);
SANITY_CHECK(dst);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
......@@ -60,22 +60,22 @@ PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack,
string("gpu/stereobm/aloe-L.png")),
::testing::Range(0.0, 4.0, 3.0)))
{
std::vector<cv::Point2f> pts_gold;
// getting params
GoodFeaturesToTrackParams param = GetParam();
const string fileName = getDataPath(get<0>(param)), impl = getSelectedImpl();
const GoodFeaturesToTrackParams param = GetParam();
const string fileName = getDataPath(get<0>(param));
const int maxCorners = 2000;
const double qualityLevel = 0.01, minDistance = get<1>(param);
Mat frame = imread(fileName, IMREAD_GRAYSCALE);
declare.in(frame);
ASSERT_TRUE(!frame.empty()) << "no input image";
if (impl == "ocl")
vector<Point2f> pts_gold;
declare.in(frame);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclFrame(frame), pts_oclmat;
cv::ocl::GoodFeaturesToTrackDetector_OCL detector(maxCorners, qualityLevel, minDistance);
ocl::GoodFeaturesToTrackDetector_OCL detector(maxCorners, qualityLevel, minDistance);
TEST_CYCLE() detector(oclFrame, pts_oclmat);
......@@ -83,17 +83,13 @@ PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack,
SANITY_CHECK(pts_gold);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::goodFeaturesToTrack(frame, pts_gold,
maxCorners, qualityLevel, minDistance);
SANITY_CHECK(pts_gold);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
......@@ -88,14 +88,13 @@ public:
PERF_TEST(HaarFixture, Haar)
{
const std::string impl = getSelectedImpl();
vector<Rect> faces;
Mat img = imread(getDataPath("gpu/haarcascade/basketball1.png"), CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_TRUE(!img.empty()) << "can't open basketball1.png";
declare.in(img);
if (impl == "plain")
if (RUN_PLAIN_IMPL)
{
CascadeClassifier faceCascade;
ASSERT_TRUE(faceCascade.load(getDataPath("gpu/haarcascade/haarcascade_frontalface_alt.xml")))
......@@ -106,7 +105,7 @@ PERF_TEST(HaarFixture, Haar)
SANITY_CHECK(faces, 4 + 1e-4);
}
else if (impl == "ocl")
else if (RUN_OCL_IMPL)
{
ocl::CascadeClassifier_GPU faceCascade;
ocl::oclMat oclImg(img);
......@@ -119,11 +118,6 @@ PERF_TEST(HaarFixture, Haar)
SANITY_CHECK(faces, 4 + 1e-4);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
......@@ -54,22 +54,21 @@ PERF_TEST(HOGFixture, HOG)
Mat src = imread(getDataPath("gpu/hog/road.png"), cv::IMREAD_GRAYSCALE);
ASSERT_TRUE(!src.empty()) << "can't open input image road.png";
const std::string impl = getSelectedImpl();
std::vector<cv::Rect> found_locations;
vector<cv::Rect> found_locations;
declare.in(src).time(5);
if (impl == "plain")
if (RUN_PLAIN_IMPL)
{
cv::HOGDescriptor hog;
HOGDescriptor hog;
hog.setSVMDetector(hog.getDefaultPeopleDetector());
TEST_CYCLE() hog.detectMultiScale(src, found_locations);
SANITY_CHECK(found_locations, 1 + DBL_EPSILON);
}
else if (impl == "ocl")
else if (RUN_OCL_IMPL)
{
cv::ocl::HOGDescriptor ocl_hog;
ocl::HOGDescriptor ocl_hog;
ocl_hog.setSVMDetector(ocl_hog.getDefaultPeopleDetector());
ocl::oclMat oclSrc(src);
......@@ -77,10 +76,6 @@ PERF_TEST(HOGFixture, HOG)
SANITY_CHECK(found_locations, 1 + DBL_EPSILON);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
This diff is collapsed.
......@@ -51,23 +51,16 @@ using std::tr1::get;
/////////// matchTemplate ////////////////////////
CV_ENUM(CV_TM_CCORRMatType, CV_32FC1, CV_32FC4)
typedef tuple<Size, CV_TM_CCORRMatType> CV_TM_CCORRParams;
typedef TestBaseWithParam<CV_TM_CCORRParams> CV_TM_CCORRFixture;
typedef Size_MatType CV_TM_CCORRFixture;
PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate,
::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000),
CV_TM_CCORRMatType::all()))
OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
{
// getting params
CV_TM_CCORRParams params = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params), templSize(5, 5);
const int type = get<1>(params);
std::string impl = getSelectedImpl();
// creating src data
Mat src(srcSize, type), templ(templSize, type);
const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1);
Mat dst(dstSize, CV_32F);
......@@ -75,8 +68,7 @@ PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate,
randu(templ, 0.0f, 1.0f);
declare.time(srcSize == OCL_SIZE_2000 ? 20 : 6).in(src, templ).out(dst);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src), oclTempl(templ), oclDst(dstSize, CV_32F);
......@@ -86,37 +78,29 @@ PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate,
SANITY_CHECK(dst, 1e-4);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::matchTemplate(src, templ, dst, CV_TM_CCORR);
SANITY_CHECK(dst, 1e-4);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
typedef TestBaseWithParam<Size> CV_TM_CCORR_NORMEDFixture;
PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate, OCL_TYPICAL_MAT_SIZES)
{
// getting params
const Size srcSize = GetParam(), templSize(5, 5);
const std::string impl = getSelectedImpl();
// creating src data
Mat src(srcSize, CV_8UC1), templ(templSize, CV_8UC1), dst;
const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1);
dst.create(dstSize, CV_8UC1);
declare.in(src, templ, WARMUP_RNG).out(dst)
.time(srcSize == OCL_SIZE_2000 ? 10 : srcSize == OCL_SIZE_4000 ? 23 : 2);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src), oclTempl(templ), oclDst(dstSize, CV_8UC1);
......@@ -126,16 +110,12 @@ PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate, OCL_TYPICAL_MAT_SIZES)
SANITY_CHECK(dst, 2e-2);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::matchTemplate(src, templ, dst, CV_TM_CCORR_NORMED);
SANITY_CHECK(dst, 2e-2);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
......@@ -51,30 +51,22 @@ using std::tr1::get;
///////////// ConvertTo////////////////////////
CV_ENUM(ConvertToMatType, CV_8UC1, CV_8UC4)
typedef tuple<Size, ConvertToMatType> ConvertToParams;
typedef TestBaseWithParam<ConvertToParams> ConvertToFixture;
typedef Size_MatType ConvertToFixture;
PERF_TEST_P(ConvertToFixture, ConvertTo,
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
ConvertToMatType::all()))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
{
// getting params
ConvertToParams params = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
std::string impl = getSelectedImpl();
// creating src data
Mat src(srcSize, type), dst;
const int dstType = CV_MAKE_TYPE(CV_32F, src.channels());
dst.create(srcSize, dstType);
declare.in(src, WARMUP_RNG).out(dst);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src), oclDst(srcSize, dstType);
......@@ -84,43 +76,32 @@ PERF_TEST_P(ConvertToFixture, ConvertTo,
SANITY_CHECK(dst);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() src.convertTo(dst, dstType);
SANITY_CHECK(dst);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
///////////// copyTo////////////////////////
typedef ConvertToMatType copyToMatType;
typedef tuple<Size, copyToMatType> copyToParams;
typedef TestBaseWithParam<copyToParams> copyToFixture;
typedef Size_MatType copyToFixture;
PERF_TEST_P(copyToFixture, copyTo,
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
copyToMatType::all()))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
{
// getting params
copyToParams params = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
std::string impl = getSelectedImpl();
// creating src data
Mat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
......@@ -130,44 +111,33 @@ PERF_TEST_P(copyToFixture, copyTo,
SANITY_CHECK(dst);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() src.copyTo(dst);
SANITY_CHECK(dst);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
///////////// setTo////////////////////////
typedef ConvertToMatType setToMatType;
typedef tuple<Size, setToMatType> setToParams;
typedef TestBaseWithParam<setToParams> setToFixture;
typedef Size_MatType setToFixture;
PERF_TEST_P(setToFixture, setTo,
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
setToMatType::all()))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
{
// getting params
setToParams params = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
const Scalar val(1, 2, 3, 4);
std::string impl = getSelectedImpl();
// creating src data
Mat src(srcSize, type);
declare.in(src);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(srcSize, type);
......@@ -176,16 +146,12 @@ PERF_TEST_P(setToFixture, setTo,
SANITY_CHECK(src);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() src.setTo(val);
SANITY_CHECK(src);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
......@@ -52,50 +52,38 @@ using std::tr1::get;
///////////// Moments ////////////////////////
CV_ENUM(MomentsMatType, CV_8UC1, CV_16SC1, CV_32FC1, CV_64FC1)
typedef tuple<Size, MomentsMatType> MomentsParams;
typedef TestBaseWithParam<MomentsParams> MomentsFixture;
typedef Size_MatType MomentsFixture;
PERF_TEST_P(MomentsFixture, DISABLED_Moments,
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
MomentsMatType::all()))
OCL_PERF_ENUM(CV_8UC1, CV_16SC1, CV_32FC1, CV_64FC1))) // TODO does not work properly (see below)
{
// getting params
MomentsParams params = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
std::string impl = getSelectedImpl();
// creating src data
Mat src(srcSize, type), dst(7, 1, CV_64F);
const bool binaryImage = false;
cv::Moments mom;
declare.in(src, WARMUP_RNG).out(dst);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
TEST_CYCLE() mom = cv::ocl::ocl_moments(oclSrc, binaryImage);
TEST_CYCLE() mom = cv::ocl::ocl_moments(oclSrc, binaryImage); // TODO Use oclSrc
cv::HuMoments(mom, dst);
SANITY_CHECK(dst);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() mom = cv::moments(src, binaryImage);
cv::HuMoments(mom, dst);
SANITY_CHECK(dst);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
......@@ -53,21 +53,18 @@ using std::tr1::get;
typedef TestBaseWithParam<Size> normFixture;
PERF_TEST_P(normFixture, DISABLED_norm, OCL_TYPICAL_MAT_SIZES)
PERF_TEST_P(normFixture, DISABLED_norm, OCL_TYPICAL_MAT_SIZES) // TODO doesn't work properly
{
// getting params
const Size srcSize = GetParam();
const std::string impl = getSelectedImpl();
double value = 0.0;
// creating src data
Mat src1(srcSize, CV_8UC1), src2(srcSize, CV_8UC1);
declare.in(src1, src2);
randu(src1, 0, 1);
randu(src2, 0, 1);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc1(src1), oclSrc2(src2);
......@@ -75,16 +72,12 @@ PERF_TEST_P(normFixture, DISABLED_norm, OCL_TYPICAL_MAT_SIZES)
SANITY_CHECK(value);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() value = cv::norm(src1, src2, NORM_INF);
SANITY_CHECK(value);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -51,97 +51,74 @@ using std::tr1::get;
///////////// pyrDown //////////////////////
CV_ENUM(pyrDownMatType, CV_8UC1, CV_8UC4)
typedef tuple<Size, pyrDownMatType> pyrDownParams;
typedef TestBaseWithParam<pyrDownParams> pyrDownFixture;
typedef Size_MatType pyrDownFixture;
PERF_TEST_P(pyrDownFixture, pyrDown,
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
pyrDownMatType::all()))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
{
// getting params
pyrDownParams params = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
std::string impl = getSelectedImpl();
// creating src data
Mat src(srcSize, type), dst;
Size dstSize((srcSize.height + 1) >> 1, (srcSize.width + 1) >> 1);
dst.create(dstSize, type);
declare.in(src).out(dst);
declare.in(src, WARMUP_RNG).out(dst);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src), oclDst(dstSize, type);
TEST_CYCLE() cv::ocl::pyrDown(oclSrc, oclDst);
TEST_CYCLE() ocl::pyrDown(oclSrc, oclDst);
oclDst.download(dst);
SANITY_CHECK(dst);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::pyrDown(src, dst);
TEST_CYCLE() pyrDown(src, dst);
SANITY_CHECK(dst);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
///////////// pyrUp ////////////////////////
typedef pyrDownMatType pyrUpMatType;
typedef tuple<Size, pyrUpMatType> pyrUpParams;
typedef TestBaseWithParam<pyrUpParams> pyrUpFixture;
typedef Size_MatType pyrUpFixture;
PERF_TEST_P(pyrUpFixture, pyrUp,
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
pyrUpMatType::all()))
OCL_PERF_ENUM(CV_8UC1, CV_8UC4)))
{
// getting params
pyrUpParams params = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
std::string impl = getSelectedImpl();
// creating src data
Mat src(srcSize, type), dst;
Size dstSize(srcSize.height << 1, srcSize.width << 1);
dst.create(dstSize, type);
declare.in(src).out(dst);
declare.in(src, WARMUP_RNG).out(dst);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src), oclDst(dstSize, type);
TEST_CYCLE() cv::ocl::pyrDown(oclSrc, oclDst);
TEST_CYCLE() ocl::pyrDown(oclSrc, oclDst);
oclDst.download(dst);
SANITY_CHECK(dst);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::pyrDown(src, dst);
TEST_CYCLE() pyrDown(src, dst);
SANITY_CHECK(dst);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
......@@ -51,23 +51,16 @@ using std::tr1::get;
///////////// Merge////////////////////////
CV_ENUM(MergeMatType, CV_8U, CV_32F)
typedef tuple<Size, MergeMatType> MergeParams;
typedef TestBaseWithParam<MergeParams> MergeFixture;
typedef Size_MatType MergeFixture;
PERF_TEST_P(MergeFixture, Merge,
::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000),
MergeMatType::all()))
OCL_PERF_ENUM(CV_8U, CV_32F)))
{
// getting params
MergeParams params = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int depth = get<1>(params), channels = 3;
std::string impl = getSelectedImpl();
// creating src data
const int dstType = CV_MAKE_TYPE(depth, channels);
Mat dst(srcSize, dstType);
vector<Mat> src(channels);
......@@ -78,8 +71,7 @@ PERF_TEST_P(MergeFixture, Merge,
}
declare.out(dst);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclDst(srcSize, dstType);
vector<ocl::oclMat> oclSrc(src.size());
......@@ -92,50 +84,39 @@ PERF_TEST_P(MergeFixture, Merge,
SANITY_CHECK(dst);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::merge(src, dst);
SANITY_CHECK(dst);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
OCL_PERF_ELSE
}
///////////// Split////////////////////////
typedef MergeMatType SplitMatType;
typedef tuple<Size, SplitMatType> SplitParams;
typedef TestBaseWithParam<SplitParams> SplitFixture;
typedef Size_MatType SplitFixture;
PERF_TEST_P(SplitFixture, Split,
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
SplitMatType::all()))
OCL_PERF_ENUM(CV_8U, CV_32F)))
{
// getting params
MergeParams params = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int depth = get<1>(params), channels = 3;
std::string impl = getSelectedImpl();
// creating src data
Mat src(srcSize, CV_MAKE_TYPE(depth, channels));
declare.in(src, WARMUP_RNG);
// select implementation
if (impl == "ocl")
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
vector<ocl::oclMat> oclDst(channels, ocl::oclMat(srcSize, CV_MAKE_TYPE(depth, 1)));
TEST_CYCLE() cv::ocl::split(oclSrc, oclDst);
AssertEQ(channels, 3);
ASSERT_EQ(3, channels);
Mat dst0, dst1, dst2;
oclDst[0].download(dst0);
oclDst[1].download(dst1);
......@@ -144,21 +125,17 @@ PERF_TEST_P(SplitFixture, Split,
SANITY_CHECK(dst1);
SANITY_CHECK(dst2);
}
else if (impl == "plain")
else if (RUN_PLAIN_IMPL)
{
vector<Mat> dst(channels, Mat(srcSize, CV_MAKE_TYPE(depth, 1)));
TEST_CYCLE() cv::split(src, dst);
AssertEQ(channels, 3);
ASSERT_EQ(3, channels);
Mat & dst0 = dst[0], & dst1 = dst[1], & dst2 = dst[2];
SANITY_CHECK(dst0);
SANITY_CHECK(dst1);
SANITY_CHECK(dst2);
}
#ifdef HAVE_OPENCV_GPU
else if (impl == "gpu")
CV_TEST_FAIL_NO_IMPL();
#endif
else
CV_TEST_FAIL_NO_IMPL();
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