SURF accuracy test is moved to nonfree

This commit is contained in:
Andrey Kamaev 2013-03-16 19:34:39 +04:00
parent 6846f881a2
commit 1be58f9a00
5 changed files with 46 additions and 45 deletions

View File

@ -69,5 +69,3 @@ int main(int argc, char** argv)
#else // HAVE_CUDA
CV_TEST_MAIN("cv")
#endif // HAVE_CUDA

View File

@ -9,16 +9,16 @@
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
#include <iostream>
#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"

View File

@ -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<cv::KeyPoint, cv::KeyPoint, bool>
{
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<cv::KeyPoint>& gold, std::vector<cv::KeyPoint>& 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<cv::KeyPoint>& 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

View File

@ -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);

View File

@ -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"