Merge pull request #2133 from apavlenko:2.4-perf_haar

This commit is contained in:
Roman Donchenko 2014-01-13 19:28:09 +04:00 committed by OpenCV Buildbot
commit 2443e8090e

View File

@ -83,3 +83,69 @@ PERF_TEST(HaarFixture, Haar)
else
OCL_PERF_ELSE
}
using namespace std;
using namespace cv;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
typedef std::tr1::tuple<std::string, std::string, int> OCL_Cascade_Image_MinSize_t;
typedef perf::TestBaseWithParam<OCL_Cascade_Image_MinSize_t> OCL_Cascade_Image_MinSize;
PERF_TEST_P( OCL_Cascade_Image_MinSize, CascadeClassifier,
testing::Combine(
testing::Values( string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt.xml") ),
testing::Values( string("cv/shared/lena.png"),
string("cv/cascadeandhog/images/bttf301.png"),
string("cv/cascadeandhog/images/class57.png") ),
testing::Values(30, 64, 90) ) )
{
const string cascasePath = get<0>(GetParam());
const string imagePath = get<1>(GetParam());
const int min_size = get<2>(GetParam());
Size minSize(min_size, min_size);
vector<Rect> faces;
Mat img = imread(getDataPath(imagePath), IMREAD_GRAYSCALE);
ASSERT_TRUE(!img.empty()) << "Can't load source image: " << getDataPath(imagePath);
equalizeHist(img, img);
declare.in(img);
if (RUN_PLAIN_IMPL)
{
CascadeClassifier cc;
ASSERT_TRUE(cc.load(getDataPath(cascasePath))) << "Can't load cascade file: " << getDataPath(cascasePath);
while (next())
{
faces.clear();
startTimer();
cc.detectMultiScale(img, faces, 1.1, 3, 0, minSize);
stopTimer();
}
}
else if (RUN_OCL_IMPL)
{
ocl::oclMat uimg(img);
ocl::OclCascadeClassifier cc;
ASSERT_TRUE(cc.load(getDataPath(cascasePath))) << "Can't load cascade file: " << getDataPath(cascasePath);
while (next())
{
faces.clear();
ocl::finish();
startTimer();
cc.detectMultiScale(uimg, faces, 1.1, 3, 0, minSize);
stopTimer();
}
}
else
OCL_PERF_ELSE
//sort(faces.begin(), faces.end(), comparators::RectLess());
SANITY_CHECK_NOTHING();//(faces, min_size/5);
// using SANITY_CHECK_NOTHING() since OCL and PLAIN version may find different faces number
}