2011-09-08 03:52:52 +08:00
|
|
|
#include "perf_precomp.hpp"
|
2011-09-29 05:14:20 +08:00
|
|
|
#include <opencv2/imgproc/imgproc.hpp>
|
2011-09-08 03:52:52 +08:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace cv;
|
|
|
|
using namespace perf;
|
2011-12-30 00:46:16 +08:00
|
|
|
using std::tr1::make_tuple;
|
|
|
|
using std::tr1::get;
|
2011-09-08 03:52:52 +08:00
|
|
|
|
2011-09-08 17:29:27 +08:00
|
|
|
typedef std::tr1::tuple<std::string, int> ImageName_MinSize_t;
|
2011-09-08 03:52:52 +08:00
|
|
|
typedef perf::TestBaseWithParam<ImageName_MinSize_t> ImageName_MinSize;
|
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
PERF_TEST_P(ImageName_MinSize, CascadeClassifierLBPFrontalFace,
|
2012-10-03 03:07:46 +08:00
|
|
|
testing::Combine(testing::Values( std::string("cv/shared/lena.png"),
|
|
|
|
std::string("cv/shared/1_itseez-0000289.png"),
|
|
|
|
std::string("cv/shared/1_itseez-0000492.png"),
|
|
|
|
std::string("cv/shared/1_itseez-0000573.png"),
|
|
|
|
std::string("cv/shared/1_itseez-0000892.png"),
|
|
|
|
std::string("cv/shared/1_itseez-0001238.png"),
|
|
|
|
std::string("cv/shared/1_itseez-0001438.png"),
|
|
|
|
std::string("cv/shared/1_itseez-0002524.png")),
|
2011-12-30 00:46:16 +08:00
|
|
|
testing::Values(24, 30, 40, 50, 60, 70, 80, 90)
|
|
|
|
)
|
|
|
|
)
|
2011-09-08 03:52:52 +08:00
|
|
|
{
|
2011-12-30 00:46:16 +08:00
|
|
|
const string filename = get<0>(GetParam());
|
|
|
|
int min_size = get<1>(GetParam());
|
2011-09-08 03:52:52 +08:00
|
|
|
Size minSize(min_size, min_size);
|
|
|
|
|
|
|
|
CascadeClassifier cc(getDataPath("cv/cascadeandhog/cascades/lbpcascade_frontalface.xml"));
|
2011-09-08 17:29:27 +08:00
|
|
|
if (cc.empty())
|
|
|
|
FAIL() << "Can't load cascade file";
|
2011-09-08 03:52:52 +08:00
|
|
|
|
2012-06-22 23:00:36 +08:00
|
|
|
Mat img = imread(getDataPath(filename), 0);
|
2011-09-08 17:29:27 +08:00
|
|
|
if (img.empty())
|
|
|
|
FAIL() << "Can't load source image";
|
|
|
|
|
2012-10-09 19:28:10 +08:00
|
|
|
vector<Rect> faces;
|
2011-09-08 03:52:52 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
equalizeHist(img, img);
|
|
|
|
declare.in(img);
|
2011-09-08 17:29:27 +08:00
|
|
|
|
|
|
|
while(next())
|
2011-09-08 03:52:52 +08:00
|
|
|
{
|
2012-10-09 19:28:10 +08:00
|
|
|
faces.clear();
|
2011-09-08 17:29:27 +08:00
|
|
|
|
|
|
|
startTimer();
|
2012-10-09 19:28:10 +08:00
|
|
|
cc.detectMultiScale(img, faces, 1.1, 3, 0, minSize);
|
2011-09-08 17:29:27 +08:00
|
|
|
stopTimer();
|
2011-09-08 03:52:52 +08:00
|
|
|
}
|
2012-10-09 19:28:10 +08:00
|
|
|
|
|
|
|
std::sort(faces.begin(), faces.end(), comparators::RectLess());
|
2012-11-01 20:29:30 +08:00
|
|
|
SANITY_CHECK(faces, 3.001 * faces.size());
|
2011-09-08 03:52:52 +08:00
|
|
|
}
|
2012-09-28 14:21:22 +08:00
|
|
|
|
|
|
|
typedef std::tr1::tuple<std::string, std::string> fixture;
|
|
|
|
typedef perf::TestBaseWithParam<fixture> detect;
|
|
|
|
|
|
|
|
PERF_TEST_P(detect, SoftCascade,
|
|
|
|
testing::Combine(testing::Values(std::string("cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml")),
|
|
|
|
testing::Values(std::string("cv/cascadeandhog/bahnhof/image_00000000_0.png"))))
|
|
|
|
{
|
2012-10-07 01:43:25 +08:00
|
|
|
typedef cv::SoftCascade::Detection detection_t;
|
2012-09-28 14:21:22 +08:00
|
|
|
cv::Mat colored = imread(getDataPath(get<1>(GetParam())));
|
|
|
|
ASSERT_FALSE(colored.empty());
|
|
|
|
|
|
|
|
cv::SoftCascade cascade;
|
|
|
|
ASSERT_TRUE(cascade.load(getDataPath(get<0>(GetParam()))));
|
|
|
|
|
2012-10-07 01:43:25 +08:00
|
|
|
std::vector<cv::Rect> rois;
|
|
|
|
std::vector<detection_t> objectBoxes;
|
2012-09-28 14:21:22 +08:00
|
|
|
cascade.detectMultiScale(colored, rois, objectBoxes);
|
|
|
|
|
|
|
|
TEST_CYCLE()
|
|
|
|
{
|
|
|
|
cascade.detectMultiScale(colored, rois, objectBoxes);
|
|
|
|
}
|
|
|
|
SANITY_CHECK(objectBoxes);
|
|
|
|
}
|