Home | History | Annotate | Download | only in perf
      1 #include "perf_precomp.hpp"
      2 
      3 using namespace std;
      4 using namespace cv;
      5 using namespace perf;
      6 using std::tr1::make_tuple;
      7 using std::tr1::get;
      8 
      9 CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT_101)
     10 
     11 typedef std::tr1::tuple<string, int, int, double, BorderType> Img_BlockSize_ApertureSize_k_BorderType_t;
     12 typedef perf::TestBaseWithParam<Img_BlockSize_ApertureSize_k_BorderType_t> Img_BlockSize_ApertureSize_k_BorderType;
     13 
     14 PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris,
     15             testing::Combine(
     16                 testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
     17                 testing::Values( 3, 5 ),
     18                 testing::Values( 3, 5 ),
     19                 testing::Values( 0.04, 0.1 ),
     20                 BorderType::all()
     21                 )
     22           )
     23 {
     24     string filename = getDataPath(get<0>(GetParam()));
     25     int blockSize = get<1>(GetParam());
     26     int apertureSize = get<2>(GetParam());
     27     double k = get<3>(GetParam());
     28     BorderType borderType = get<4>(GetParam());
     29 
     30     Mat src = imread(filename, IMREAD_GRAYSCALE);
     31     ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
     32 
     33     Mat dst;
     34 
     35     TEST_CYCLE() cornerHarris(src, dst, blockSize, apertureSize, k, borderType);
     36 
     37     SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE);
     38 }
     39 
     40 typedef std::tr1::tuple<string, int, int, BorderType> Img_BlockSize_ApertureSize_BorderType_t;
     41 typedef perf::TestBaseWithParam<Img_BlockSize_ApertureSize_BorderType_t> Img_BlockSize_ApertureSize_BorderType;
     42 
     43 PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerEigenValsAndVecs,
     44             testing::Combine(
     45                 testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
     46                 testing::Values( 3, 5 ),
     47                 testing::Values( 3, 5 ),
     48                 BorderType::all()
     49             )
     50           )
     51 {
     52     string filename = getDataPath(get<0>(GetParam()));
     53     int blockSize = get<1>(GetParam());
     54     int apertureSize = get<2>(GetParam());
     55     BorderType borderType = get<3>(GetParam());
     56 
     57     Mat src = imread(filename, IMREAD_GRAYSCALE);
     58     ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
     59 
     60     Mat dst;
     61 
     62     TEST_CYCLE() cornerEigenValsAndVecs(src, dst, blockSize, apertureSize, borderType);
     63 
     64     Mat l1;
     65     extractChannel(dst, l1, 0);
     66 
     67     SANITY_CHECK(l1, 2e-5, ERROR_RELATIVE);
     68 }
     69 
     70 PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerMinEigenVal,
     71             testing::Combine(
     72                 testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
     73                 testing::Values( 3, 5 ),
     74                 testing::Values( 3, 5 ),
     75                 BorderType::all()
     76             )
     77           )
     78 {
     79     string filename = getDataPath(get<0>(GetParam()));
     80     int blockSize = get<1>(GetParam());
     81     int apertureSize = get<2>(GetParam());
     82     BorderType borderType = get<3>(GetParam());
     83 
     84     Mat src = imread(filename, IMREAD_GRAYSCALE);
     85     ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
     86 
     87     Mat dst;
     88 
     89     TEST_CYCLE() cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType);
     90 
     91     SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE);
     92 }
     93