2013-01-29 16:26:12 +08:00
|
|
|
#include "perf_precomp.hpp"
|
2013-03-13 20:22:44 +08:00
|
|
|
#include <opencv2/imgproc.hpp>
|
2013-01-29 16:26:12 +08:00
|
|
|
|
|
|
|
using cv::Rect;
|
|
|
|
using std::tr1::get;
|
|
|
|
|
2013-02-01 18:25:10 +08:00
|
|
|
|
|
|
|
using namespace cv::softcascade;
|
|
|
|
|
2013-01-29 16:26:12 +08:00
|
|
|
typedef std::tr1::tuple<std::string, std::string> fixture;
|
|
|
|
typedef perf::TestBaseWithParam<fixture> detect;
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2013-02-01 18:25:10 +08:00
|
|
|
void extractRacts(std::vector<Detection> objectBoxes, std::vector<Rect>& rects)
|
2013-01-29 16:26:12 +08:00
|
|
|
{
|
|
|
|
rects.clear();
|
|
|
|
for (int i = 0; i < (int)objectBoxes.size(); ++i)
|
2013-03-15 16:26:25 +08:00
|
|
|
rects.push_back(objectBoxes[i].bb());
|
2013-01-29 16:26:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-29 17:09:49 +08:00
|
|
|
PERF_TEST_P(detect, SoftCascadeDetector,
|
2013-01-29 16:26:12 +08:00
|
|
|
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());
|
|
|
|
|
2013-02-01 18:25:10 +08:00
|
|
|
Detector cascade;
|
2013-01-29 16:26:12 +08:00
|
|
|
cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ);
|
|
|
|
ASSERT_TRUE(fs.isOpened());
|
|
|
|
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
|
|
|
|
|
2013-02-01 18:25:10 +08:00
|
|
|
std::vector<Detection> objectBoxes;
|
2013-01-29 16:26:12 +08:00
|
|
|
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);
|
|
|
|
}
|