Home | History | Annotate | Download | only in opencl
      1 #include "../perf_precomp.hpp"
      2 #include <opencv2/imgproc.hpp>
      3 
      4 #include "opencv2/ts/ocl_perf.hpp"
      5 
      6 using namespace std;
      7 using namespace cv;
      8 using namespace perf;
      9 using std::tr1::make_tuple;
     10 using std::tr1::get;
     11 
     12 typedef std::tr1::tuple<std::string, std::string, int> Cascade_Image_MinSize_t;
     13 typedef perf::TestBaseWithParam<Cascade_Image_MinSize_t> Cascade_Image_MinSize;
     14 
     15 #ifdef HAVE_OPENCL
     16 
     17 OCL_PERF_TEST_P(Cascade_Image_MinSize, CascadeClassifier,
     18                  testing::Combine(
     19                     testing::Values( string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt.xml"),
     20                                      string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt2.xml"),
     21                                      string("cv/cascadeandhog/cascades/lbpcascade_frontalface.xml") ),
     22                     testing::Values( string("cv/shared/lena.png"),
     23                                      string("cv/cascadeandhog/images/bttf301.png"),
     24                                      string("cv/cascadeandhog/images/class57.png") ),
     25                     testing::Values(30, 64, 90) ) )
     26 {
     27     const string cascadePath = get<0>(GetParam());
     28     const string imagePath   = get<1>(GetParam());
     29     int min_size = get<2>(GetParam());
     30     Size minSize(min_size, min_size);
     31 
     32     CascadeClassifier cc( getDataPath(cascadePath) );
     33     if (cc.empty())
     34         FAIL() << "Can't load cascade file: " << getDataPath(cascadePath);
     35 
     36     Mat img = imread(getDataPath(imagePath), IMREAD_GRAYSCALE);
     37     if (img.empty())
     38         FAIL() << "Can't load source image: " << getDataPath(imagePath);
     39 
     40     vector<Rect> faces;
     41 
     42     equalizeHist(img, img);
     43     declare.in(img).time(60);
     44 
     45     UMat uimg = img.getUMat(ACCESS_READ);
     46 
     47     while(next())
     48     {
     49         faces.clear();
     50         cvtest::ocl::perf::safeFinish();
     51 
     52         startTimer();
     53         cc.detectMultiScale(uimg, faces, 1.1, 3, 0, minSize);
     54         stopTimer();
     55     }
     56 
     57     sort(faces.begin(), faces.end(), comparators::RectLess());
     58     SANITY_CHECK(faces, min_size/5);
     59 }
     60 
     61 #endif //HAVE_OPENCL
     62