2011-09-08 03:52:52 +08:00
|
|
|
#include "perf_precomp.hpp"
|
2013-03-13 20:22:44 +08:00
|
|
|
#include <opencv2/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"),
|
2012-12-20 16:25:59 +08:00
|
|
|
std::string("cv/shared/1_itseez-0000573.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());
|
2012-12-24 12:43:04 +08:00
|
|
|
}
|