perf_softcascade.cpp 1.26 KB
Newer Older
1
#include "perf_precomp.hpp"
2
#include <opencv2/imgproc.hpp>
3 4 5 6

using cv::Rect;
using std::tr1::get;

7 8 9

using namespace cv::softcascade;

10 11 12 13 14 15
typedef std::tr1::tuple<std::string, std::string> fixture;
typedef perf::TestBaseWithParam<fixture> detect;


namespace {

16
void extractRacts(std::vector<Detection> objectBoxes, std::vector<Rect>& rects)
17 18 19
{
    rects.clear();
    for (int i = 0; i < (int)objectBoxes.size(); ++i)
20
        rects.push_back(objectBoxes[i].bb());
21 22 23 24
}

}

25
PERF_TEST_P(detect, SoftCascadeDetector,
26 27 28 29 30 31
    testing::Combine(testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml")),
    testing::Values(std::string("cv/cascadeandhog/images/image_00000000_0.png"))))
{
    cv::Mat colored = cv::imread(getDataPath(get<1>(GetParam())));
    ASSERT_FALSE(colored.empty());

32
    Detector cascade;
33 34 35 36
    cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ);
    ASSERT_TRUE(fs.isOpened());
    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));

37
    std::vector<Detection> objectBoxes;
38 39 40 41 42 43 44 45 46
    TEST_CYCLE()
    {
        cascade.detect(colored, cv::noArray(), objectBoxes);
    }

    std::vector<Rect> rects;
    extractRacts(objectBoxes, rects);
    std::sort(rects.begin(), rects.end(), perf::comparators::RectLess());
    SANITY_CHECK(rects);
47
}