1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

making OCL tests conform to the comon style

This commit is contained in:
Andrey Pavlenko
2014-03-24 10:08:44 +04:00
parent 22f42a639f
commit 5421d741bc
3 changed files with 80 additions and 32 deletions
+52 -31
View File
@@ -13,36 +13,34 @@ typedef perf::TestBaseWithParam<std::string> surf;
"stitching/a3.png"
#ifdef HAVE_OPENCV_OCL
static Ptr<Feature2D> getSURF()
{
ocl::PlatformsInfo p;
if(ocl::getOpenCLPlatforms(p) > 0)
return new ocl::SURF_OCL;
else
return new SURF;
}
#else
static Ptr<Feature2D> getSURF()
{
return new SURF;
}
#define OCL_TEST_CYCLE() for( ; startTimer(), next(); cv::ocl::finish(), stopTimer())
#endif
PERF_TEST_P(surf, detect, testing::Values(SURF_IMAGES))
{
String filename = getDataPath(GetParam());
Mat frame = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename;
if (frame.empty())
FAIL() << "Unable to load source image " << filename;
declare.in(frame);
Mat mask;
declare.in(frame).time(90);
Ptr<Feature2D> detector = getSURF();
vector<KeyPoint> points;
Ptr<Feature2D> detector;
TEST_CYCLE() detector->operator()(frame, mask, points, noArray());
if (getSelectedImpl() == "plain")
{
detector = new SURF;
TEST_CYCLE() detector->operator()(frame, mask, points, noArray());
}
#ifdef HAVE_OPENCV_OCL
else if (getSelectedImpl() == "ocl")
{
detector = new ocl::SURF_OCL;
OCL_TEST_CYCLE() detector->operator()(frame, mask, points, noArray());
}
#endif
else CV_TEST_FAIL_NO_IMPL();
SANITY_CHECK_KEYPOINTS(points, 1e-3);
}
@@ -51,19 +49,30 @@ PERF_TEST_P(surf, extract, testing::Values(SURF_IMAGES))
{
String filename = getDataPath(GetParam());
Mat frame = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename;
if (frame.empty())
FAIL() << "Unable to load source image " << filename;
declare.in(frame);
Mat mask;
declare.in(frame).time(90);
Ptr<Feature2D> detector = getSURF();
Ptr<Feature2D> detector;
vector<KeyPoint> points;
vector<float> descriptors;
detector->operator()(frame, mask, points, noArray());
TEST_CYCLE() detector->operator()(frame, mask, points, descriptors, true);
if (getSelectedImpl() == "plain")
{
detector = new SURF;
detector->operator()(frame, mask, points, noArray());
TEST_CYCLE() detector->operator()(frame, mask, points, descriptors, true);
}
#ifdef HAVE_OPENCV_OCL
else if (getSelectedImpl() == "ocl")
{
detector = new ocl::SURF_OCL;
detector->operator()(frame, mask, points, noArray());
OCL_TEST_CYCLE() detector->operator()(frame, mask, points, descriptors, true);
}
#endif
else CV_TEST_FAIL_NO_IMPL();
SANITY_CHECK(descriptors, 1e-4);
}
@@ -72,17 +81,29 @@ PERF_TEST_P(surf, full, testing::Values(SURF_IMAGES))
{
String filename = getDataPath(GetParam());
Mat frame = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename;
if (frame.empty())
FAIL() << "Unable to load source image " << filename;
declare.in(frame).time(90);
Mat mask;
declare.in(frame).time(90);
Ptr<Feature2D> detector = getSURF();
Ptr<Feature2D> detector;
vector<KeyPoint> points;
vector<float> descriptors;
TEST_CYCLE() detector->operator()(frame, mask, points, descriptors, false);
if (getSelectedImpl() == "plain")
{
detector = new SURF;
TEST_CYCLE() detector->operator()(frame, mask, points, descriptors, false);
}
#ifdef HAVE_OPENCV_OCL
else if (getSelectedImpl() == "ocl")
{
detector = new ocl::SURF_OCL;
detector->operator()(frame, mask, points, noArray());
OCL_TEST_CYCLE() detector->operator()(frame, mask, points, descriptors, false);
}
#endif
else CV_TEST_FAIL_NO_IMPL();
SANITY_CHECK_KEYPOINTS(points, 1e-3);
SANITY_CHECK(descriptors, 1e-4);