Home | History | Annotate | Download | only in perf
      1 // This file is part of OpenCV project.
      2 // It is subject to the license terms in the LICENSE file found in the top-level directory
      3 // of this distribution and at http://opencv.org/license.html.
      4 
      5 // Copyright (C) 2014, Itseez, Inc., all rights reserved.
      6 // Third party copyrights are property of their respective owners.
      7 
      8 #include "perf_precomp.hpp"
      9 
     10 using namespace std;
     11 using namespace cv;
     12 using namespace perf;
     13 using namespace testing;
     14 using std::tr1::make_tuple;
     15 using std::tr1::get;
     16 
     17 typedef std::tr1::tuple<string, Point, int, int, int, int> Size_Source_Fl_t;
     18 typedef perf::TestBaseWithParam<Size_Source_Fl_t> Size_Source_Fl;
     19 
     20 PERF_TEST_P(Size_Source_Fl, floodFill1, Combine(
     21     testing::Values("cv/shared/fruits.png", "cv/optflow/RubberWhale1.png"), //images
     22             testing::Values(Point(120, 82), Point(200, 140)), //seed points
     23             testing::Values(4,8), //connectivity
     24             testing::Values((int)IMREAD_COLOR, (int)IMREAD_GRAYSCALE), //color image, or not
     25             testing::Values(0, 1, 2), //use fixed(1), gradient (2) or simple(0) mode
     26             testing::Values((int)CV_8U, (int)CV_32F, (int)CV_32S) //image depth
     27             ))
     28 {
     29     //test given image(s)
     30     string filename = getDataPath(get<0>(GetParam()));
     31     Point pseed;
     32     pseed = get<1>(GetParam());
     33 
     34     int connectivity = get<2>(GetParam());
     35     int colorType = get<3>(GetParam());
     36     int modeType = get<4>(GetParam());
     37     int imdepth = get<5>(GetParam());
     38 
     39     Mat image0 = imread(filename, colorType);
     40 
     41     Scalar newval, loVal, upVal;
     42     if (modeType == 0)
     43     {
     44         loVal = Scalar(0, 0, 0);
     45         upVal = Scalar(0, 0, 0);
     46     }
     47     else
     48     {
     49         loVal = Scalar(4, 4, 4);
     50         upVal = Scalar(20, 20, 20);
     51     }
     52     int newMaskVal = 255;  //base mask for floodfill type
     53     int flags = connectivity + (newMaskVal << 8) + (modeType == 1 ? FLOODFILL_FIXED_RANGE : 0);
     54 
     55     int b = 152;//(unsigned)theRNG() & 255;
     56     int g = 136;//(unsigned)theRNG() & 255;
     57     int r = 53;//(unsigned)theRNG() & 255;
     58     newval = (colorType == IMREAD_COLOR) ? Scalar(b, g, r) : Scalar(r*0.299 + g*0.587 + b*0.114);
     59 
     60     Rect outputRect = Rect();
     61     Mat source = Mat();
     62 
     63     for (;  next(); )
     64     {
     65         image0.convertTo(source, imdepth);
     66         startTimer();
     67         cv::floodFill(source, pseed, newval, &outputRect, loVal, upVal, flags);
     68         stopTimer();
     69     }
     70     EXPECT_EQ(image0.cols, source.cols);
     71     EXPECT_EQ(image0.rows, source.rows);
     72     SANITY_CHECK_NOTHING();
     73 }
     74