perf_surf.cpp 1.77 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include "perf_precomp.hpp"

using namespace std;
using namespace cv;
using namespace cv::xfeatures2d;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;

typedef perf::TestBaseWithParam<std::string> surf;

#define SURF_IMAGES \
    "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
    "stitching/a3.png"

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;

    Mat mask;
    declare.in(frame).time(90);
24
    Ptr<SURF> detector = SURF::create();
25 26
    vector<KeyPoint> points;

27
    TEST_CYCLE() detector->detect(frame, points, mask);
28

29
    SANITY_CHECK_NOTHING();
30 31 32 33 34 35 36 37 38 39 40
}

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;

    Mat mask;
    declare.in(frame).time(90);

41
    Ptr<SURF> detector = SURF::create();
42 43
    vector<KeyPoint> points;
    vector<float> descriptors;
44
    detector->detect(frame, points, mask);
45

46
    TEST_CYCLE() detector->compute(frame, points, descriptors);
47

48
    SANITY_CHECK_NOTHING();
49 50 51 52 53 54 55 56 57 58
}

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;
    declare.in(frame).time(90);
59
    Ptr<SURF> detector = SURF::create();
60 61 62
    vector<KeyPoint> points;
    vector<float> descriptors;

63
    TEST_CYCLE() detector->detectAndCompute(frame, mask, points, descriptors, false);
64

65
    SANITY_CHECK_NOTHING();
66
}