From 1be58f9a00797291959c06c89b801fa78989f683 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Sat, 16 Mar 2013 19:34:39 +0400 Subject: [PATCH] SURF accuracy test is moved to nonfree --- modules/nonfree/test/test_main.cpp | 2 - modules/nonfree/test/test_precomp.hpp | 10 +-- .../test/test_surf.ocl.cpp} | 76 ++++++++++--------- modules/ocl/src/initialization.cpp | 1 - modules/ocl/test/precomp.hpp | 2 - 5 files changed, 46 insertions(+), 45 deletions(-) rename modules/{ocl/test/test_surf.cpp => nonfree/test/test_surf.ocl.cpp} (77%) diff --git a/modules/nonfree/test/test_main.cpp b/modules/nonfree/test/test_main.cpp index bf4c6c0c3b..57e41901eb 100644 --- a/modules/nonfree/test/test_main.cpp +++ b/modules/nonfree/test/test_main.cpp @@ -69,5 +69,3 @@ int main(int argc, char** argv) #else // HAVE_CUDA CV_TEST_MAIN("cv") - -#endif // HAVE_CUDA diff --git a/modules/nonfree/test/test_precomp.hpp b/modules/nonfree/test/test_precomp.hpp index 14c4b2a874..15f2b95735 100644 --- a/modules/nonfree/test/test_precomp.hpp +++ b/modules/nonfree/test/test_precomp.hpp @@ -9,16 +9,16 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ -#include - -#include "cvconfig.h" -#include "opencv2/opencv_modules.hpp" - #include "opencv2/ts/ts.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/nonfree/nonfree.hpp" +#include "opencv2/opencv_modules.hpp" +#ifdef HAVE_OPENCV_OCL +# include "opencv2/nonfree/ocl.hpp" +#endif + #if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA) #include "opencv2/ts/gpu_test.hpp" #include "opencv2/nonfree/gpu.hpp" diff --git a/modules/ocl/test/test_surf.cpp b/modules/nonfree/test/test_surf.ocl.cpp similarity index 77% rename from modules/ocl/test/test_surf.cpp rename to modules/nonfree/test/test_surf.ocl.cpp index c4cf60fcbc..2648b6ad96 100644 --- a/modules/ocl/test/test_surf.cpp +++ b/modules/nonfree/test/test_surf.ocl.cpp @@ -43,13 +43,12 @@ // //M*/ +#include "test_precomp.hpp" -#include "precomp.hpp" -#ifdef HAVE_OPENCL - -extern std::string workdir; +#ifdef HAVE_OPENCV_OCL using namespace std; +using std::tr1::get; static bool keyPointsEquals(const cv::KeyPoint& p1, const cv::KeyPoint& p2) { @@ -73,22 +72,12 @@ static bool keyPointsEquals(const cv::KeyPoint& p1, const cv::KeyPoint& p2) return false; } - -struct KeyPointLess : std::binary_function -{ - bool operator()(const cv::KeyPoint& kp1, const cv::KeyPoint& kp2) const - { - return kp1.pt.y < kp2.pt.y || (kp1.pt.y == kp2.pt.y && kp1.pt.x < kp2.pt.x); - } -}; - - #define ASSERT_KEYPOINTS_EQ(gold, actual) EXPECT_PRED_FORMAT2(assertKeyPointsEquals, gold, actual); static int getMatchedPointsCount(std::vector& gold, std::vector& actual) { - std::sort(actual.begin(), actual.end(), KeyPointLess()); - std::sort(gold.begin(), gold.end(), KeyPointLess()); + std::sort(actual.begin(), actual.end(), perf::comparators::KeypointGreater()); + std::sort(gold.begin(), gold.end(), perf::comparators::KeypointGreater()); int validCount = 0; @@ -122,13 +111,29 @@ static int getMatchedPointsCount(const std::vector& keypoints1, co return validCount; } -IMPLEMENT_PARAM_CLASS(SURF_HessianThreshold, double) -IMPLEMENT_PARAM_CLASS(SURF_Octaves, int) -IMPLEMENT_PARAM_CLASS(SURF_OctaveLayers, int) -IMPLEMENT_PARAM_CLASS(SURF_Extended, bool) -IMPLEMENT_PARAM_CLASS(SURF_Upright, bool) +#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > > +#define IMPLEMENT_PARAM_CLASS(name, type) \ + namespace { \ + class name \ + { \ + public: \ + name ( type arg = type ()) : val_(arg) {} \ + operator type () const {return val_;} \ + private: \ + type val_; \ + }; \ + inline void PrintTo( name param, std::ostream* os) \ + { \ + *os << #name << "(" << testing::PrintToString(static_cast< type >(param)) << ")"; \ + }} -PARAM_TEST_CASE(SURF, SURF_HessianThreshold, SURF_Octaves, SURF_OctaveLayers, SURF_Extended, SURF_Upright) +IMPLEMENT_PARAM_CLASS(HessianThreshold, double) +IMPLEMENT_PARAM_CLASS(Octaves, int) +IMPLEMENT_PARAM_CLASS(OctaveLayers, int) +IMPLEMENT_PARAM_CLASS(Extended, bool) +IMPLEMENT_PARAM_CLASS(Upright, bool) + +PARAM_TEST_CASE(SURF, HessianThreshold, Octaves, OctaveLayers, Extended, Upright) { double hessianThreshold; int nOctaves; @@ -138,16 +143,17 @@ PARAM_TEST_CASE(SURF, SURF_HessianThreshold, SURF_Octaves, SURF_OctaveLayers, SU virtual void SetUp() { - hessianThreshold = GET_PARAM(0); - nOctaves = GET_PARAM(1); - nOctaveLayers = GET_PARAM(2); - extended = GET_PARAM(3); - upright = GET_PARAM(4); + hessianThreshold = get<0>(GetParam()); + nOctaves = get<1>(GetParam()); + nOctaveLayers = get<2>(GetParam()); + extended = get<3>(GetParam()); + upright = get<4>(GetParam()); } }; + TEST_P(SURF, Detector) { - cv::Mat image = readImage(workdir + "fruits.jpg", cv::IMREAD_GRAYSCALE); + cv::Mat image = cv::imread(string(cvtest::TS::ptr()->get_data_path()) + "shared/fruits.png", cv::IMREAD_GRAYSCALE); ASSERT_FALSE(image.empty()); cv::ocl::SURF_OCL surf; @@ -180,7 +186,7 @@ TEST_P(SURF, Detector) TEST_P(SURF, Descriptor) { - cv::Mat image = readImage(workdir + "fruits.jpg", cv::IMREAD_GRAYSCALE); + cv::Mat image = cv::imread(string(cvtest::TS::ptr()->get_data_path()) + "shared/fruits.png", cv::IMREAD_GRAYSCALE); ASSERT_FALSE(image.empty()); cv::ocl::SURF_OCL surf; @@ -218,10 +224,10 @@ TEST_P(SURF, Descriptor) } INSTANTIATE_TEST_CASE_P(OCL_Features2D, SURF, testing::Combine( - testing::Values(/*SURF_HessianThreshold(100.0), */SURF_HessianThreshold(500.0), SURF_HessianThreshold(1000.0)), - testing::Values(SURF_Octaves(3), SURF_Octaves(4)), - testing::Values(SURF_OctaveLayers(2), SURF_OctaveLayers(3)), - testing::Values(SURF_Extended(false), SURF_Extended(true)), - testing::Values(SURF_Upright(false), SURF_Upright(true)))); + testing::Values(HessianThreshold(500.0), HessianThreshold(1000.0)), + testing::Values(Octaves(3), Octaves(4)), + testing::Values(OctaveLayers(2), OctaveLayers(3)), + testing::Values(Extended(false), Extended(true)), + testing::Values(Upright(false), Upright(true)))); -#endif +#endif // HAVE_OPENCV_OCL diff --git a/modules/ocl/src/initialization.cpp b/modules/ocl/src/initialization.cpp index 5930562cf9..7782046e33 100644 --- a/modules/ocl/src/initialization.cpp +++ b/modules/ocl/src/initialization.cpp @@ -331,7 +331,6 @@ namespace cv size_t widthInBytes, size_t height, DevMemRW rw_type, DevMemType mem_type) { cl_int status; - *dev_ptr = clCreateBuffer(clCxt->impl->clContext, gDevMemRWValueMap[rw_type]|gDevMemTypeValueMap[mem_type], widthInBytes * height, 0, &status); openCLVerifyCall(status); diff --git a/modules/ocl/test/precomp.hpp b/modules/ocl/test/precomp.hpp index e8c1aaa1b9..eec938ee81 100644 --- a/modules/ocl/test/precomp.hpp +++ b/modules/ocl/test/precomp.hpp @@ -68,9 +68,7 @@ #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/video/video.hpp" #include "opencv2/ts/ts.hpp" -#include "opencv2/ts/ts_perf.hpp" #include "opencv2/ocl/ocl.hpp" -#include "opencv2/nonfree/nonfree.hpp" #include "utility.hpp" #include "interpolation.hpp"