From fa5705613da45ab5627b2f9006e355c6dca31afc Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Tue, 25 Mar 2014 16:19:45 +0400 Subject: [PATCH] splitting plain and OCL tests for SURF. --- modules/nonfree/perf/perf_main.cpp | 2 +- modules/nonfree/perf/perf_surf.cpp | 92 +++++++------------------- modules/nonfree/perf/perf_surf_ocl.cpp | 89 +++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 69 deletions(-) diff --git a/modules/nonfree/perf/perf_main.cpp b/modules/nonfree/perf/perf_main.cpp index 9a877202f..447cf395e 100644 --- a/modules/nonfree/perf/perf_main.cpp +++ b/modules/nonfree/perf/perf_main.cpp @@ -36,6 +36,6 @@ int main(int argc, char **argv) #elif defined(HAVE_OPENCL) CV_PERF_TEST_MAIN_INTERNALS(nonfree, impls, dumpOpenCLDevice()); #else - CV_PERF_TEST_MAIN_INTERNALS(ocl, impls) + CV_PERF_TEST_MAIN_INTERNALS(nonfree, impls) #endif } diff --git a/modules/nonfree/perf/perf_surf.cpp b/modules/nonfree/perf/perf_surf.cpp index 69468db41..85b233951 100644 --- a/modules/nonfree/perf/perf_surf.cpp +++ b/modules/nonfree/perf/perf_surf.cpp @@ -12,98 +12,54 @@ typedef perf::TestBaseWithParam surf; "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\ "stitching/a3.png" -#ifdef HAVE_OPENCV_OCL -#define OCL_TEST_CYCLE() for( ; startTimer(), next(); cv::ocl::finish(), stopTimer()) -#endif - -PERF_TEST_P(surf, DISABLED_detect, testing::Values(SURF_IMAGES)) +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; - declare.in(frame); - Mat mask; + declare.in(frame).time(90); + SURF detector; vector points; - Ptr detector; - 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(); + TEST_CYCLE() detector(frame, mask, points); SANITY_CHECK_KEYPOINTS(points, 1e-3); } -PERF_TEST_P(surf, DISABLED_extract, testing::Values(SURF_IMAGES)) +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; - declare.in(frame); - Mat mask; - Ptr detector; - vector points; - vector descriptors; - - 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); -} - -PERF_TEST_P(surf, DISABLED_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; - declare.in(frame).time(90); + SURF detector; + vector points; + vector descriptors; + detector(frame, mask, points); + + TEST_CYCLE() detector(frame, mask, points, descriptors, true); + + SANITY_CHECK(descriptors, 1e-4); +} + +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; + Mat mask; - Ptr detector; + declare.in(frame).time(90); + SURF detector; vector points; vector descriptors; - 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(); + TEST_CYCLE() detector(frame, mask, points, descriptors, false); SANITY_CHECK_KEYPOINTS(points, 1e-3); SANITY_CHECK(descriptors, 1e-4); diff --git a/modules/nonfree/perf/perf_surf_ocl.cpp b/modules/nonfree/perf/perf_surf_ocl.cpp index 4528b7926..1a2f8cd0b 100644 --- a/modules/nonfree/perf/perf_surf_ocl.cpp +++ b/modules/nonfree/perf/perf_surf_ocl.cpp @@ -121,4 +121,93 @@ PERF_TEST_P(OCL_SURF, without_data_transfer, testing::Values(SURF_IMAGES)) SANITY_CHECK_NOTHING(); } + + +PERF_TEST_P(OCL_SURF, DISABLED_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; + + declare.in(frame); + + Mat mask; + vector points; + Ptr detector; + + if (getSelectedImpl() == "plain") + { + detector = new SURF; + TEST_CYCLE() detector->operator()(frame, mask, points, noArray()); + } + else if (getSelectedImpl() == "ocl") + { + detector = new ocl::SURF_OCL; + OCL_TEST_CYCLE() detector->operator()(frame, mask, points, noArray()); + } + else CV_TEST_FAIL_NO_IMPL(); + + SANITY_CHECK_KEYPOINTS(points, 1e-3); +} + +PERF_TEST_P(OCL_SURF, DISABLED_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; + + declare.in(frame); + + Mat mask; + Ptr detector; + vector points; + vector descriptors; + + if (getSelectedImpl() == "plain") + { + detector = new SURF; + detector->operator()(frame, mask, points, noArray()); + TEST_CYCLE() detector->operator()(frame, mask, points, descriptors, true); + } + 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); + } + else CV_TEST_FAIL_NO_IMPL(); + + SANITY_CHECK(descriptors, 1e-4); +} + +PERF_TEST_P(OCL_SURF, DISABLED_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; + + declare.in(frame).time(90); + + Mat mask; + Ptr detector; + vector points; + vector descriptors; + + if (getSelectedImpl() == "plain") + { + detector = new SURF; + TEST_CYCLE() detector->operator()(frame, mask, points, descriptors, false); + } + 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); + } + else CV_TEST_FAIL_NO_IMPL(); + + SANITY_CHECK_KEYPOINTS(points, 1e-3); + SANITY_CHECK(descriptors, 1e-4); +} + #endif // HAVE_OPENCV_OCL